Manage cover with sun position (elevation and azimuth)

Hi I’m getting an error trying to import this BP

No valid blueprint found in the topic. Blueprint syntax blocks need to be marked as YAML or no syntax.

In your expample sould be:
var:
cover_jadalnia_fix_mala:
friendly_name: “JADALNIA FIX MAŁA CIEŃ”
initial_value :0
icon: mdi:bug

But in this mode is not runing for me.

If they can explain var config…

I am getting the same error

I love the idea of this blueprint, I’m going to try this later today.
I partially lower and raise several of my Somfy shades during the course of any given day, to block the direct sun from getting in our eyes, but don’t close them all the way.

Would it be possible to update your blueprint to open or close to a certain percentage depending on the azimuth / altitude / weather (clear, cloudy, partially cloudy, etc)?

Thanks for your industry!

It would be more helpful if you could share the nodered JSON.

Hi! is it possible to get the sun value “above and below” ? During winter the sun is very low and shines bright in our windows. i live on the first floor. But during summer the sun is much higher and doesent disturd as much. As of right now i can only choose “above” which makes it hard.

And also one question, if the automation triggers and the cover closes, will it open again if the weather turns to “rainy” for exampel? Can you maybe clarify how the open and closing values work?

Thanks!!

1 Like

Hello @convicte could you share your code for node-red? thanx

@mougeat

I second the idea of “above and below” settings. I have the same issue with 2 west facing french doors. When the sun is between 23 degrees and 5 degrees its blinding. Being able to set a range on elevation just like azimuth would be perfect.

Thanks!

@mougeat

I really would love to correctly install & use this automation, because sun is around the corner and may heat up my house soon. For the shutters I use shelly, that also use the position service.

It’s not running. I have not adjusted anything, only followed the instruction above and used a test-shutter. Below some screens. Can somebday make out the issue here? The sun-entity is for sure installed.

I selected the maximum range for azimuth + elevation just for test reasons:

This is how I define the test-shutter in the YAML:
Definition variable in yaml_2

This is the name of the Shutter also used in the configuration.yaml and variable definition shown above:
Shutter_entitiy name_3

Many thanks !!!

Hi

Very nice idea :slight_smile: I mean, this work which you did because when I sit in front of my PC then sun is shining directly on monitor so manual cover closing is needed…

I totally agree with convicte about using possition instead of time.

Just and idea, but maybe hard to do it - I would imagine that best (but most difficult I guess) would be to controll possition of shutter in a way that depends on temperature, sun will shine only f.e. at window sill. Just this needs to be triggered then every f.e. 15 minutes?

Have also the same issue, that shutter is closed, but not re-opened again :frowning: was anybody able to solve this issue in the meantime ? @sascha005 @omolko

@sirfalo @convicte

My fork of the work from @mougeat using shutter position instead of time.

BW

2 Likes

Hi Convicte,
Can you please share the code for node red ? FDor me this is also much more intuitive.
thanks in advance

Peter

I’m further trying to fine-tune optimize the blueprint. I’m still in a testing phase, but the following enjoys priority:

  • baseline is for sure still Mougeat’s code
  • implemented a second threshold
  • solved at least on my side the issue, that covers were not opening again

blueprint:
  name: sun protection v2
  description: close cover when sun is shining and open when stops
  domain: automation
  source_url: https://gist.github.com/mougeat/bec9f93c723c8e7d1a9c64c2592fa471
  input:
    cover_entity:
      name: cover
      selector:
        entity:
          domain: cover
          
    sun_position_start:
      name: sun azimuth position start
      description: Sun azimuth. when sun is below this value, shutter could be triggered
      default: 89
      selector:
        number:
          min: 0
          max: 360
          unit_of_measurement: °
          
    sun_position_end:
      name: sun azimuth position end
      description: Sun azimuth. when sun is over this value, shutter could be triggered
      default: 200
      selector:
        number:
          min: 0
          max: 360
          unit_of_measurement: °
          
    sun_elevation_start:
      name: sun elevation to start
      description: Sun elevation. when sun is over this value, shutter could be triggered
      default: 32
      selector:
        number:
          min: -100
          max: 360
          unit_of_measurement: °
          
    weather:
      name: Weather service
      selector:
        entity:
          domain: weather
          
    outdoor_temp_1:
      name: Pos1 - Outdoor temperature (Low)
      description: Temperature above which the shutters will close
      default: 19
      selector:
        number:
          min: 0
          max: 30
          unit_of_measurement: °C
          
    close_position_1:
      name: Pos1 - Intermediate Closing position for lower temperature
      description: Position at which the shutter should close
      default: 35
      selector:
        number:
          min: 0
          max: 100

    outdoor_temp_2:
      name: Pos2 - Outdoor temperature (High)
      description: Second temperature threshold above which the shutters will close
      default: 25
      selector:
        number:
          min: 0
          max: 30
          unit_of_measurement: °C
          
    close_position_2:
      name: Pos2 - Maximum Closing Position for higher temperature
      description: Second position at which the shutter should close
      default: 18
      selector:
        number:
          min: 0
          max: 100
          
    open_position:
      name: Opening position
      description: Position at which the shutter should open
      default: 100
      selector:
        number:
          min: 0
          max: 100

variables:
    cover_e: !input cover_entity
    var_e: "{{ 'var.' + cover_e[6:] }}"
    protection_begin: !input sun_position_start
    protection_end: !input sun_position_end
    elevation_begin: !input sun_elevation_start
    outdoor_temp: !input outdoor_temp_1
    outdoor_temp_2: !input outdoor_temp_2
    close_position: !input close_position_1
    close_position_2: !input close_position_2
    open_position: !input open_position
    weather_service: !input weather

mode: parallel

trigger:
  - platform: time_pattern
    minutes: "/1"
  
condition:
  - condition: sun
    before: sunset
    after: sunrise
    
action:
  - choose:
      ##########################################################
      # close cover - second temperature threshold
      ##########################################################
      - conditions:
          - condition: template
            value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
          - condition: template
            value_template: "{{ states(var_e) != '1' }}"
          - condition: template
            value_template: "{{ state_attr('sun.sun', 'azimuth') > protection_begin and state_attr('sun.sun', 'azimuth') < protection_end and state_attr('sun.sun', 'elevation') > elevation_begin }}"
          - condition: or
            conditions:
              - condition: template
                value_template: "{{ states(weather_service) == 'partlycloudy' }}"
              - condition: template
                value_template: "{{ states(weather_service) == 'sunny' }}"
          - condition: template
            value_template: "{{ (state_attr(weather_service, 'temperature') > outdoor_temp and state_attr(weather_service, 'temperature') <= outdoor_temp_2) }}"
        sequence:
          - data_template:
              entity_id: "{{ cover_e }}"
              position: "{{ close_position_2 }}"
            service: cover.set_cover_position

      ##########################################################
      # close cover - first temperature threshold
      ##########################################################
      - conditions:
          - condition: template
            value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
          - condition: template
            value_template: "{{ states(var_e) != '1' }}"
          - condition: template
            value_template: "{{ state_attr('sun.sun', 'azimuth') > protection_begin and state_attr('sun.sun', 'azimuth') < protection_end and state_attr('sun.sun', 'elevation') > elevation_begin }}"
          - condition: or
            conditions:
              - condition: template
                value_template: "{{ states(weather_service) == 'partlycloudy' }}"
              - condition: template
                value_template: "{{ states(weather_service) == 'sunny' }}"
          - condition: template
            value_template: "{{ state_attr(weather_service, 'temperature') > outdoor_temp_2 }}"
        sequence:
          - data_template:
              entity_id: "{{ cover_e }}"
              position: "{{ close_position }}"
            service: cover.set_cover_position

      ##########################################################
      # open cover
      ##########################################################
      - conditions:
          - condition: template
            value_template: "{{- is_state('input_boolean.cover_manage_cover_with_sun', 'on') -}}"
          - condition: sun
            before: sunset
            after: sunrise
          - condition: template
            value_template: "{{ (state_attr('sun.sun', 'azimuth') < protection_begin or state_attr('sun.sun', 'azimuth') > protection_end or  state_attr('sun.sun', 'elevation') < elevation_begin) }}"
        sequence:
          - data_template:
              entity_id: "{{ cover_e }}"
              position: "{{ open_position }}"
            service: cover.set_cover_position
3 Likes

could you also add an optional setting for using outdoor light sensor and enabling setting only above a certain lux threshold? that way if it is too cloudy outside I wouldn’t be sitting in the dark

1 Like

Hi there!
Were you able to get past this?
I’m seeing the same issue!

Hello there (I know I am a day late for that one),

I had the solution from @Kosy running from here (Shutter automation with sun azimuth trigger and contact sensor - #3 by Kosy)
The great thing was that the shutters would not only close and open completely but would adjust the position accroding to the suns position. This way the rooms would not be completely dark (or only during noon).
And I somewhat loved it. Problem there was:
1.) No matter the weather the shutters would always move even during rain, this is also true for the temperature, even though it was winter with minus something degrees.
2.) There was no real way to interact with the automation, i could of course adjust the shutters manually, but i could not easily disable the automation for a given period of time.

As far as i understood the thread here, this solution takes into account the weather (temperature as well?) but shuts the shutters only completely? Is that right? How much work would it be to adjust it to have them opened adjusted to the suns position?
Thank you!

I had similar problem. In my case the name of the cover enitities were too long and consequently variables were not set correctly.

@mougeat configuration.yaml example here:

Manage cover with sun position (elevation and azimuth) - #31 by mougeat

If you trace the automation, on the open cover section make sure you have the entire variable name, if it’s cut, go on the device and just update it for something shorter. Also make sure it is stated on the configuration.yaml correctly.

Example of my configuration.yaml:

var:
  bedroom_curtain:
    friendly_name: "VAR COVER QUARTO"
    initial_value: 0
    icon: mdi:bed-empty
  blinders_lr_front:
    friendly_name: "VAR COVER SALA FRENTE"
    initial_value: 0
    icon: mdi:living-room

Hi guys,

I just don’t know where my error is.
For example I have a rollo that is called cover.rollo_badezimmer, so my variable looks like this:

cover_rollo_badezimmer:
friendly_name: “rollo Badezimmer”
initial_value: 0
icon: mdi:bathroom

this will end up with an entity called “var.cover_rollo_badezimmer”, that’s correct so far isn’t it?
and if I want an input_boolean for each room instead of the input_boolean.cover_manage_cover_with_sun, it should be enough if I change this accordingly in the input as well as under conditions or?

currently I have the problem that e.g. rollo_osten reacts accordingly, but same script and because rollo_badezimmer all the time remains down.

try rollo_badezimmer: instead cover_rollo_badezimmer: