Asking for help with sunscreen

Dear All,

I made an automation for my awning to lower it during sunny days. Despite my basic knowledge of YAML, I think it turned out well and I am satisfied with it.

Today I was at home and noticed that the screen was constantly shuttling open-close-open-close. I noticed that there were quite a few clouds. And indeed when there was a cloud it went up and when the cloud was gone it went down again.

Now I would like to extend my automation with the condition that if there are clouds then the screen will not go down.

I installed the BUIENRADAR integration and I saw that you can use PARTLY CLOUDY and CLOUDY for that.
Despite searching on Google I didn’t get any further than trial and error…I can’t figure out how you can do that.

Who wants to take me step-by-step to include this as a condition in my automation?

  - id: 'Screens_naar_beneden'
    alias: Screens naar beneden
    description: ''
    trigger:
      - platform: time_pattern
        minutes: '/5'                                                           
        seconds: 0
      - platform: numeric_state
        entity_id: sensor.buienradar_irradiance
        above: 350                                     
        for:
          minutes: 10                                                           
    condition:
      condition: and                                                           
      conditions:
        - condition: time
          after: '07:30:00'
          before: '14:00:00'                                                    
        - condition: numeric_state
          entity_id: sensor.buienradar_wind_force
          below: 6                                                              
        - condition: numeric_state
          entity_id: sensor.buienradar_precipitation
          below: 0.1
          #Sensor at the top of the screen -> Check if screen is open or closed                                                            
        - condition: state                                                      
          entity_id: binary_sensor.screen_sensor_up_down                         
          state: 'off'                                                          
        - condition: numeric_state
          entity_id: sensor.buienradar_irradiance
          above: 350                                    
    action:
      - service: scene.turn_on
        target:
          entity_id: scene.screens_naar_beneden
      - service: notify.henk
        data: 
          title: 'Screens gaan omlaag!'
          message: 'Dat zeg ik...'
          data:
            clickAction: "noAction"                                             
    mode: restart


  - id: 'Screens_naar_boven'
    alias: Screens naar boven
    description: ''
    trigger:
      - platform: time                                                          
        at: '14:15:00'
      - platform: numeric_state
        entity_id: sensor.buienradar_wind_force
        above: 6                                                                
      - platform: numeric_state
        entity_id: sensor.buienradar_precipitation                              
        above: 0.1                                                              
      - platform: numeric_state
        entity_id: sensor.buienradar_irradiance
        below: 300                                                              
        for:
          minutes: 30                                                          
    condition:
        #Sensor at the top of the screen -> Check if screen is open or closed 
      - condition: state
        entity_id: binary_sensor.screen_sensor_up_down
        state: 'on'
        for: "00:00:10"    
    action:
      - service: scene.turn_on
        target:
          entity_id: scene.Screens_naar_boven
      - service: notify.family
        data:
          title: 'Screens gaan omhoog!'
          message: 'Dat zeg ik...'
          data:
            clickAction: "noAction"                                             
      - wait_for_trigger: 
            #Sensor at the top of the screen -> Check if screen is open or closed                                                      
          - platform: state
            entity_id: binary_sensor.screen_sensor_up_down
            from: 'on'
            to: 'off'
        timeout:
          seconds: 60                                                           
        continue_on_timeout: true                                               
      - if:
            #Sensor at the top of the screen -> Check if screen is open or closed                                                                     
          - condition: state                                                    
            entity_id: binary_sensor.screen_sensor_up_down                      
            state: 'on'                                                        
        then:                                                                   
          - service: notify.henk                                               
            data:                                                               
              title: ⚠️ Probleem ⚠️
              message: >
                Er is een probleem met de screens!
                Het scherm is niet boven aangekomen.
                Komt de sensor wel binnen?
                Batterij leeg?
                Vastgelopen in de rails?
              data:
                clickAction: "noAction"                                             
    mode: restart

I see you are using numeric state triggers, which are very precise, even with a time added. You might try experimenting with threshold helpers, which allow you to specify a hysteresis - that is a “grey zone” on either side of the threshold value when nothing happens.

As said above, hysterisis will do the trick.

This is one option: Threshold - Home Assistant

Or make template triggers: one for e.g. above 360 and another for below 340, giving you a dead zone of 20.

Both: Thank you for replying to my message.
Threshold helpers is still a step too far for me. I’m just a beginner.
For the moment I am looking for a solution with PARTLY CLOUDY AND/OR CLOUDY.

But, is it possible to integrate the threshold helpers in my automation so I can experiment with this?
This is very new for me.

That’s not making things any easier! :grinning_face_with_smiling_eyes:

As an experiment, go to Settings | Devices & Services | Helpers and create a threshold helper with the input sensor sensor.buienradar_irradiance, upper limit 350 and Hysteresis 50 (no lower limit). This means that although the threshold is 350, the helper will not turn on or off between 300 and 400.

Then try your first automation with the single trigger:

platform: state
entity_id:
  - binary_sensor.<your_threshold_helper>
to: "on"

You may have to make the hysteresis bigger or smaller, depending on the difference the clouds make to the light.

In your second automation, replace the fourth trigger with:

platform: state
entity_id:
  - binary_sensor.<your_threshold_helper>
to: "off"
1 Like

I wil give this a try, but be patient. I’m not the youngest anymore. (retirement)
Give me a few day’s and I come back with an update.
For now I would like to thank you for helping me.

Tell me about it! :man_white_haired:

Today I implemented the threshold helper exactly as you described. This week I can test it nicely and adjust it if necessary.
Next week I will report my findings.

Update:

Threshold helper has been implemented and have been observing it for a while. Occasionally a little adjusted but I was not satisfied with it.
After some searching I have used a number of conditions for it
sunny / partly cloudy and cloudy.
After more than a week of testing, I found a solution that works great.

Outside the threshold helper:

       - platform: state
         entity_id: binary_sensor.threshold_screen_helper
         to: 'on'

implemented the following:

        - condition: template
          value_template: >-
            {{(states('sensor.buienradar_condition_code') == 'a' ) or
            (states('sensor.buienradar_condition_code') == 'b' ) or
            (states('sensor.buienradar_condition_code') == 'o' ) and
            ((states('sensor.buienradar_irradiance') | int) > 324)}}

Before monitoring, I send myself a message every time so that I know why the screens go down or up.

          message: > 
            {% set my_text_json = { "irradiance": "W/m²", "speed": "km/h", "unit": "°C", "total": "mm" } %}
            Tijd: {{now().timestamp()|timestamp_custom() }} <br> 
            Weer: {{ states('sensor.buienradar_condition') }} <br>
            Code: {{ states('sensor.buienradar_condition_code') }} <br>
            Windkracht: {{ states('sensor.buienradar_wind_force') }} <br>
            Windsnelheid: {{ states('sensor.buienradar_wind_speed') }} {{ my_text_json.speed }} <br>
            Windhoek: {{ states('sensor.buienradar_wind_direction') }} <br>
            Lichtsterkte: {{ states('sensor.buienradar_irradiance') }} {{ my_text_json.irradiance }} <br>
            Temperatuur: {{ states('sensor.buienradar_temperature') }} {{ my_text_json.unit }} <br>
            Regen Forecast: {{ states('sensor.buienradar_precipitation_forecast_total') }} {{ my_text_json.total }}

I also make sure that the screen does not go down again until the sensor status is not changed.

         - condition: template
           value_template: >
             '{{ as_timestamp(now()) - as_timestamp(states.binary_sensor.screen_sensor_up_down.last_changed) | int > 1800}}'

And of course I also had to adjust the automation “screen up”.
In the end I was able to learn a lot from this.
And that was my goal.

Thank you both for the support!