I have created a sensor to know if there was enough sun to heat the water. In my country we use solar panels to have hot water. The time these panels collect the solar energy is at around 9am to 3pm.
Here is my sensor:
- platform: history_stats
name: suntimeforhotwater
entity_id: sensor.owm_condition
state: ‘clear’
type: time
start: ‘{{ now().replace(hour=9).replace(minute=0).replace(second=0) }}’
duration:
hours: 6
The sensor reads how much time the weather state was clear, and an automation announces it some time at night. That way I know there was enough sun today to have hot water.
The real question here is how to use multiple states. Ok, I dont intent to use 5 or 6 different states, but only two. But how to do it? The states I want the sensor to read are “clear” and “Few clouds”.
A way I found was to add a second line:
- platform: history_stats
name: suntimeforhotwater
entity_id: sensor.owm_condition
state: ‘clear’
state: 'few clouds’
type: time
start: ‘{{ now().replace(hour=9).replace(minute=0).replace(second=0) }}’
duration:
hours: 6
And it worked!! The hours the sky was “clear” and “few clouds” is added so that does the trick for me.
But I am getting errors for double states in my log. Is this going to be a problem? Is there another way to do the same thing?