I tried searching for an answer to this, but I’m not sure I even know how to phrase the search…
I’m trying to come up with an automation that turns on a heater (via a smart plug) when the temperature in the room is below a certain temperature (19C), but only between 7pm and 8am. Another component of the automation turns off the heater when the temperature goes above a certain temperature (20C)
I created an automation where the trigger is the temperature dropping below 19C and the condition is between 7pm and 8am. As expected, between 7pm and 8am, if the temperature drops below 19C, the heater turns on. But the problem is if the temperature has dropped below 19C before 7pm, the heater never turns on (I guess because the automation is only monitoring for a CHANGE from higher than 19C to lower than 19C).
If I come at it from the other direction, i.e. an automation where the trigger is the time (7pm), and the condition is the temperature below 19C, then it turns on at 7pm if the temperature is already below 19C. But if it’s higher than 19C at 7pm, but then later drops below 19C, the heater does not turn on.
I could solve this by making one automation that turns on the heater at 7pm if the temperature is below 19C, and another that turns it on if the temperature drops below 19C between 7pm and 8am (i.e. have BOTH of the above automations)… but is there a way to accomplish this with just one automation?
I would also need the automation to turn off the heater if the temperature went above 20C between 7pm and 8am, and then turn back on if the temperature dropped below 19C again between those hours.
I would caution against using Automations for “Ad-hoc” heating purposes, especially relying on a separate temp sensor, doubly especially if you are firing the heater using a consumer grade smart plug. Should your automation begin to oscillate on/off rapidly as your temp oscillates around your desired set point, you are at REAL risk of a serious fire hazard from the heater, the smart plug, or both. Most people hooking up their HA instance for heating services are tying them into actual heating controllers (Nest, etc.) that are fit for purpose. I CANNOT CAUTION YOU ON THIS POINT ENOUGH.
I DO have one set up myself to heat up my car during the winter months, but it is NOT temp activated specifically for this reason. It fires up at a set time, before I wake up to clear any frost or snow, turns off after 45min, resting off for a full 15min before turning on again. I use an exterior grade smart plug, heavy duty exterior extension and an air conditioner grade extension (flat, so I can shut the car door on it). And I activate it the automation before I go to bed, it doesn’t run nightly on it’s own (ensures I actually set up my heater properly). I also went to the trouble of monitoring the process on the first few runs, just in case.
A non-HASS option you might want to consider that will likely get you what you want is an Inkbird ITC-308-WIFI temp controller. I have an insulated outdoor shelter for a couple of semi-feral cats that have taken up residence and I wanted to provide a base level of heating during winter, remote control for adjustment, and some data capture to make sure everything is going OK. The important parts are integrated temp sensor and the ability to set a firing delay to prevent rapid on/off cycling. Those combined mitigate the problems I warned of above. The Inkbrd Pro App allows for scheduling, but I have never used it as I want relatively constant temp. I also purposely selected a really small heater : a Honeywell Heat Bud personal ceramic heater as a heat source and built a cement board enclosure with grated openings that allow airflow but prevent cat access to it.
It’s not connected to my HomeAssistant, but it doesn’t need to be, I would argue it handles its task better, easier, more reliably, and SAFER than anything I might try cobbling together with HomeAssistant, separate temp sensors, and separate smart plugs.
Do make sure it can handle the power needs of whatever heater you want to hook up to it prior to purchasing one.