Page 1 of 1
Turn on device after On state other device
Posted: Thursday 03 January 2019 18:54
by Labtec
Hi,
Could you help me with a script for switching on a device if the source is x minutes On
For example:
I want to turn On a device after a light is x minutes On
I tried to make it with blocky but it is not possible to use a Control block IF and a Set block On for x minutes
Thanks
Re: Turn on device after On state other device
Posted: Friday 04 January 2019 11:46
by Labtec
Hi, this is de LUA code I used in Fibaro, how can I modify this to use it in Domoticz.
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(31, "value");
if (( tonumber(fibaro:getValue(31, "value")) > 0 ) and (os.time() - deviceLastModification0) >= 120) then
delayedCheck0 = true;
end
local startSource = fibaro:getSourceTrigger();
if (
( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
fibaro:call(33, "turnOn");
fibaro:sleep(300000)
fibaro:call(33, "turnOff")
end
end, 120000)
Re: Turn on device after On state other device
Posted: Friday 04 January 2019 12:15
by freijn
I think you can use this example :
https://www.domoticz.com/wiki/Event_script_examples
or the dzvents version :
From the domoticz examples online:
http://www.domoticz.com/wiki/Event_script_examples
Code: Select all
[[Send a warning when the garage door has been open for more than 10 minutes
]]
return {
active = true,
on = {
['timer'] = {
'every minute',
}
},
execute = function(domoticz)
local door = domoticz.devices('Garage door')
if (door.state == 'Open' and door.lastUpdate.minutesAgo > 10) then
domoticz.notify('Garage door alert',
'The garage door has been open for more than 10 minutes!',
domoticz.PRIORITY_HIGH)
end
end
}
Re: Turn on device after On state other device
Posted: Friday 04 January 2019 16:49
by Labtec
Thanks!