Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Last active January 3, 2018 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxmartin/1d4ac2a2ffc821e73eed05ad1b48048a to your computer and use it in GitHub Desktop.
Save tuxmartin/1d4ac2a2ffc821e73eed05ad1b48048a to your computer and use it in GitHub Desktop.
Domoticz dzVents - spozdene zapinani rele pres uzivatelsky vypinac s triggerem kazdou 1 minutu
function vypni(domoticz)
local rele = domoticz.devices('rele')
rele.switchOff().afterMin(3)
domoticz.log("vypinam za xxx minut")
end
function zapni(domoticz)
local rele = domoticz.devices('rele')
rele.switchOn().afterMin(3)
domoticz.log("zapinam za xxx minut")
end
return {
active = true,
logging = {
level = domoticz.LOG_DEBUG,
marker = "TEST"
},
data = {
rele_zapinaSe = { initial = false },
rele_vypinaSe = { initial = false }
},
on = {
devices = {
'vypinac' -- idx 28
},
timer = {
'every 1 minutes'
}
},
execute = function(domoticz, device, triggerInfo)
domoticz.log("1 rele_zapinaSe stav " .. tostring(domoticz.data.rele_zapinaSe))
domoticz.log("1 rele_vypinaSe stav " .. tostring(domoticz.data.rele_vypinaSe))
if (triggerInfo.type == domoticz.EVENT_TYPE_TIMER) then -- Timer triggered use
domoticz.log("event: EVENT_TYPE_TIMER")
elseif (triggerInfo.type == domoticz.EVENT_TYPE_DEVICE) then -- Device triggered use
domoticz.log("event: EVENT_TYPE_DEVICE")
end
local rele = domoticz.devices('rele')
local vypinac = domoticz.devices('vypinac')
if (vypinac.state == 'On' and domoticz.data.rele_zapinaSe == false) then
domoticz.log('turning on...')
domoticz.data.rele_zapinaSe = true
zapni(domoticz)
elseif (vypinac.state == 'On') then
domoticz.data.rele_vypinaSe = false
end
if (vypinac.state == 'Off' and domoticz.data.rele_vypinaSe == false) then
domoticz.log('turning off...')
domoticz.data.rele_vypinaSe = true
vypni(domoticz)
elseif (vypinac.state == 'Off') then
domoticz.data.rele_zapinaSe = false
end
domoticz.log("2 rele_zapinaSe stav " .. tostring(domoticz.data.rele_zapinaSe))
domoticz.log("2 rele_vypinaSe stav " .. tostring(domoticz.data.rele_vypinaSe))
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment