A binary_sensor’s state is on/off (you can confirm that by inspecting the state of binary_sensor.water_leak_detector_water_alarm_water_leak_detected in Developer Tools → States). The reason you see it reported as Wet/Dry in the dashboard UI is because the binary_sensor’s device_class is moisture.
Also the period is weird. At 8:00, will it try to look from now into the future? And what will the sensor report at 18:00? Does the sensor support a reverse time period? Normally you’d look from the start of the day until now, or 24 hours back.
If you want only the length of the last occurrence then I think you need an input helper or other sensor to store the time it went on for that. The last changed value can can only be used while the sensor is on. If you use that directly, the value will always be 0 if there is no moisture. (Unless that is what you want of course). But then you do not heed a history sensor, and you could just as easily use a template sensor.
If you replace the time with 0 you will get the sum for today. That will always be 0 at 0:00, even if the wet started before midnight though.
So it all depends: if it was wet but now is dry, do you want the length to stay or go to 0. And if you have multiple wet periods on a day, do you want them to sum op or do you only want the length of the last time, no matter if it started before today?
I would like the time to stay and average of multiple time it was wet during the day.
I just can’t figure out how to do that- just starting my beginner journey.
Thank you, it has been working.
How do you hold the previous value as when the sensor state changes it goes back to blank or perhaps take the average and then show that on the history graph?
I use the Utility Meter integration to create four sensors that track daily, weekly, monthly, and yearly statistics for a History Stats sensor. By looking at each of the four sensor’s history you can see its previous values.
Here’s how you would configure four Utility Meter sensors to track your wetstatus sensor’s daily, weekly, monthly, and yearly statistics.