Firstly thanks to everyone that has been part of the HASS community… I have played with it for years but only jumped in seriously over the last couple of months and there is so much support it’s incredible.
I think I may be a bit crazy however… From what I can gather HASS stores sensor ‘values’ when they change (seems reasonable to minimise storage requirements) but I’m finding this is actually resulting in lost information. Here’s the logic:
- Assume a sensor updates every minute.
- For 10 minutes the sensor returns 0 (not unknown but a legit 0) and then 50 on the 10th minute
- HASS stores a 0 point @ t and a 50 @ t+10minutes
- You now plot this with any reasonable plotting scheme and it will draw a ramp (or fit a curve) between these points…
The issue being this plot is more wrong than it needs to be. From the data we know at t+9 the value was still zero and only then did it start to ramp, yet that information is lost and it is now indistinguishable from a situation where the update interval is 10m. Over the last month I read all sorts of suggestions and tried:
- Forcing values to be written through automations (
homeassistant.update_entity
) - Template trigger sensors
- Adding
states.sensor.time
to templates - Editing an attribute on update (eg.
minute_counter: "{{ now().minute }}"
)
but came to the realisation that (I think) all these are about updating the sensor and do nothing to force the repeated values from actually being stored. With this I decided to add a tiny random offset ((range(0, 10) | random)/10000
) when in a known stable state and all of a sudden I could see values every minute.
Anyway, long story short, surely introducing jitter to a sensor isn’t the only way to ensure values are stored? Please tell me I’m crazy and there is something blatantly obvious I’m missing (a min store interval?).
If you got to the end of this… thanks!