I have a PoolSense integration with Home Assistant. It works really well and records values every few hours. However, I am using the in-line version of the sensor, so the readings are only accurate during the time which the pool pump runs, in my case between 10h00 and 15h00. What I am trying to achieve is to calculate the average pH and Chlorine levels during these hours and then report those readings to me on a daily basis to allow me to treat the pool appropriately. Here is the template I have created, but I am just getting “unavailable” as a reading
This refers to sensor.date_time. Where and how is that defined? What is the value of it? This doesn’t seem to be a default sensor that I can reference in my instance. Check that it is setting the value you expect it to be.
Once you have corrected the above, go to Developer Tools, then the Template tab and copy what you’ve got straight into that box. It will give you the output of the template and tell you if there are errors (such as a sensor being undefined, the wrong type being used, etc) and you can correct from there. You can also add in things like {{ start_time }} to view and double check that the value in that variable is what you were expecting.
Assuming this sensor only has a date: sensor.date_time you would be better off doing this:
{% set start_time = today_at('10:00:00') %}
{% set end_time = today_at('15:00:00') %}
Putting aside what Sam said above about last_updated being a property of the state object and not an attribute, even if it was an attribute I think this would be comparing strings, not datetime objects:
selectattr('last_updated', 'ge', start_time)
So you may not get the results you expected. e.g. when comparing strings (left to right) “2” is ge than “12”.