if device = on and between specified time interval

Post Reply
TheCondor
Posts: 31
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

if device = on and between specified time interval

Post by TheCondor » Friday 04 August 2017 23:55

Hello, i'm trying a very simple script but without success. I need to turn on a light "Bano Lampada" when the PIR is ON (Sensore Movimento) but only during the night, suppose an interval between 23:00 and 07:00.

That's what i do, but it doesn't works. If i remove the 'time' part works fine obviously... so i'm not using correctly the time function of dzvents.... any help is very appreciated, thanks in advance.

Code: Select all

return {
	active = true,
	
	on = {
		devices = {
            'Sensore Movimento'
        }
},
	execute = function(domoticz, Bagno)
			if domoticz.devices('Sensore Movimento').state == 'On' then
			    if (domoticz.time.hour > 23 and domoticz.time.hour < 7) then
                    domoticz.devices('Bagno Lampada').switchOn().forMin(2)
		        end
            end
	end
}

markjgabb
Posts: 127
Joined: Wednesday 25 January 2017 0:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Australia
Contact:

Re: if device = on and between specified time interval

Post by markjgabb » Saturday 05 August 2017 0:00

Think you need to use or. As the time can't be both after 11 and before 7 at the same time
V 3.8153 RPI 3
RFlink 334 mhz
mysensors
broadlink
wemo

bimse
Posts: 19
Joined: Sunday 05 February 2017 13:09
Target OS: Raspberry Pi
Domoticz version: Model 3
Contact:

Re: if device = on and between specified time interval

Post by bimse » Saturday 05 August 2017 9:57

[Try this

Code: Select all

return {
	active = true,
	
	on = {
		devices = {
            			['Sensore Movimento'] = {'at 23:00-07:00'}

        }
},
	execute = function(domoticz, Bagno)
			if domoticz.devices('Sensore Movimento').state == 'On' then
			         domoticz.devices('Bagno Lampada').switchOn().forMin(2)
		        end
            end
}
[/quote]
Translated with google

TheCondor
Posts: 31
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

Re: if device = on and between specified time interval

Post by TheCondor » Sunday 06 August 2017 17:10

Awesome, both works fine, thanks and sorry for the dummy question!!!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests