i am trying to make a scene which runs every 5 minutes, if the humidity of my room is lower than 29.9 then turn my humidifier on, else turn it off. my code so far is:
local humidity = luup.variable_get("urn:upnp-org:serviceId:HumiditySensor1","CurrentLevel", 13)
local max = 30
if (tonumber(humidity) < max) then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 5)
else
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, 5)
end
this doesnt come up with an error however doesnt turn the switch on or off
got it working in the end, made it slightly more advanced by installing the variable container app, now it takes a maximum humidity from the veritable container app, meaning i dont need to change the lua code just to alter this.
local Humidity = luup.variable_get("urn:micasaverde-com:serviceId:HumiditySensor1" , "CurrentLevel" , 13)
local max = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable2", 37)
if (tonumber(Humidity) < tonumber(max)) then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 5)
else
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, 5)
end
Best Home Automation shopping experience. Shop at Ezlo!