Blame | Last modification | View Log | Download
-- local device id's, only used in this scriptlocal cDevDeken = 188local cVirtTimer = 187local cDevTemp = 169local cDevMargrietHome = 162-- local constantslocal cMaxOutTemp = 8 -- Celsiusreturn {on = {devices = { cDevDeken, cVirtTimer, cDevMargrietHome, cDevTemp}},logging = {--level = domoticz.LOG_DEBUG + domoticz.LOG_INFO,level = domoticz.LOG_ERROR,marker = "Edeken-Margriet"},execute = function(domoticz, triggeredItem)domoticz.log('Device ' .. triggeredItem.name .. ' was changed', domoticz.LOG_INFO)-- handle the device triggersif (triggeredItem.isDevice) thenlocal lDekenOn = (domoticz.devices(cDevDeken).active)local lTimerOn = domoticz.devices(cVirtTimer).active--var = false and 20 or 30 return 30local lTempLow = (tonumber(domoticz.devices(cDevTemp).state) < cMaxOutTemp) and true or falselocal lMargrietHome = domoticz.devices(cDevMargrietHome).activedomoticz.log('Outside Temperature: ' .. tostring(domoticz.devices(cDevTemp).state))domoticz.log('lDekenOn, lTimerOn, lTempLow, lMargrietHome: ' .. tostring(lDekenOn) .. ', ' .. tostring(lTimerOn) .. ', ' .. tostring(lTempLow) .. ', ' .. tostring(lMargrietHome))-- E-blanket should be turned on: Margriet home and timer ON and Outside temp lowif (triggeredItem.id ~= cDevDeken) thenif (lTimerOn and lTempLow and lMargrietHome) thendomoticz.devices(cDevDeken).switchOn().silent()domoticz.log('Switched cDevDeken ON')elsedomoticz.devices(cDevDeken).switchOff().silent()endelse-- manual turn blanket on, 1.5 hours maxif (triggeredItem.active) then -- state == 'On'triggeredItem.switchOff().afterMin(90) -- if it is a switch, turn off after 90 minuteselsedomoticz.devices(cVirtTimer).switchOff()endendendend}