Determine Sunny/Cloudy State from Solar Power Sensor

Introduction:
I am trying to prevent the bedrooms from heating up, by lowering the roller shutters under certain conditions.
Currently I use

  • a bedroom temperature sensor sensor.bedroom_temperature to determine, if it is getting to warm in the bedrooms and
  • the sun’s position sun.sun to determine, if the sun is potentially shining at the side of the house where the bedroom windows sit.

As the radiators in the bedrooms are ususally turned off, the temperature threshold is not reached during winter, and the roller shutters remain open all day (as intended). Now in spring time, the temperature is usually below the threshold in the morning. In the afternoon, when the sun comes around, the bedrooms start to heat up and on sunny days, it may be, that the temperature crosses the threshold and the roller shutters lower down (as intended). If it is mostly cloudy, the bedrooms do not heat up enough to trigger the automation and the roller shutters remain open (as intended).

As the bedrooms are on the upper flow underneath the roof of the house, I am afraid, that throughout the hotter months of the year, the temperature may be constantly above the threshold. On a sunny day of course I would still like the roller shutters to lower down, to prevent the rooms from heating up even further, but if it is a very cloudy day, even though it may be hot/warm outside, I don’t think it is necessary to lower the roller shutters.

Current Automation
- alias: Shutters - Close Shutters Partly to keep Heat out
  id: 'shutters_close_shutters_partly_to_keep_heat_out'
  trigger:
  - platform: numeric_state
    entity_id: sensor.bedroom_temperature
    above: 20
  - platform: numeric_state
    entity_id: sun.sun
    value_template: "{{ state_attr('sun.sun', 'azimuth') }}"
    above: 200  # sun shines at the west side of the house
  mode: single
  
  condition:
  - condition: numeric_state
    entity_id: sensor.bedroom_temperature
    above: 20
  - condition: template
    value_template: >
      {{ states.sun.sun.attributes.elevation > 6 and
         states.sun.sun.attributes.azimuth > 200 }}
  - condition: state
    entity_id: input_boolean.disable_shutters
    state: 'off'

  action:
  - choose:
    - conditions:
      - condition: template
        value_template: >-
          {{ (state_attr('cover.bedroom', 'current_position') | float) > 40 }}
      sequence:
      - service: cover.set_cover_position
        data:
          entity_id: cover.bedroom
          position: 40
    default: []
  - choose:
    - conditions:
      - condition: template
        value_template: >-
          {{ (state_attr('cover.kids_room', 'current_position') | float) > 40 }}
      sequence:
      - service: cover.set_cover_position
        data:
          entity_id: cover.kids_room
          position: 40
    default: []

Question:
For the reason above I am trying to figure out, if it is rather sunny, or cloudy outside. I do not have a lux sensor on the side of the house, but I do have a photovoltaic system on the roof. Using a modbus integration I am getting the Watts it generates sensor.e3dc_solar_power currently with a default scan_interval of 30 seconds. The photovoltaic system ofcourse generates more power, if there are no clouds, but the power generated depends on the position of the sun. So a hardcoded threshold will not be sufficient to determine, if it is sunny, or cloudy outside.

Example of a sunny day

Example of a cloudy day

Is there a way to use the sun’s position sun.sun together with the solar power sensor.e3dc_solar_power to determine if it is sunny and feed this into the automation?
Maybe even including a statistics sensor, to smooth out some spikes.

Another idea to solve the problem is to check if the bedroom temperature is currently rising. The bedroom temperature is a DHT22 connected to an ESP32. Is there a way to output the temperature rate (temperature change over time) maybe directly in ESP Home?
I could then only lower the shutters, if the indoor temperature is rising. :thinking:

Edit: I found this thread, indicating a potential solution for my thought using a Statistic Sensor. I’ll give it a try. The Cloudsensor derived from the solar power however does sound like a charming sensor, if it can be realised

@Guesswho620 Sorry to drag you in to this thread, but I saw in Sun Declination discussion, that you are basically using your PV as a similar manner and did not like to hijack the other thread for it.
Are you using a fixed threshold to check for sunny/cloudy days? How is that working out for you? I figure especially in the morning, or evening, the performance of the PV will drop, although it might still be sunny, depending on the orientation of the solar panels.

@Steve61, maybe this may also be of your interest, as we are mainly trying to achieve the same thing.

1 Like

yep, for the moment I’m using static values based on experience, I’m still exploring what will be the best.

I have different automations for different blinds, so I use different absolute values. On the east side, where sun is rising from, I’m using smaller amount, I know that if I reach above 1000W, sun will be pretty harsh. The automation is based on Finity’s code, so the blind effectively moving with the azimuth, PV is jus a pure condition whether it should run or not, the rest (what should be the blind’s position) is taken care by azimuth sensor.

On south side I’m using 5000W, and on the west side I’m using 4000W.

What I did not accomplish yet is to revert the position of the blind to full open if PV is below treshold. Now it’s simply killing the automation from further running meaning the blind will rest in its last position it was set to by the automation, but so far it’s still waaaaaaaay better than calling wife: “Hey, can’t you see the sun is crazy shiny and it’s heating up the house?? Go up, and press the cover’s down button now, please!!” :smiley: :smiley: :smiley:

I’m still amazed every freakin’ day how stunning home assistant is, and what absolutely great community it has, I never felt alone with my technical/automation problems :smiley:

Thanks.

I have the benefit of having an Enphase solar system, so I can monitor individual panels - and I have them on the east, north and west (southern hemisphere). Well actually my house has a magnetic north-south alignment and true north is at about 356-degrees, which is why I get variation in sun-entry time.

For the blinds, I should be able to mix sun.sun, with a western panel to determine whether I need to close blinds on the western side (about 276-degrees).

I also plan to use a northern panel to help determine whether I need to give the solar hot water a boost.

What i did is this: made a multilinear regression using stats.blue website or any other tool you find. rated the sun clody to sunny from 0 to 1 and noted sun angle and lux level (or power level). You could use azimuth as well and make 2 regressions, fist part of the day and second.

Data collection example
rating lux angle
1 50000 45
0.9 50000 60

Copy the formula from the result of the regression and make a sensor /weather entity out of it. The resulted value will be between 0 and 1. I’ve set >0.85 as sunny, <0.25 dark day and everything in between just like i considered when i collected data. You could do that for each month, sky is the limit (pun unintended).