How to automate my awning (sunscreen)

I tried playing with it. But if you set it, it does still allow you to use a button. So it doesn’t work. Also if i click the options i see 3 options. No protection, Local Protection and 3rth one “Not Supported” perhaps that just indicates that it is not supported?

You can however protect the node. The setting below it.

But… when manually switching the device it doesn’t report back anything anymore.

This is what i see btw:

Do you have a shutter v3 or something else?

p.s. also the blind settings doesn’t work, read that on the forums. Its some fibaro specific thing and it does not work in openzwave. Might be the same with this. I’ll just do a quick check and stop with a sound. That works also (not the nicest, but enough for now)

Too bad, but good for you for finding a solution of sorts

Just a big thank you to all the contributers here. All your work make a very very good template so saves me so much time and thinking… cheers!

And i thank the same from whom i got the information too. I always try to put the topic/post in my package/yaml files at the top as comment so when people read it on github they know where it came from. (and it is also easy for yourself to check if there are updates)

Since we’re all sharing; here’s an update of my most recent version of the ‘sunscreen’ automation :slight_smile:

Changes:

  1. Weather Underground is no longer available if you’re not operating your own weather station. I just installed my own weather station, it’s been especially helpful for wind so far.
  2. The forecast for ‘high temperature today’ is coming from DarkSky now (not Weather Underground).
  3. There are now 2 automations for automatically rolling it up: 1 for ‘urgent up’ (rain/wind/sunset) and 1 for ‘regular up’. The ‘urgent up’ automation is always active, while the ‘regular up’ is inactive if you choose to operate the awning manually (= from Google Home in my case). This has increased the WAF significantly.

Automations:

- alias: Awning automatically down
  trigger:
  - platform: time_pattern
    minutes: '/1'
    seconds: 1
  condition:
    condition: and
    conditions:
    - condition: numeric_state
      entity_id: sun.sun
      value_template: '{{ states.sun.sun.attributes.azimuth }}'
      above: 130
      below: 265
    - condition: state
      entity_id: sun.sun
      state: 'above_horizon'
    - condition: state
      entity_id: cover.zonnescherm_level
      state: open
      for:
        minutes: 30
    - condition: sun
      before: sunset
      before_offset: -00:45:00
    - condition: numeric_state
      entity_id: sensor.dark_sky_daytime_high_temperature_0d
      above: 18
    - condition: numeric_state
      entity_id: sensor.wind_kph_avg_mean
      below: 7
    - condition: numeric_state
      entity_id: sensor.br_precipitation_forecast_total
      below: 0.1
    - condition: template
      value_template: '{{ now().month > 2 }}'
    - condition: template
      value_template: '{{ now().month < 10 }}'
    - condition: numeric_state
      entity_id: sensor.irradiance_avg_mean
      above: 350
    - condition: state
      entity_id: input_boolean.vacation_mode
      state: 'off'
    - condition: state
      entity_id: input_boolean.sunscreen_manual_up
      state: 'off'
  action:
    - service: switch.turn_on
      entity_id: switch.sunscreenswitch
    - service: notify.by_telegram
      data:
        message: The awning has automatically rolled down.

- alias: Sunscreen up with urgency
  trigger:
  - platform: sun
    event: sunset
    offset: -00:45:00
  - platform: numeric_state
    entity_id: sensor.wind_kph_avg_mean
    above: 7
  - platform: numeric_state
    entity_id: sensor.br_precipitation_forecast_total
    above: 0.2
  condition:
    condition: state
    entity_id: cover.zonnescherm_level
    state: closed
    for:
      seconds: 30
  action:
  - service: switch.turn_off
    entity_id: switch.sunscreenswitch
  - service: input_boolean.turn_off
    entity_id: input_boolean.sunscreen_manual_down
  - service: notify.by_telegram
    data:
      message: The awning was rolled up because of wind, predicted rain or nearing sunset. 

- alias: Awning automatically up low sunlight
  trigger:
    - platform: numeric_state
      entity_id: sensor.irradiance_avg_mean
      below: 290   # low sunlight
    - platform: numeric_state
      entity_id: sun.sun
      value_template: '{{ states.sun.sun.attributes.azimuth }}'
      above: 270   # the sun is no longer hitting the window
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: cover.zonnescherm_level
      state: closed
      for:
        seconds: 30  # the time it takes for the awning to fully open or close
    - condition: state
      entity_id: input_boolean.sunscreen_manual_down
      state: 'off'    # the awning was not manually opened
    - condition: sun
      after: sunset
      after_offset: "-4:00:00"  # sunset is within 4 hours
  action:
  - service: switch.turn_off
    entity_id: switch.sunscreenswitch
  - service: notify.by_telegram
    data:
      message: The awning was rolled up because of low sunlight (< 290 W/m2 or azimuth > 270) and sunset is within 4 hours.
4 Likes

I see you also changed the precipitation to 0.2, did the same since it was giving some false ones (or just so tiny it didn’t matter)

For note nr 3, you say for use with google home. Do you mean that if she says “sunscreen down” it will not allow automatic going open, or manual interaction? Uncertain what you mean now :wink:

Also added a door sensor with it, if the screen is open and the door is half way open it would crush against the door. So the door needs to be closed, if not it will send a message.

I also wanted to share my code…
I use 5 Somfy stateless sunscreens and 1 Somfy stateless awning.
Because all my covers are stateless, I made for every cover a template_cover like this:

  - platform: template
    covers:
      keuken_1_temp:
        friendly_name: "Keuken 1"
        value_template: "{{ is_state('input_boolean.keuken_1_closed', 'off')}}"
        open_cover:
          service: script.turn_on
          data:
            entity_id: script.keuken_1_openen
        close_cover:
          service: script.turn_on
          data:
            entity_id: script.keuken_1_sluiten
        stop_cover:
          service: cover.stop_cover
          data:
            entity_id: cover.keuken_1

and this are those 2 scripts:

  keuken_1_sluiten:
    sequence:
      - service: cover.close_cover
        entity_id: cover.keuken_1
      - delay:
          seconds: 20
      - service: input_boolean.turn_on
        entity_id: input_boolean.keuken_1_closed
      
  keuken_1_openen:
    sequence:
      - service: cover.open_cover
        entity_id: cover.keuken_1
      - delay:
          seconds: 20
      - service: input_boolean.turn_off
        entity_id: input_boolean.keuken_1_closed

and this the used input_boolean:

  keuken_1_closed:
    name: Keuken 1 gesloten
    icon: mdi:arrow-down-bold-box-outline

Since my covers are on different sides of the house I made scripts for the ‘achtergevel’, ‘zijgevel’ and the ‘zonnetent’. They don’t have to be closed at the same time.
I calculated the azimut on this site http://shadowcalculator.eu/#/lat/50.08/lng/19.899999999999977
This is the automation to close the backside ‘achtergevel’:

  alias: Achtergevel sluiten #Sunscreen down/uitklappen
  initial_state: 'on' #on reboot HA or reloading of automations, automation is ON
  trigger:
    - platform: time_pattern
      minutes: '/5'
      seconds: 00
  condition:
    condition: and # all conditions need to be TRUE before action is executed.
    conditions:

      # Sun based conditions
      - condition: numeric_state
        entity_id: sensor.sun_azimut
        above: 80  
        below: 200
      - condition: numeric_state
        entity_id: sun.sun
        value_template: '{{ state.attributes.elevation }}'
        above: 15  
      - condition: or
        conditions:
          - condition: numeric_state
            entity_id: sensor.huidige_opbrengst
            above: 1200
          - condition: numeric_state
            entity_id: sensor.opbrengst_solaredge_kostal
            above: 1200

      # Weather based conditions
      - condition: numeric_state
        entity_id: sensor.windsnelheid
        below: 40 # Wind strenght - I still have to tune this value
      - condition: numeric_state
        entity_id: sensor.ba_precipitation_forecast_average
        below: 0.25 # Rain the next 15 min
      - condition: numeric_state
        entity_id: sensor.dark_sky_uv_index_0d
        above: 3 # This indicates direct sunlight on my location (as in: not cloudy)

      # Temperature based conditions
      - condition: numeric_state
        entity_id: sensor.buitentemperatuur_gefilterd
        above: 20 # only if outdoor temperature is above x then allowed to roll out
      - condition: numeric_state
        entity_id: sensor.gemiddelde_temp_beneden
        above: 22 # only if indoor temperature is above x then allowed to roll out
      - condition: numeric_state
        entity_id:  sensor.dark_sky_daytime_high_temperature_0d
        above: 23

      # Time based conditions
      - condition: template
        value_template: '{{ now().month > 3 }}' # Starting April
      - condition: template
        value_template: '{{ now().month < 10 }}' # Ending October
      - condition: template
        value_template: >
          {{  is_state('input_boolean.keuken_1_closed', 'off') or
              is_state('input_boolean.keuken_2_closed', 'off') or
              is_state('input_boolean.slaapkamer_closed', 'off')  }}

      # No others screens are closing
      - condition: state
        entity_id: script.zijgevel_sluiten
        state: "off"
      - condition: state
        entity_id: script.zonnetent_my
        state: "off"

  action:
    - service: script.achtergevel_sluiten
    - service: notify.mobile_app_gphone
      data:
       message: "Het zonnescherm achtergevel gesloten"
    - delay:
        minutes: 5
    - service: script.achtergevel_sluiten

and this the script:

  achtergevel_sluiten:
    sequence:
      - service: cover.close_cover
        entity_id: cover.keuken_1_temp
      - delay:
          seconds: 10
      - service: cover.close_cover
        entity_id: cover.keuken_2_temp
      - delay:
          seconds: 10
      - service: cover.close_cover
        entity_id: cover.slaapkamer_temp
      - delay:
          seconds: 10
      - service: input_boolean.turn_on
        entity_id: input_boolean.achtergevel_closed

The automation to open my ‘achtergevel’:

  alias: Achtergevel openen #Sunscreen up/inklappen
  initial_state: 'on' #on reboot HA or reloading of automations, automation is ON
  trigger:

    # Sun based triggers
  - platform: numeric_state
    entity_id: sensor.sun_azimut
    above: 250
  - platform: state
    entity_id: sensor.dark_outside
    to: 'on'
  - platform: numeric_state
    entity_id: sensor.zonne_energie_gefilterd_lowpass
    below: 350
    
    # Weather based triggers
  - platform: numeric_state
    entity_id: sensor.windsnelheid
    above: 40 #If wind force becomes to high, sunscreen needs to go up
  - platform: numeric_state
    entity_id: sensor.ba_precipitation_forecast_average
    above: 0.30  # Rain the next 15 min

  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.achtergevel_closed
        state: 'on'

  action:
    - service: script.achtergevel_openen 
    - service: notify.mobile_app_gphone
      data_template:
       message: "Het zonnescherm achtergevel geopend, reden {{trigger.entity_id}} "
    - delay:
        minutes: 5
    - service: script.achtergevel_openen 

and the script:

  achtergevel_openen:
    sequence:
      - service: cover.open_cover
        entity_id: cover.keuken_1_temp
      - delay:
          seconds: 10
      - service: cover.open_cover
        entity_id: cover.keuken_2_temp
      - delay:
          seconds: 10
      - service: cover.open_cover
        entity_id: cover.slaapkamer_temp
      - delay:
          seconds: 10
      - service: input_boolean.turn_off
        entity_id: input_boolean.achtergevel_closed
      - delay:
          minutes: 1
      - condition: or
        conditions:
          - condition: state
            entity_id: 'input_boolean.keuken_1_closed'
            state: 'on'
          - condition: state
            entity_id: 'input_boolean.keuken_2_closed'
            state: 'on'
          - condition: state
            entity_id: 'input_boolean.slaapkamer_closed'
            state: 'on'
      - service: cover.open_cover
        entity_id: cover.keuken_1_temp
      - delay:
          seconds: 10
      - service: cover.open_cover
        entity_id: cover.keuken_2_temp
      - delay:
          seconds: 10
      - service: cover.open_cover
        entity_id: cover.slaapkamer_temp
      - delay: '00:01:10'
      - condition: or
        conditions:
          - condition: state
            entity_id: 'input_boolean.keuken_1_closed'
            state: 'on'
          - condition: state
            entity_id: 'input_boolean.keuken_2_closed'
            state: 'on'
          - condition: state
            entity_id: 'input_boolean.slaapkamer_closed'
            state: 'on'
      - service: cover.open_cover
        entity_id: cover.keuken_1_temp
      - delay:
          seconds: 10
      - service: cover.open_cover
        entity_id: cover.keuken_2_temp
      - delay:
          seconds: 10
      - service: cover.open_cover
        entity_id: cover.slaapkamer_temp
      - delay: '00:01:10'
      - condition: or
        conditions:
          - condition: state
            entity_id: 'input_boolean.keuken_1_closed'
            state: 'on'
          - condition: state
            entity_id: 'input_boolean.keuken_2_closed'
            state: 'on'
          - condition: state
            entity_id: 'input_boolean.slaapkamer_closed'
            state: 'on'
      - service: notify.mobile_app_gphone
        data_template:
          message: "Der is iets mis me die Somfy's van den achtergevel. Fix het maar!! "

If you have questions, shoot…

5 Likes

Roelof, Is your automation giving you the behavior you want?
Is Dark sky accurate enough?

I am also trying to perfectly automate my screens.
The difference is that i want to roll them down based on lux values from different sensors around the house. I tried it in home assistant but that does not give me the result i want.
I can’t get the timer to work correct. I want to have a steady reading for x minutes above a certain value. If it drops below that value the timer should start over. this wil make sure the screens only go down if it has been sunny for a while.
With NodeRed i managed to get this to work correct, but i don’t know how to implement all the other conditions that have to be met. And how to manage the screen up automation.

@ Giel,
That is an impressive set if lines you made.
The question to you also, does this give you the desired behavior? no intervention needed?

I went with the lux sensors so i get actual local readings.
I am also thinking of using a rain sensor for the screens to go up instantly on rain.
But of course i don’t want the screens to go up and down the whole time.

The only intervention I ever did was, when one of my covers didn’t receive the “open” command due an error at the somfy servers…

I want to have a steady reading for x minutes above a certain value. If it drops below that value the timer should start over. this wil make sure the screens only go down if it has been sunny for a whilexyg

I use statistics sensors for that purpose. To calculate the average over e.g. 3 measurements. Primarily to eliminate spikes.

Right now I only have my phone, will answer your question later.

Hi all,

I’m struggling with my template value. I have also a automation for my covers. I want a overview in a display to see or all my conditions are true or false. The most of them I have already, but I can’t get the right one of these

- condition: sun

after: sunrise

after_offset: ‘07:30:00’

How can I make a sensor with output true or false.

{% if is_state(‘sun.sun’, ‘above_horizon’) + (for example 7,5 hours) %} True

That is actually not as simply as you would hope :sunny:

Home Assistant only contains the time of the Next Sunrise. So once the sun has risen, you can only get the time of tomorrow’s sunrise. I think this template will get you an approximation of what you want:

{{ as_timestamp(now()) | timestamp_custom('%H:%M:%S', true) > ( as_timestamp(state_attr('sun.sun','next_rising')) + (7*3600)+1800 ) | timestamp_custom('%H:%M:%S', true) }}

Basically it says: if the time is after sunrise + 7,5 hours, then it’s true. But it looks at the time of tomorrow’s sunrise, not today’s. So there might be a slight difference (usually just a matter of minutes, depending on where you are in the world. If you want the exact number, I would advice you to install the sun2 custom component. It does contains today’s time of sunrise.

Sorry Arnold, forgot to answer you. My automation is indeed giving me the desired behaviour. I could make it more perfect, but because I can also control the awning manually there’s never really an issue. Dark Sky is accurate enough. But now I have my own weather station, so that temperature is also going in the mix soon. I don’t really know of another weather source for HA that containts today’s predicted temperature.

Did you get your timer to work correctly or do you need some help with that?

Roelof, I am on holiday right now but i did not manage to get the working correct.
But I haven’t tried your solution yet because i thought i had it working in node red. But I was wrong. I still like to use my own realtime lux values, but the hue sensors update only every few minutes.

When i am back i’ll try some more.

Roelof,

I will try it and let you know. thx for replying :slight_smile:

This could be a suggestion too. @Railittle

Roelof,

Thx for your extra suggestion. I will keep this in my mind. At this moment I want to have it all automatic and not with manual input.
I have made these sensor. And it works perfect. Based on your code.

 - platform: template
    sensors:
      wk_sun_above_horizon_time: 
        value_template: >-
          {% if (now().timestamp())|timestamp_custom('%H:%M') >= ( as_timestamp(state_attr('sensor.sunrise','today')) + (1.0*3600) )|timestamp_custom('%H:%M') %} True
          {% else %} False
          {% endif %}

1 Like

I did not integrate the dark sky sensors yet but did set up the statistics sensors and that works a lot better. Thanks for the suggestion.

Soon i will implement the dark sky sensors and use at least the wind sensor.
I am trying to build my own rain sensor so that after a few drops the screens will go up.

Nice, DIY :slightly_smiling_face: Still, in my experience Buienradar predicted rain is better. When my personal weather station picks it up the awning is quite wet already.

1 Like