Close/open curtain (cover, blinds) based on sun and weather

Nice Blueprint, trank you!
What about the „regular“ open and close automations? Eg in the morning open and in the evening close.
What about open windows that prevent the cover from closing.

For the first I have a seperate automation wich controls the open/close logic and sets a binary helper for activating an deactivatig the automation for the sun protection.
Additionaly I have a second binary helper to control the sun protection in general. So there is just one switch to enable and disable.

@kreuzundkwer thanks for the feedback!

What about the „regular“ open and close automations? Eg in the morning open and in the evening close.

This should not interfere with this automation, as it is “stateless”, i.e. only closes, when all conditions are met and opens when the first condition is not met any more. Actions are idempotent, hence it should be no problem if the curtain already is set to the target position (through another automation or manually). Furthermore an additional configuration for a “night time” is currently in the making, this would block/defer all actions during a configured time, which should additionally help to assure no interference with another automation.

What about open windows that prevent the cover from closing.

This is not covered yet. Possible solutions that come to my mind:

  1. With a separate automation, you disable the automation from this blueprint depending on your sensor.
  2. We define an additional (optional) input for this blueprint, that selects a binary sensor and blocks/defers any action when it is “off” (on?) - analogous to the above described “night time”.

Any thoughts?

1 Like

Hi @daniel-sc !

Thanks for this great blueprint, I’ve been wanting to make something like this for some time now…

Unfortunately, I have an issue with my automation.
First to be sure there is an issue and not that I am doing something wrong please tell me what conditions have to be met for the cover/curtain open fully again after being closed to the target position?
I am asking this because I cannot get the automation to open the cover to 100% when sun goes down.

Thanks!

@dedabrane thanks for the feedback!

First, always when the cover is moved, it is either set to the target position (close) or to 100 (completely open).

For the open to happen, the automation needs to be triggered by one of its triggers (temperature change, sun change, …) and the current position (as reported by state_attr(curtain_entity_id, 'current_position')) must be smaller or equal the target position. Furthermore before the trigger all conditions for “close” (sun position, temperature, weather), had to be true - i.e. it only opens when the first condition switches to false.

Additionally (though probably obvious), there is one more relevant point: If the open would happen between the configured time for “Skip opening after this time” and midnight. :wink: (This is currently reworked, to defer the open in this case until after the night…).

From this one can conclude the following scenarios where an open is not happening:

  1. Manually running the automation
  2. Missing the first condition that violates the “close” state (e.g. ha is offline, …)
  3. The open would have happend between “Skip opening after this time” and midnight.

My scenario is: Another automation closed the curtain (eg 10pm). In the morning all conditions are met to set the curtian to the target position (eg 20%). In summer this could be at 7am, but I want the curtain not to open before 10am.

Otherwise, my target position is 0% (closed). All conditions are met, nothing happens. At 10am the other automation opens the curtain and I have no sun protection.

If you integrate a start and end time for the night, this would be a great solution.

Disableing and Enableing is possible but feels not so good. An optional binary input sounds good :wink: Also the possibility to configure night time with an external automation or configuration.

@daniel-sc thanks for the info.

So just to be sure I understand (sorry for being dumb), let’s say these are the settings in the automation:

Sun azimuth position start: 220
Sun azimuth position end: 300
Sun elevation to start: 60
Temperature threshold: 35
Closing position of curtain: 50
Skip opening after this time: 22:00:00
Weather conditions: sunny, partlycloudy

In the morning blinds position is at 100.
Sun reaches the start azimuth and elevation at about 14:00 and as it is summer the temperature on the selected sensor is well above 35.

Assuming all conditions are true the blinds should close to 50 at about 14:00 h.
So two questions now:
Do the blinds need to be closed by this automation, meaning does the automation need to be triggered in step 1 (close) for the open to work?
And second: given this situation above, what condition should change for the open action to be triggered?

Again, sorry for the dumb questions, I just want to be sure I tested the whole automation before saying something’s not working :slight_smile:

Thanks!

Hi @dedabrane to answer your two questions:

No, the open does work even if another automation closed the blinds or when they were manually closed.

The open action will be triggered by any condition that changes - e.g. sun elevation < 60 or temperature < 35 or weather cloudy etc. Note that only the first changed condition triggers the action, so if e.g. at 15:00 the weather changes to cloudy, the open action is triggered. If afterwards at 15:10 the temperature drops to 30, there is no further open action (independently if the curtain was manually or by some other automation closed in the meantime!).

Hi @daniel-sc

Thanks for the answers, It’s clear now how it should work.
Now, I tested the automation today and here’s the result:
When sun position went over the set start positions the blinds closed as they should.
Unfortunately, I miscalculated the sun elevation at the time that blinds should open and the set value was higher than it should have been. Just for an example, I set the elevation value to 50 but at the aprox. time that blinds should open sun will be at 10, so the elevation threshold of < 50 was met a lot earlier.
So at the time the elevation became < 50 the blinds opened.
I suppose this is ok and by design meant to be this way.
But then in an attempt to correct the settings, I changed the elevation setting to 10 and closed the blinds manually to a position below the setting.
As the sun position changed to over the azimuth end setting and below the elevation setting I hopped that blinds would open again. Instead, nothing happened and automation trace shows that condition check failed.
Is this ok behavior?
If not, how can I check which condition did not pass?
If I look at step details there is now way I can recognize what failed…

Thanks!

@dedabrane not sure if I can follow your post correctly… For general instructions on how to debug an automation, I’d recommend Troubleshooting automations - Home Assistant for a start.

One of the conditions “azimuth end” or “elevation” should have changed first, and with that trigger the open should have happend.

Hi @daniel-sc,
are you still working on a extension for your blueprint to manage an “earliest time” or an general “active-flag” to have more control about when the covers should move?
Otherwise I’m going to modify your blueprint for myselfe.
I will also add an extra entity to optionaly set the cover tilt position.

I thing, that the described scenario ist still not coverd by this blueprint:

@kreuzundkwer yes, still working on the „night“ feature. But as I’ve only little free time, it might take some more days/weeks… The general active flag might come later…

If you like, you can share your additions, and if they generally make sense, I’ll add them to this blueprint?

The cited scenario should be solved when the „night“ feature is there. Then you could configure the night to end at 10:01, so it closes the curtain right after the other automation opened it. Did I miss something here?

1 Like

Hi Daniel,
I have installed roller blind motors that can only be controlled by radio. unfortunately I can’t define a position with it. The only option I have is to let the shades go all the way up, let it pass a little time and then lower the shades again and stop after a few seconds. Do you think this is possible with your blueprint?

Hi all, i love this Blueprint, but i have some Error Messages in the Logfile:

→ Error in 'cover sun Büro ’ trigger: In ‘numeric_state’ condition: entity weather.openweathermap state ‘sunny’ cannot be processed as a number<–

Do you have an idea ?

@illiloh no - you’d need a device that supports set_position: Cover - Home Assistant

@GUIS2023 yes, this is a “known issue” (to me :wink: ) and is caused by the duality of the “Temperature source” which can either be a weather entity or a temperature device. In case it is a weather entity, the trigger t_temp_above_temp creates this error (as the state is not the temperature but e.g. ‘sunny’). This is expected, as in this case the trigger t_temp_above_weather is the relevant one.

If anyone has a better way of handling this, that prevents these error logs, I’d be happy about feedback :thinking:

Hi Daniel, are you sure that the t_temp is the problem ?
→ "[homeassistant.components.homeassistant.triggers.numeric_state] Error in ‘cover sun Büro’ trigger: In ‘numeric_state’ condition: entity weather.forecast_home state ‘partlycloudy’ cannot be processed as a number ←
I think the error ist the sensor.openweathermap_condition → partlycloudy , sunny , or i am wrong?
BR :grinning:

Great blueprint, thank you for this. My use-case was a bit different, as I don’t have a set_position. So I refactored your code for private use to make this work for the following situation.

I have an awning with a zigbee motorcontroller attached, which connects via a Philips Hue hub as a “light”. The lights brightness controls the motor, 80-100 is open, 0-20 is close 21-79 is stop. The motor automatically stops once it reaches the end of the rail so no need for adding timing complexity fortunately.

Heres what I did:

  • I commented out all the code in the yaml you added for position of the cover, as my setup does not support that.
  • I changed the entity list to lights, instead of covers.
  • I changed the services in the yaml to change the brightness of the ‘light’. For example for closing the awning/cover;
- service: light.turn_on
            data:
              brightness_pct: 95
            target:
              entity_id: "{{ curtain_entity_id }}"

Perhaps someone else might find this thread with a similar situation and can build on this for their own use-case.

Probably a stupid question but how do I change this to Fahrenheit??

hello
Thank’s for the blue print. I try it but it doesen’t close my cover
I instal only your blueprint. It’s ok or i shal instal another think form hacs? I m in HA 2023-9-3

My config for testing

alias: volet-Fermeture  cuisine en fonction du soleil
description: blueprint fermeture volet cuisine
use_blueprint:
  path: daniel-sc/cover_sun_blueprint.yaml
  input:
    cover_entity: cover.cuisine
    sun_position_start: 160
    sun_position_end: 250
    sun_elevation_start: 10
    close_position: 40
    weather: weather.villefranque
    temperature_entity: sensor.garage_temperature
    no_open_after: "20:00:00"
    outdoor_temp: 10
    close_weather_conditions:
      - sunny
      - partlycloudy
      - cloudy

At this time my position is


and the weather.villefranque (from meteo france) state is Cloudy
So i think the cover must be closed and not…

thank’s for your help

Hi Folks,

I have two questions.

1.Is it possible to add a brightness sensor? I have a homematic weather station which delivers the brightness 0-255 and would like to use a combination of temperature and the brightness sensor instead weather forecast.

  1. It would be great to have a timer for the temperature and brightness sensor where the blind closes if the value is above the defined duration. In this way to many open/close triggers couls be avoided.