Blame | Last modification | View Log | Download
-- local device id's, only used in this scriptlocal cDevAquaHeaterPlug = 124local cDevAquaHeaterWatt = 130local cDevVirtHeater = 142local iONdelay = 30return {on = {devices = {cDevAquaHeaterPlug, cDevVirtHeater, cDevAquaHeaterWatt},--system = {'start'},--timer = { 'every 1 minutes' },},logging = {level = domoticz.LOG_ERROR,--level = domoticz.LOG_DEBUG + domoticz.LOG_INFO,marker = 'Aquarium-Heater',},execute = function(domoticz, triggeredItem)if (triggeredItem.isDevice) thendomoticz.log('Device ' .. triggeredItem.name .. ' was changed', domoticz.LOG_INFO) --domoticz.LOG_FORCEendif (triggeredItem.isDevice) and (triggeredItem.id == cDevAquaHeaterPlug) then-- if heater is turned off, switch on after specified timeif (not triggeredItem.active) then -- state == 'Off'domoticz.log('Device ' .. triggeredItem.name ..' will be turned ON after delay of ' .. tostring(iONdelay) ..' minutes', domoticz.LOG_DEBUG)triggeredItem.switchOn().afterMin(iONdelay).silent()endend-- Make sure heater plug is turned on at startupif (triggeredItem.isSystemEvent) then--and (not domoticz.devices(cDevAquaHeaterPlug).active)domoticz.log('System event handling', domoticz.LOG_DEBUG)if (triggeredItem.type == 'start') thendomoticz.devices(cDevAquaHeaterPlug).switchOn().silent()endend-- Turn heater indication if power > 0, check this for every triggerdomoticz.log('Device ' .. domoticz.devices(cDevAquaHeaterWatt).name ..' has actual power of: ' .. tostring(domoticz.devices(cDevAquaHeaterWatt).actualWatt) ..' Watt', domoticz.LOG_DEBUG)if (domoticz.devices(cDevAquaHeaterWatt).actualWatt > 0.0) thendomoticz.devices(cDevVirtHeater).switchOn().silent()domoticz.log('Switch ON cDevVirtHeater', domoticz.LOG_DEBUG)elsedomoticz.devices(cDevVirtHeater).switchOff().silent()domoticz.log('Switch OFF cDevVirtHeater', domoticz.LOG_DEBUG)endend}