Trying to get a handle on schedules and triggers and reading devices …
My goal is to turn my pool pump on when the temperature is below 32 degrees. I want to run the pump for 10 minutes then turn it off. I’d like it to stay off for 20-30 minutes and then check the temperature again.
I have four scenes to turn equipment on and off - 1 scene each to turn the pump and polaris pump on, 1 scene each to turn the pumps off. I’ve setup schedules for these scenes - turn the pumps on at 6:00 a.m., turn the pumps of at 11:00 a.m. for example. That all works fine.
I created a scence call FreezeConditions that will turn the pumps on. I found and modified some luup code to check the temperature and only allow the scene to run if the temperature is below 32. I put this in the luup tab of the FreezeConditions tab - seems to work correctly when I manually run the scene.
local dID = 31 -- Device ID of your thermostatic/temperature sensor
local tLow = 0 -- Lowest temperature of range
local tHigh = 32 -- Highest temperature of range
local allow = true -- true runs scene when in range, false blocks it
local tCurrent = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",dID)))
return (tCurrent <= tHigh) == allow
I thought I would create a schedule to run the scene every hour - if the temp is below 32 it will run the scene, if not the scene will abort and the schedule will run again in an hour.
But, I thought that’s a lot of schedule running 365 days a year and pretty pointless most of the time (I live in the south). So I thought adding a trigger would be a better way to go.
I added a trigger in the triggers tab of the scene that checks the Wunderground temperature device and runs if the temp is below 32.
The trigger fired fine the first time - ran the scene and sent a text to my phone as requested. But the trigger did not fire again. I am suspecting the trigger will not fire until the temperature changes, i.e. the status of the device actually changes. Is this a correct assumption?
Keeping the solution simple, yet elegant, what is the best way to re-check the state of the device and re-run the scene without setting up a schedule to run periodically?
Once I get this sorted, I will want to figure out how to keep the scene from running if the pumps are already on - i.e. the regularly scheduled scene is in progress. Pointers on this would be very welcome as well.
Thanks in advance!