Some of you may be familiar with My Central Heating Solution using Thermal Actuators (which has my current Items/Rules listed, rather than re-list it here), and I’m also happily using both Alexa and Google Assistant to allow voice-based changes to the current Target Temperature.
This works great, and they “reset” when a Cron rule triggers to change a Target Temperature.
However, I’d like to limit the timescale for which these “manual” changes to the Target Temperature are applied if there’s a big time gap between a scheduled Cron job.
For a simple example, lets say I have rules set to change the target at 6am, 2pm and 10pm, thus, a change to a Target at 1pm will be applied for 1 hour. But a change at 3pm will be applied for 7 hours.
(but also, a change made at 1:58pm will only be applied for 2 minutes, but for now lets say that I’m happy with that!)
I’m hopefully not going to fall into the typical XY problem trap and ask for just help with what I think is the solution - if I’ve overcomplicated this, please, please let me know! (And hence why I’ve tried to add more information above to try to indicate what problem I’m trying to solve)
So, with all that said, I think that I’d need to trigger a Timer when my TargetTemperature item is changed - but I think I would want this to ONLY be applied if it’s not been changed by the Rule (otherwise I’m spawning lots of timers every time my temperatures change on their schedule). Then, when the timer expires, it will reset this to its Normal Target temperature.
However, I’m not entirely sure if this is the correct answer, and if so, how I’d go about it.
As a basic, this works, but does create a timer for each room every time the target changes (including from my scheduled Cron rules), which can be a few times a day:
createTimer(now.plusMinutes(60)) [| val String GroupName = triggeringItem.name.substring(0, 4) val target = ScriptServiceUtil.getItemRegistry.getItem(GroupName + "Heating_PresetTempNormal") triggeringItem.sendCommand(target.state as Number) ]