Automatic blinds / sunscreen control based on sun platform

Thatā€™s HA dependent. Eg. the Rademacher (german manufacturer) integration is reporting exactly the opposite, and the data needs to be reverted, before it getā€™s send to HA (very laymans terms). :slight_smile:

In HA itself 0 = closed and 100 = open. :wink:

EDIT: Donā€™t worry, I couldnā€™t have answered your post without prior checking on one of my blinds! :rofl: :rofl: This is something I just canā€™t remember after five minutesā€¦ :rofl: :rofl:

Impressive blueprint !
Do you think it could be easely transform for manage tilt of exterior venetian blind ?
Venetian blind is always 100% close but the tilt change for maximise the light without any sun to come inside during the dayā€¦ I guess d=0 and tilt remplace the h ?

Thanks for your help !

Hi. I think you are trying to follow the sun with the tilts? This is not really meant for that, but it is a very similar problem.

Yes itā€™s similar but i donā€™t find any blueprintā€¦
I made it works like that :

  • For simplification the tilts are only 2 positions (horizontal 0Ā° & 45Ā°) depending of the sun elevation.
  • Sun azimut trigger the automatisation when sun hit the window.
  • Interior temperature allow or not the sun to come inside (for winter)

Thank you for template, it was a great source of inspiration !

1 Like

Nice. You could also use a template to follow the sun, so the sun is always hitting the slats at 90 degrees to maximize the amount of light. But itā€™s not really necessary.

For everyone interested!

In the meantime I have build a small custom-integration based on the calculations with adding some more useful features. :smiley:

For now it supports:

  • Dedicated sensors that show the position in percentages
  • Vertical Covers
  • Horizontal Covers
  • Tilted Blinds
  • Inverse States (for the cover integrations that do not follow the guidelines)
  • Small and Easy integration specific Blueprint (auto-added)
  • Climate savings mode
9 Likes

Iā€™ve installed the Blueprint but I can never get the shades to close. The conditions are never met.
Azimuth: 163
Distance 4m
Height: 2.1
Min: 0
Default: 60%
Min Cover: 0%
FOV
90
90
90
90
Min Elev: 0
Min change: 1%
Timeout: 1 min

1 Like

Hereā€™s the trace of the shade that never closes. What do I have set incorrectly?

{
  "trace": {
    "last_step": "action/0/choose/0/sequence/0/conditions/0",
    "run_id": "4a6f9843e85507935f31da1e4c3ad8a8",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2023-10-20T14:26:43.175734+00:00",
      "finish": "2023-10-20T14:26:43.201279+00:00"
    },
    "domain": "automation",
    "item_id": "1695845347770",
    "trigger": "state of sun.sun",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2023-10-20T14:26:43.176651+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.office_shade_front_open_with_blueprint",
              "state": "on",
              "attributes": {
                "id": "1695845347770",
                "last_triggered": "2023-10-20T14:22:43.175463+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Office Front Shade Close with Blueprint"
              },
              "last_changed": "2023-10-14T18:53:05.499259+00:00",
              "last_updated": "2023-10-20T14:22:43.187127+00:00",
              "context": {
                "id": "01HD6QF3Z6TE3ZV9SCSD84BHH4",
                "parent_id": "01HD6QF3Z2PJPGAG35Z4VNC9CJ",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "sun.sun",
              "from_state": {
                "entity_id": "sun.sun",
                "state": "above_horizon",
                "attributes": {
                  "next_dawn": "2023-10-21T11:55:10.694198+00:00",
                  "next_dusk": "2023-10-20T23:55:32.168170+00:00",
                  "next_midnight": "2023-10-21T05:55:01+00:00",
                  "next_noon": "2023-10-20T17:55:19+00:00",
                  "next_rising": "2023-10-21T12:21:17.461132+00:00",
                  "next_setting": "2023-10-20T23:29:29.144072+00:00",
                  "elevation": 22.51,
                  "azimuth": 121.63,
                  "rising": true,
                  "friendly_name": "Sun"
                },
                "last_changed": "2023-10-20T12:20:26.007880+00:00",
                "last_updated": "2023-10-20T14:22:43.170773+00:00",
                "context": {
                  "id": "01HD6QF3Z2PJPGAG35Z4VNC9CJ",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sun.sun",
                "state": "above_horizon",
                "attributes": {
                  "next_dawn": "2023-10-21T11:55:10.694198+00:00",
                  "next_dusk": "2023-10-20T23:55:32.168170+00:00",
                  "next_midnight": "2023-10-21T05:55:01+00:00",
                  "next_noon": "2023-10-20T17:55:19+00:00",
                  "next_rising": "2023-10-21T12:21:17.461132+00:00",
                  "next_setting": "2023-10-20T23:29:29.144072+00:00",
                  "elevation": 23.2,
                  "azimuth": 122.38,
                  "rising": true,
                  "friendly_name": "Sun"
                },
                "last_changed": "2023-10-20T12:20:26.007880+00:00",
                "last_updated": "2023-10-20T14:26:43.171620+00:00",
                "context": {
                  "id": "01HD6QPEB3RX70A982263YFW2D",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of sun.sun"
            },
            "cover_entity": {
              "device_id": "27fabd93ed4193cb1387377fbccd1714"
            },
            "azimuth": 163,
            "distance": 4,
            "max_height": 2.1,
            "min_height": 0,
            "default_height": 60,
            "min_position": 0,
            "degrees": 90,
            "default_template": "",
            "azimuth_left": 90,
            "azimuth_right": 90,
            "max_elevation": 90,
            "min_elevation": 0,
            "cover_height": 100,
            "change_threshold": 1,
            "time_out": 1,
            "condition_mode": "and",
            "dict_var": {
              "condition_1": [],
              "condition_2": [],
              "names_1": [],
              "names_2": []
            },
            "condition_1": false,
            "condition_2": false,
            "entities_1": [],
            "entities_2": []
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-10-20T14:26:43.192693+00:00",
          "changed_variables": {
            "context": {
              "id": "01HD6QPEB7CEMK7RP1Y8X1MT7M",
              "parent_id": "01HD6QPEB3RX70A982263YFW2D",
              "user_id": null
            }
          },
          "result": {
            "choice": 0
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2023-10-20T14:26:43.192764+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2023-10-20T14:26:43.192786+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "action/0/choose/0/sequence/0": [
        {
          "path": "action/0/choose/0/sequence/0",
          "timestamp": "2023-10-20T14:26:43.195805+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/sequence/0/conditions/0": [
        {
          "path": "action/0/choose/0/sequence/0/conditions/0",
          "timestamp": "2023-10-20T14:26:43.195903+00:00",
          "result": {
            "result": false,
            "entities": []
          }
        }
      ]
    },
    "config": {
      "variables": {
        "cover_entity": {
          "device_id": "27fabd93ed4193cb1387377fbccd1714"
        },
        "azimuth": 163,
        "distance": 4,
        "max_height": 2.1,
        "min_height": 0,
        "default_height": 60,
        "min_position": 0,
        "degrees": 90,
        "default_template": "",
        "azimuth_left": 90,
        "azimuth_right": 90,
        "max_elevation": 90,
        "min_elevation": 0,
        "cover_height": "{%- set deg2rad = pi/180 -%} {

I do notice you do have a quiet large (work-area) distance set. The larger the distance, the closer the sunā€™s elevation must be to the horizon to close the cover.
Did you try to lower the distance?

EDIT:
I think to see youā€™re using the device_id to setup the entity. But you should rather select the entity_id for the entity selection.

Both of your suggestions were spot on for this Noob (I should have caught those) but changing from Device to Entity causes an error. The messages above mentioned this type of error but the new version of the BP should have fixed it. Iā€™m on version 1.1.2.

{
  "trace": {
    "last_step": null,
    "run_id": "38a6e57b0b6f03298cc2734507cf308f",
    "state": "stopped",
    "script_execution": null,
    "timestamp": {
      "start": "2023-10-23T19:04:57.712273+00:00",
      "finish": "2023-10-23T19:04:57.713287+00:00"
    },
    "domain": "automation",
    "item_id": "1697055708549",
    "error": "ValueError: Template error: int got invalid input 'None' when rendering template '{%- set ns = namespace(list_1=[],name_1=[],list_2=[],name_2=[]) %} {%- set  entity = cover_entity['entity_id'] -%} {%- if entity is iterable and (entity is not string and entity is not mapping) -%}\n  {%- set cover = entity -%}\n{%- else -%}\n  {%- set cover = [entity] -%}\n{%- endif -%} {%- for c in cover %}\n  {%- set position = state_attr(c,'current_position') | int -%}\n  {%- set con_1 = ((position - cover_height | float) | abs >= change_threshold)\n  or (cover_height in [default_height, default_template] and position not in [default_height, default_template])%}\n  {%- set ns.list_1 = ns.list_1 + [con_1]  -%}\n  {%- set con_2 = now() - timedelta(minutes=time_out) >= states[c].last_updated %}\n  {%- set ns.list_2 = ns.list_2 + [con_2] %}\n  {%- if con_1 == true -%}\n    {%- set ns.name_1 = ns.name_1 + [c] -%}\n  {% endif %}\n  {%if con_2 == true%}\n    {%- set ns.name_2 = ns.name_2 + [c] -%}\n  {% endif %}\n{%endfor%} {%- set dict = {\n  'condition_1':ns.list_1,\n  'condition_2':ns.list_2,\n  'names_1':ns.name_1,\n  'names_2':ns.name_2\n  } %}\n{{dict}}' but no default was specified",
    "trigger": null,
    "trace": {},
    "config": {
      "variables": {
        "cover_entity": {
          "entity_id": "cover.officeshade1"
        },
        "azimuth": 180,
        "distance": 0.1,
        "max_height": 0.4,
        "min_height": 0.2,
        "default_height": 60,
        "min_position": 8,
        "degrees": 90,
        "default_template": "",
        "azimuth_left": 90,
        "azimuth_right": 90,
        "max_elevation": 90,
        "min_elevation": 0,
        "cover_height": "{%- set deg2rad = pi/180 -%} {

@basbrus - any idea on the error when I switch from Device_ID (no error) to Entity_ID (error) ?

Thanks for this great Automation and Blueprint, first!

Is it possible to edit the Blueprint .yaml to open the blinds whenever there is direct sunlight onto the window?
I made a copy of the blueprint already which I can edit accordingly, but I am not shure where and how.

Background:
I live in a poorly insulated building and I use this blueprint during summer to avoid my living room getting too hot whenever there is direct sunlight. During workdays, I am not home anyway at these times of day.
In Winter, I lower the heating to a certain degree whenever I am away from home, and the blinds close automatically to give some additional insulation.
However, on sunny winter days, I would want to let the sun in instead of keeping it out, thus heating the living room a bit.
Conditions on what is a ā€œsummerā€ or ā€œwinterā€ day are set, but how to change the blueprint to work in the reverse way?

Thanks

I donā€™t think the blueprint can be used in that way. But I shared a template in this thread which may help you: https://community.home-assistant.io/t/automatic-blinds-sunscreen-control-based-on-sun-platform/573818/175?u=langestefan

This will return true whenever there is direct sunlight hitting your window. You can use that in an automation to control the blind

Oh, thanks for pointing me towards your old post, easy to overread for meā€¦
I think I can go from there.

I use the UV index to decide whether to lower the blinds or not. It works pretty well in any season and also based on weather conditions. This could be an idea to combine with the angular similarity.

2 Likes

That could work well as a conditional boolean indeed. Itā€™s not a direct replacement for brightness (what you would really like to know) but it does correlate well with it I believe.

How do I set the maximum height the cover will be automatically adjusted too?

Did I miss the obvious post on how to run the simulation?

Simulation is just the python notebook. Not much to explain

Just to share where this has gone since summer when I shared this: I now have a couple input booleans that I added to this. I use those to allow ā€œnap timeā€ which keeps the shades closed in my bedroom even when all other inputs say they should remain open. I also have a ā€œwork modeā€ which keeps my office shade closed about 75% when it is bright (because my office has 8 foot high south facing windows and I cannot see my monitor!).

1 Like