im currently trying to write a dzvents to control my towel rail
the scenario is
i have a wemo switch in the bathroom on the powerpoint for the towel rail
if its switched on manually at the switch (which is the most likely)
it doesnt update in domoticz
so i would like to set a switch that checks every 10 minutes using the phyton command wemo status (ouixmux)
which returns something like ('Switch:', 'Wemo', '\t', 0) off
or ('Switch:', 'Wemo', '\t', 1) on
this is where ive gotten so far...im stuck on the script return part....and the end in the middle.... line 27
Code: Select all
-- Check the wiki at
-- http://www.domoticz.com/wiki/%27dzVents%27:_next_generation_LUA_scripting
return {
-- 'active' controls if this entire script is considered or not
active = false, -- set to false to disable this script
-- trigger
-- can be a combination:
on = {
timer = {
-- timer triggers.. if one matches with the current time then the script is executed
'every 10 minutes'
}
},
data = {
towelrailontime = {domoticz.device('towel rail').lastUpdate.raw}
wemo_state = {initial=off}
}
-- actual event code
-- in case of a timer event or security event, device == nil
execute = function(domoticz, device)
-- check for if switch is manually turned On
--need somthing to run script and report if switch is on or off and report back to wemo_state
if domoticz.data.wemo_state == 'off'then
goto end
elseif domoticz.data.wemo_state == 'on' then
--turn on towel rail without triggering on script
domoticz.device('towel rail').switchOn(true)
--actual off switch
if (domoticz.device('towel rail').state == 'On') and domoticz.time.raw - domoticz.data.towelrailontime > 45 then
domoticz.device('towel rail').switchOff()
end
end
}