Hello,
I’m trying to create a statistics sensor in order to retrieve the max value of a pool water temperature sensor over the last 24 hours. My source sensor is available only when the water pump is running, but still I would like to get the max recorded value over these periods.
It looks like the statistics sensor should be able to do this, however this sensor reports itself as “unavailable” as soon as the source sensor is “unavailable”. I’ve found the following piece of code in homeassistant/components/statistics/sensor.py
which seems to confirm what I’m seeing:
@property
def available(self) -> bool:
"""Return the availability of the sensor linked to the source sensor."""
return self._available
However, I don’t understand why the availability of the source and computed sensors should be linked. Even if the source becomes unavailable the history still contains the relevant info for the statistics to be computed.
Is my understanding correct? Is this behavior intended to cover a different use case? Would it be possible to do what I’m trying to achieve differently?
I’ve been doing this using a direct SQL query for a while, however my request broke multiple times after HA updates so I would like to find a more reliable solution.
Thanks.