triggering script between given hours

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

Moderator: leecollings

Post Reply
Adso76
Posts: 20
Joined: Tuesday 28 August 2018 21:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

triggering script between given hours

Post by Adso76 »

I have PIR sensor on detecting which I want to turn on other device. But I want this to happen only between given hours. Whats wrong with the script?

Code: Select all


return {

on =
    {

        devices = {
            'PIRSleeping',
            ['nightTime'] = {'between 23:00 and 06:00'}

           },
    },
       
    execute = function(domoticz, PIRSleeping)

        if (domoticz.devices("PIRSleeping").state == "Off" and (domoticz.devices == 'nightTime' and domoticz.devices == 'On')) then

            domoticz.devices('gosund').switchOn()

        end
    end

}
Domoticz Version: 4.9895 running on Raspberry Pi B 3+ (Raspbian). PCF8574 as input and output.
plugge

Re: triggering script between given hours

Post by plugge »

Assuming that 'nightTime' is a device (which I doubt) that is triggered between 23:00-06:00.
PIRSleeping hold the triggered device.
The script should/could read like:

Code: Select all

return {

on =
    {

        devices = {
            'PIRSleeping',
            ['nightTime'] = {'between 23:00 and 06:00'}

           },
    },
       
    execute = function(domoticz, PIRSleeping)

        if domoticz.devices("PIRSleeping").state == "Off" and
     	   (PIRSleeping.name == 'nightTime' and PIRSleeping.state == 'On')
	then
            domoticz.devices('gosund').switchOn()
	end
    end
}
if 'nightTime' is not a device then you need a different script:

Code: Select all

return {

on =
    {

        devices = {
            ['PIRSleeping'] = {'between 23:00 and 06:00'}

           },
    },
       
    execute = function(domoticz, PIRSleeping)

        if domoticz.devices('PIRSleeping').state == 'Off'
	then
            domoticz.devices('gosund').switchOn()
	end
    end

}
Adso76
Posts: 20
Joined: Tuesday 28 August 2018 21:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: triggering script between given hours

Post by Adso76 »

Thanks a lot! Works perfectly! I couldn't grasp that from dzvents tutorial.
Domoticz Version: 4.9895 running on Raspberry Pi B 3+ (Raspbian). PCF8574 as input and output.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest