Trigger depending of time AND device  [Solved]

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

Moderator: leecollings

Post Reply
usky73
Posts: 39
Joined: Saturday 07 November 2015 9:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: france
Contact:

Trigger depending of time AND device

Post by usky73 »

Hi all
I am updating all my scripts in DzVent. And this is really a great improvement.

Then I want more !
Is there a way to link 2 trigger conditions : time AND devices instead of time OR devices.
I want my script to run from sunset to morning and only if one device (motion sensor) state change.

At the moment I have only a trigger on the devices but I dont't want to run the script in day time.

Any idea ?
Geuvert
Posts: 6
Joined: Tuesday 07 May 2019 20:11
Target OS: Linux
Domoticz version: 4.10717
Location: Netherlands
Contact:

Re: Trigger depending of time AND device

Post by Geuvert »

Hi Usky,

Personally I have a timer script running in which I use an if statement to check the state of a switch.
My (simplified) code looks like this:

Code: Select all

return {
    active = true,
	on = {
		timer =	{
			'every minute at 14:00-22:16',
		}
	},
	
	execute = function(domoticz, device, switch)
	    local I2    = domoticz.devices('Qubino Dimmer I2')
        
        if (I2.state == 'On') then
            light.switchOn()
        end
	end
}
I removed some of the code, so not sure is this runs as is.

If this is not what you're looking for I believe you can add a device after the time. Not sure how that works though.
It should look something like:

Code: Select all

return {
    active = true,
	on = {
		timer =	{
			'every minute at 14:00-22:16',
		},
		devices = {
			'Switch 1'
		}
	},
	...
	
Though I am not sure whether this triggers if both conditions are met (time and device) or if either one is met.

Hope this helps.


Geuvert
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Trigger depending of time AND device

Post by waaren »

usky73 wrote: Saturday 29 June 2019 8:28 Hi all
I am updating all my scripts in DzVent. And this is really a great improvement.

Then I want more !
Is there a way to link 2 trigger conditions : time AND devices instead of time OR devices.
I want my script to run from sunset to morning and only if one device (motion sensor) state change.

At the moment I have only a trigger on the devices but I dont't want to run the script in day time.

Any idea ?

Code: Select all

return 
{
   on = 
   {
      devices = { ['myMotionSensor'] = { 'at nighttime' } }
   },
   
   execute = function(domoticz,item)
      if (item.state == 'On') then
         domoticz.log('Sensor ' .. item.name .. ' was turned on.',domoticz.LOG_FORCE)
      end
   end
}
Look here for more examples
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
usky73
Posts: 39
Joined: Saturday 07 November 2015 9:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: france
Contact:

Re: Trigger depending of time AND device

Post by usky73 »

Thanks a lot to all.
Waaren you got my point. That's exactly what I was looking for. I missed that point in the doc.
usky73
Posts: 39
Joined: Saturday 07 November 2015 9:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: france
Contact:

Re: Trigger depending of time AND device

Post by usky73 »

for testing purpose I have tested that :

Code: Select all

on = {
		devices = { ['Hue motion sensor salon'] = {'at civildaytime'} }
	},
but it is not working, any idea ?
usky73
Posts: 39
Joined: Saturday 07 November 2015 9:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: france
Contact:

Re: Trigger depending of time AND device

Post by usky73 »

Just did test and it works with other timer parameters but not with 'at civildaytime'
For this value should work for any day time. But it is not the case. Am I correct ?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Trigger depending of time AND device

Post by waaren »

usky73 wrote: Saturday 29 June 2019 20:00 Just did test and it works with other timer parameters but not with 'at civildaytime'
For this value should work for any day time. But it is not the case. Am I correct ?
You are correct. Nice catch and thanks for reporting. Fixed in next beta.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
usky73
Posts: 39
Joined: Saturday 07 November 2015 9:53
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: france
Contact:

Re: Trigger depending of time AND device  [Solved]

Post by usky73 »

:-)
Post Reply

Who is online

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