Hi, I need to calculate amount of sunny hours during the day for last week. History Stats works great to calculate amount of sunny hours but I see no way how to include condition that sunny hours should be during the day. What would be the best way to do it? I guess generic template sensor but I don’t understand how to code it (how to sum subset of data of another sensor). Any examples or references to docs would be great.
All of this is a guess as you have not provided any information on how you are determining it is sunny. But create a similar template binary sensor and feed that to the history stats integration.
template:
- binary_sensor:
- name: "Is Sunny"
state: "{{ is_state('weather.your_weather', 'sunny') and state_attr('sun.sun', 'elevation') > 0 }}"
1 Like