Hey there, I’m looking to get the daily value_max of a weather sensor’s observation.
For example if it’s “Cloudy” 5 times, “Mostly Cloudy” 3 times and “Rain” 2 times in a day, I want to be able to have a sensor state “Cloudy” since that’s the most observed condition of the day.
Does this make sense? Unsure how to do that with the statistics sensor.
I ended up asking chatgpt about this one because I felt it was complex. It’s solution was to create a python script that uses the API at /api/history/period/<timestamp> and specify the time range to get the states. Then loop through each state and count them as unique values which gives you the most frequent state of the day. So far so good
I’m curious about the circumstance where it matters which description is “most observed” ? What if the description is “Cloudy” 25 times, with each instance is only 2 minutes long, and it is “Mostly Cloudy” 5 times, but for an hour each…? Is “Cloudy” truly the “most observed”?
My forecast data only updates once every 15 minutes, and historically the conditions itself change maybe hourly with those API calls.
I’m only curious about the conditions during the daylight hours and it’s going to an external mysql db alongside my solar panel readings for the day. Theoretically I can look back and be able to see if there’s a reason for low solar production - e.g. snow/cloudy/rain/etc. Certainly this isn’t scientific and is just for data logging purposes.
You’re right, using the data from the home assistant api, I could calculate the time delta between each state update (seen below) and select the one that has the largest delta across the values, but I’m not certain that’s needed - though an option for future.
This is a good idea too. Though I think there’s something like 40 observations, so having something like this be dynamic was originally what I was looking for