Problem with Multiple states for history stats

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?

It appears that adding two lines of state doesnt work. Any ideas of how I could do the trick?

I’m also trying to get multiple states in History Stats but don’t seem able to.

I’m thinking that it might need a template sensor creating or something.

just add a second history_stats platform and create a template sensor from them.

- platform: history_stats
  name: clear skys
  state: 'clear'
  ...... etc

- platform: history_stats
  name: few clouds
  state: 'few clouds'
  ..... etc

… or create a template sensor first to check one of your two states is active, and then add a history_stats platform over that template sensor. That might consume fewer resources.