I do have a device, a heat pump, which can have three states which I want to derive from its power consumption:
“STANDBY” i.e., power consumption <= 150 Watt
“HEATING” (aka “Heizung”), power consumption above 150 Watt AND below 2300 Watt
“WARM WATER” (aka “Warmwasser”), power above 2300 Watt
As you can see in attached history chart, the heat pump has some overshoot and drops in the power consumption while being in a certain state.
I want to create a sensor that derives the heat pump’s status - but with some kind of “smoothing” of the raw data to avoid e.g., the status to change from “WARM WATER” to “HEATING” for some minutes when the power consumption drops while the heat pump is in WARM WATER state.
I do have a working template sensor - but without that “smoothing” logic. And I am missing an idea how to that. Something like what we have in automation (below x for xx:xx:xx) would be sufficient, I guess. But no idea how to implement this in a template sensor.
You can use triggers in template sensors: Template - Home Assistant
This means you can set a trigger for when the state changes for x amount of time, just like in an automation. The conditions for triggers and other rules that you set in an automation would have to be managed within the template.
Another possibility, that’s how I display the state of my washing machine and dryer, would be to use an automation and set the state of an entity from there. This adds the bonus of debugging capabilities (my washing cycle power consumptions are quite complex) and using the UI.
thanks for that input Helpful - I started experimenting.
Would you mind sharing your setup for the 2nd / the “automation” option? I am not sure I get that yet completely. I assume you use the python set_state script (which I installed in the meantime) but I am struggling how the automation(s) look like. A glance at your YAML definitions of it would likely help me a lot.
I guess I don’t need to translate the german words
I am not using the script. I use the custom component var to store information. You could also store it in an input_text and derive a template sensor from that.