device trigger time-rule constraint

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
mutley
Posts: 9
Joined: Tuesday 16 May 2017 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

device trigger time-rule constraint

Post by mutley »

I know this is really basic and silly question to ask, but I can't seem to find the right syntax for this command. I'm trying to use the 'at nighttime' constrain on a device trigger.

The documentation gives this as an example.

Code: Select all

on = { devices = { ['myDevice'] = 'at nighttime' } }
This is my code

Code: Select all

return {
    active = true,
    on = {
        devices = { [
            'Driveway Cam Motion',
            'Front Door Cam Motion',
            'Back Door Cam Motion',
            'Back Garden Cam Motion'
           ] = 'at nighttime'
        }
    },
    execute = function(domoticz, switch)
    ..............
The error I get
Error: dzVents: Error: error loading module 'motion' from file '/data/home/domoticz/scripts/dzVents/scripts/motion.lua':
/data/home/domoticz/scripts/dzVents/scripts/motion.lua:15: '}' expected (to close '{' at line 10) near '='

Line 10 is 'device=...'
Line 15 '] = 'at nighttime'

I realize I can put the time test in the execute part, but the whole point of using dzVents is to stop this code getting executed unless absolutely necessary. I have a very elaborate motion trigger / light setup that I wrote in C using MQTT events because of the limitations using previous versions of scripts in Domoticz and having to be executed on every event, dzVents looks like the perfect reason to port this.
mosjonathan
Posts: 40
Joined: Friday 24 February 2017 21:20
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: device trigger time-rule constraint

Post by mosjonathan »

this is the i'm using it:

Code: Select all

return {
    active = true,
	on = {
		devices = {
	      ['PowerOff'] = {'at 21:30-03:00'},
		}
	     },
	execute = function(domoticz, device)
mutley
Posts: 9
Joined: Tuesday 16 May 2017 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: device trigger time-rule constraint

Post by mutley »

Thanks. You gave me a hint. Needed to list each time constraint independently. Which makes it a lot more powerful.

Code: Select all

 return {
    active = true,
    on = {
        devices = {
            ['Driveway Cam Motion'] = {'at daytime'},
            ['Front Door Cam Motion'] = {'at daytime'},
            ['Back Door Cam Motion'] = {'at daytime'},
            ['Back Garden Cam Motion'] = {'at daytime'}
            }
    },
    execute = function(domoticz, switch)
...........
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: device trigger time-rule constraint

Post by dannybloe »

Yes, you have to provide a table for the device-time constraints as you can have multiple constraints per device.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest