Page 1 of 1

device trigger time-rule constraint

Posted: Thursday 02 November 2017 14:31
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.

Re: device trigger time-rule constraint

Posted: Thursday 02 November 2017 14:36
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)

Re: device trigger time-rule constraint

Posted: Thursday 02 November 2017 16:47
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)
...........

Re: device trigger time-rule constraint

Posted: Friday 03 November 2017 12:35
by dannybloe
Yes, you have to provide a table for the device-time constraints as you can have multiple constraints per device.