Automatic blinds / sunscreen control based on sun platform

I have a few questions… using the blueprint.

  • How do I have to interprete the “Field of view left/right”?
    Left from which side of the window? :slight_smile:
  • I have blinds that are not ‘floor to top’ but for a normal window. I’ve set the minimum height to be the distance between the floor to the start of the window, this is correct?
  • Is correct for the azimuth? It’s the house with number 8.
    image
  • My backdoor blind - which is a full 2.3m one - keeps staying open at 10%. Never completely closes…
    minimum distance is set at 0.1m

When you look outside the window standing in the middle the left side of your view is the left fov angle and vice versa for the right side. See also Automatic blinds / sunscreen control based on sun platform - #30 by langestefan

The height from the floor to the bottom of the window is neglectable. The minimum height only need to be set if you always want 20 centimeters of the window not being covered. If you want the window to be fully covered in some situations just leave it at zero. See also this post Automatic blinds / sunscreen control based on sun platform - #10 by langestefan

That’s because you have set the minimum height, so the blind should always be open for that measurement from the bottom of the window.

1 Like


This is the configuration for that particular blind - should close to 0% I think?

Update: 130 Azimuth windows do nothing. The only window that reacts is the 310. 310 blind goes into default cover height.

this:
  entity_id: automation.cover_height_134_grad
  state: 'on'
  attributes:
    id: '1688727824028'
    last_triggered: '2023-07-08T05:43:09.557121+00:00'
    mode: single
    current: 0
    friendly_name: Cover Height 130 Grad
  last_changed: '2023-07-08T05:43:06.818917+00:00'
  last_updated: '2023-07-08T05:43:09.562430+00:00'
  context:
    id: 01H4T0D0ZMVGSDENAVE666ACPM
    parent_id: 01H4T0D0ZM80BQ1J8WXBVWF8EG
    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-07-09T02:45:49.117292+00:00'
      next_dusk: '2023-07-08T20:16:30.049414+00:00'
      next_midnight: '2023-07-08T23:31:07+00:00'
      next_noon: '2023-07-08T11:30:53+00:00'
      next_rising: '2023-07-09T03:28:52.746774+00:00'
      next_setting: '2023-07-08T19:33:27.086792+00:00'
      elevation: 18.18
      azimuth: 76.29
      rising: true
      friendly_name: Sun
    last_changed: '2023-07-08T05:07:21.028192+00:00'
    last_updated: '2023-07-08T05:39:21.037229+00:00'
    context:
      id: 01H4T061TD2TBV12BXSN6406CB
      parent_id: null
      user_id: null
  to_state:
    entity_id: sun.sun
    state: above_horizon
    attributes:
      next_dawn: '2023-07-09T02:45:49.117292+00:00'
      next_dusk: '2023-07-08T20:16:30.049414+00:00'
      next_midnight: '2023-07-08T23:31:07+00:00'
      next_noon: '2023-07-08T11:30:53+00:00'
      next_rising: '2023-07-09T03:28:52.746774+00:00'
      next_setting: '2023-07-08T19:33:27.086792+00:00'
      elevation: 18.82
      azimuth: 77
      rising: true
      friendly_name: Sun
    last_changed: '2023-07-08T05:07:21.028192+00:00'
    last_updated: '2023-07-08T05:43:21.038174+00:00'
    context:
      id: 01H4T0DC6ER1MZJVYTR8GVZ6JC
      parent_id: null
      user_id: null
  for: null
  attribute: null
  description: state of sun.sun
cover_entity:
  entity_id:
    - cover.arbeitszimmer_rolladen_links
    - cover.kuche_rolladen_links
azimuth: 130
distance: 0.1
max_height: 1.2
min_height: 0
default_height: 50
min_position: 0
degrees: 90
default_template: ''
azimuth_left: 90
azimuth_right: 90
max_elevation: 90
min_elevation: 0
cover_height: 5
change_threshold: 1
time_out: 1
condition_mode: and

Now I have to ask a really stupid question: I have now installed Blueprint 1.0.6. Do I still need to install the custom template?

Can you share the full trace instead of the changed variables. These don’t give any information how the automation runs or if it is stopped by any condition. You can download the full trace log by clicking on the 3 dots in the trace window.

Btw the template is build in the blueprint so no need to add it.

{
  "trace": {
    "last_step": "action/0/choose/0/sequence/0/conditions/1",
    "run_id": "d28b3802a49f1daac0845ad29de1d2b6",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2023-07-08T07:07:08.774593+00:00",
      "finish": "2023-07-08T07:07:08.790515+00:00"
    },
    "domain": "automation",
    "item_id": "1688727824028",
    "trigger": "state of sun.sun",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2023-07-08T07:07:08.775088+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.cover_height_134_grad",
              "state": "on",
              "attributes": {
                "id": "1688727824028",
                "last_triggered": "2023-07-08T07:03:08.774155+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Cover Height 130 Grad"
              },
              "last_changed": "2023-07-08T06:55:12.216806+00:00",
              "last_updated": "2023-07-08T07:03:08.784723+00:00",
              "context": {
                "id": "01H4T4ZFQ5VE26TRQ8HSCXH9ME",
                "parent_id": "01H4T4ZFQ4N8KKRB9VQNKGDYPQ",
                "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-07-09T02:45:49.117292+00:00",
                  "next_dusk": "2023-07-08T20:16:30.049414+00:00",
                  "next_midnight": "2023-07-08T23:31:07+00:00",
                  "next_noon": "2023-07-08T11:30:53+00:00",
                  "next_rising": "2023-07-09T03:28:52.746774+00:00",
                  "next_setting": "2023-07-08T19:33:27.086792+00:00",
                  "elevation": 31.76,
                  "azimuth": 91.51,
                  "rising": true,
                  "friendly_name": "Sun"
                },
                "last_changed": "2023-07-08T06:55:08.769483+00:00",
                "last_updated": "2023-07-08T07:03:08.772120+00:00",
                "context": {
                  "id": "01H4T4ZFQ4N8KKRB9VQNKGDYPQ",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sun.sun",
                "state": "above_horizon",
                "attributes": {
                  "next_dawn": "2023-07-09T02:45:49.117292+00:00",
                  "next_dusk": "2023-07-08T20:16:30.049414+00:00",
                  "next_midnight": "2023-07-08T23:31:07+00:00",
                  "next_noon": "2023-07-08T11:30:53+00:00",
                  "next_rising": "2023-07-09T03:28:52.746774+00:00",
                  "next_setting": "2023-07-08T19:33:27.086792+00:00",
                  "elevation": 32.42,
                  "azimuth": 92.28,
                  "rising": true,
                  "friendly_name": "Sun"
                },
                "last_changed": "2023-07-08T06:55:08.769483+00:00",
                "last_updated": "2023-07-08T07:07:08.773540+00:00",
                "context": {
                  "id": "01H4T56T3542E9WH4H5KDZ8RFR",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of sun.sun"
            },
            "cover_entity": {
              "entity_id": [
                "cover.arbeitszimmer_rolladen_links",
                "cover.kuche_rolladen_links"
              ]
            },
            "azimuth": 130,
            "distance": 0.1,
            "max_height": 1.2,
            "min_height": 0,
            "default_height": 50,
            "min_position": 0,
            "degrees": 90,
            "default_template": "",
            "azimuth_left": 90,
            "azimuth_right": 90,
            "max_elevation": 90,
            "min_elevation": 0,
            "cover_height": 7,
            "change_threshold": 1,
            "time_out": 1,
            "condition_mode": "and"
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2023-07-08T07:07:08.775118+00:00",
          "result": {
            "wanted_time_before": "2023-07-08T19:33:27.086792+00:00",
            "wanted_time_after": "2023-07-08T04:07:59.864140+00:00",
            "result": true
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-07-08T07:07:08.778919+00:00",
          "changed_variables": {
            "context": {
              "id": "01H4T56T363H8F063VNNZ880J2",
              "parent_id": "01H4T56T3542E9WH4H5KDZ8RFR",
              "user_id": null
            }
          },
          "result": {
            "choice": 0
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2023-07-08T07:07:08.778982+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2023-07-08T07:07:08.779003+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "action/0/choose/0/sequence/0": [
        {
          "path": "action/0/choose/0/sequence/0",
          "timestamp": "2023-07-08T07:07:08.779922+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/sequence/0/conditions/0": [
        {
          "path": "action/0/choose/0/sequence/0/conditions/0",
          "timestamp": "2023-07-08T07:07:08.780023+00:00",
          "error": "In 'template' condition: AttributeError: 'list' object has no attribute 'lower'"
        }
      ],
      "action/0/choose/0/sequence/0/conditions/1": [
        {
          "path": "action/0/choose/0/sequence/0/conditions/1",
          "timestamp": "2023-07-08T07:07:08.780302+00:00",
          "error": "In 'template' condition: UndefinedError: homeassistant.helpers.template.AllStates object has no element ['cover.arbeitszimmer_rolladen_links', 'cover.kuche_rolladen_links']"
        }
      ]
    },
    "config": {
      "variables": {
        "cover_entity": {
          "entity_id": [
            "cover.arbeitszimmer_rolladen_links",
            "cover.kuche_rolladen_links"
          ]
        },
        "azimuth": 130,
        "distance": 0.1,
        "max_height": 1.2,
        "min_height": 0,
        "default_height": 50,
        "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 -%} {# normalize in range [0,1] #} {%- macro norm(x, min, max) %}\n  {{ (x - min) / (max - min) }}\n{%- endmacro %} {# convert blind height h to percentage [0,100] #} {%- macro h2perc(x) %}\n  {{ 100 * float(norm(x, h_min, h_max)) }}\n{%- endmacro %} {# clip value between [min, max] #} {%- macro clipv(x, x_min, x_max) %}\n  {{ max(min(x, x_max), x_min) }}\n{%- endmacro %} {# constants #} {%- set win_azi = azimuth -%} {%- set left_azi = azimuth_left | default(90) -%} {%- set right_azi = azimuth_right | default(90) -%} {%- set elev_high = deg2rad * (max_elevation | default(90)) -%} {# Maximum: 90 #} {%- set elev_low = deg2rad * (min_elevation| default(0)) -%} {# Minimum: 0 #} {%- set d = distance | default(0.5) -%} {%- set h_max = max_height | default(2.10) -%} {%- set h_min = min_height | default(0) -%} {%- set deg = degrees | default(90) -%} {%- set def = default_height | default(60) -%} {%- set min_pos = min_position | default(0) -%} {%- set def_temp = default_template | default('') -%} {% if def_temp | int(-1) >= 0 %}\n  {% set def = def_temp %}\n{%endif%}\n{# FOV #} {%- if left_azi != right_azi-%}\n  {%- set azi_left = deg2rad * -left_azi -%} {# Minimum: -90 #}\n  {%- set azi_right = deg2rad * right_azi -%} {# Maximum: 90 #}\n{%-else-%}\n  {%- set azi_left = deg2rad * -deg -%} {# Minimum: -90 #}\n  {%- set azi_right = deg2rad * deg -%} {# Maximum: 90 #}\n{%-endif-%} {%- set fov = deg2rad * deg -%} {# get sun elevation / azimuth from sun.sun #} {%- set sun_azi = state_attr('sun.sun', 'azimuth') -%} {%- set sun_ele = state_attr('sun.sun', 'elevation') -%} {# default height, when automatic control is off. #} {%- set def_h = def / 100 * h_max -%} {%- set alpha = deg2rad * sun_ele -%} {%- set gamma = deg2rad * (win_azi - sun_azi) -%}     {%- set h = (d / cos(gamma)) * tan(alpha) -%} {# gamma is outside of FOV #} {%- if gamma < azi_left or gamma > azi_right or alpha < elev_low or alpha > elev_high -%}\n  {{ clipv(h2perc(def_h) | round(0) | int , 0, 100) }}\n{# gamma is inside of FOV #} {%- else -%}  \n  {{ clipv(h2perc(h) | round(0) | int , min_pos, 100) }}\n{%- endif -%}\n",
        "change_threshold": 1,
        "time_out": 1,
        "condition_mode": "and"
      },
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "sun.sun"
          ]
        }
      ],
      "condition": [
        {
          "condition": "sun",
          "before": "sunset",
          "after": "sunrise",
          "after_offset": "00:40:00"
        }
      ],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "template",
                  "value_template": "{{condition_mode == 'and'}}"
                }
              ],
              "sequence": [
                {
                  "condition": "and",
                  "conditions": [
                    {
                      "condition": "template",
                      "value_template": "{%- set position = state_attr(cover_entity.entity_id,'current_position') | float -%} {{ ((position - cover_height | float) | abs > change_threshold) or (cover_height in [default_height, default_template] and position not in [default_height, default_template])}}\n"
                    },
                    {
                      "condition": "template",
                      "value_template": "{{now() - timedelta(minutes=time_out) >= states[cover_entity.entity_id].last_updated }}\n"
                    }
                  ]
                },
                {
                  "choose": [],
                  "default": []
                },
                {
                  "service": "cover.set_cover_position",
                  "data": {
                    "position": "{{ cover_height | int(0) }}"
                  },
                  "target": {
                    "entity_id": [
                      "cover.arbeitszimmer_rolladen_links",
                      "cover.kuche_rolladen_links"
                    ]
                  }
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "template",
                  "value_template": "{{condition_mode == 'or'}}"
                }
              ],
              "sequence": [
                {
                  "condition": "or",
                  "conditions": [
                    {
                      "condition": "template",
                      "value_template": "{%- set position = state_attr(cover_entity.entity_id,'current_position') | float -%} {{ ((position - cover_height | float) | abs > change_threshold) or (cover_height in [default_height, default_template] and position not in [default_height, default_template])}}\n"
                    },
                    {
                      "condition": "template",
                      "value_template": "{{now() - timedelta(minutes=time_out) >= states[cover_entity.entity_id].last_updated }}\n"
                    }
                  ]
                },
                {
                  "choose": [],
                  "default": []
                },
                {
                  "service": "cover.set_cover_position",
                  "data": {
                    "position": "{{ cover_height | int(0) }}"
                  },
                  "target": {
                    "entity_id": [
                      "cover.arbeitszimmer_rolladen_links",
                      "cover.kuche_rolladen_links"
                    ]
                  }
                }
              ]
            }
          ]
        }
      ],
      "mode": "single",
      "id": "1688727824028",
      "alias": "Cover Height 130 Grad",
      "description": ""
    },
    "blueprint_inputs": {
      "id": "1688727824028",
      "alias": "Cover Height 130 Grad",
      "description": "",
      "use_blueprint": {
        "path": "langestefan/auto_sun_blind.yaml",
        "input": {
          "azimuth": 130,
          "distance": 0.1,
          "max_height": 1.2,
          "cover_entity": {
            "entity_id": [
              "cover.arbeitszimmer_rolladen_links",
              "cover.kuche_rolladen_links"
            ]
          },
          "condition": [
            {
              "condition": "sun",
              "before": "sunset",
              "after": "sunrise",
              "after_offset": "00:40:00"
            }
          ],
          "min_elevation": 0,
          "default_height": 50
        }
      }
    },
    "context": {
      "id": "01H4T56T363H8F063VNNZ880J2",
      "parent_id": "01H4T56T3542E9WH4H5KDZ8RFR",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Cover Height 130 Grad",
      "message": "triggered by state of sun.sun",
      "source": "state of sun.sun",
      "entity_id": "automation.cover_height_134_grad",
      "context_id": "01H4T56T363H8F063VNNZ880J2",
      "when": 1688800028.775343,
      "domain": "automation"
    }
  ]
}

I am guessing that the blueprint has a problem when you try to control multiple covers at the same time with the same automation. Maybe something to debug when I have time for it.

ok…i remove the second blind and make a separate automation for it. I will report.

It works. Blueprint cannot manage more than 1 entity.

I’m a bit puzzled why the blind didn’t close, and then it closed all the way.

What is the action/0/choose/0/sequence/0/conditions/0" ?

{
  "trace": {
    "last_step": "action/0/choose/0/sequence/0/conditions/0",
    "run_id": "9d0eac5696c1c4287de5f1487d963de2",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2023-07-09T12:29:40.084251+00:00",
      "finish": "2023-07-09T12:29:40.120027+00:00"
    },
    "domain": "automation",
    "item_id": "1688129398219",
    "trigger": "state of sun.sun",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2023-07-09T12:29:40.090816+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.cover_height_backdoor",
              "state": "on",
              "attributes": {
                "last_triggered": "2023-07-09T12:25:40.112869+00:00",
                "mode": "single",
                "current": 0,
                "id": "1688129398219",
                "friendly_name": "Cover Height - Backdoor"
              },
              "last_changed": "2023-07-08T19:02:01.441127+00:00",
              "last_updated": "2023-07-09T12:25:40.138498+00:00",
              "context": {
                "id": "01H4X9TRGEZHYZDA6HE7E92RGQ",
                "parent_id": "01H4X9TRENCBY67P5746YTXRQ5",
                "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-07-10T02:55:20.179807+00:00",
                  "next_dusk": "2023-07-09T20:44:35.297567+00:00",
                  "next_midnight": "2023-07-09T23:49:54+00:00",
                  "next_noon": "2023-07-10T11:49:49+00:00",
                  "next_rising": "2023-07-10T03:41:18.822669+00:00",
                  "next_setting": "2023-07-09T19:58:37.510098+00:00",
                  "elevation": 60.39,
                  "azimuth": 196.98,
                  "rising": false,
                  "friendly_name": "Sun"
                },
                "last_changed": "2023-07-09T03:38:09.995835+00:00",
                "last_updated": "2023-07-09T12:25:40.053678+00:00",
                "context": {
                  "id": "01H4X9TRENCBY67P5746YTXRQ5",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sun.sun",
                "state": "above_horizon",
                "attributes": {
                  "next_dawn": "2023-07-10T02:55:20.179807+00:00",
                  "next_dusk": "2023-07-09T20:44:35.297567+00:00",
                  "next_midnight": "2023-07-09T23:49:54+00:00",
                  "next_noon": "2023-07-10T11:49:49+00:00",
                  "next_rising": "2023-07-10T03:41:18.822669+00:00",
                  "next_setting": "2023-07-09T19:58:37.510098+00:00",
                  "elevation": 60.2,
                  "azimuth": 198.8,
                  "rising": false,
                  "friendly_name": "Sun"
                },
                "last_changed": "2023-07-09T03:38:09.995835+00:00",
                "last_updated": "2023-07-09T12:29:40.054784+00:00",
                "context": {
                  "id": "01H4XA22TPC4MJ2W6X7ZSA2GW9",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of sun.sun"
            },
            "cover_entity": {
              "entity_id": "cover.backdoor"
            },
            "azimuth": 245,
            "distance": 0.1,
            "max_height": 2.3,
            "min_height": 0,
            "default_height": 100,
            "min_position": 0,
            "degrees": 90,
            "default_template": "",
            "azimuth_left": 35,
            "azimuth_right": 45,
            "max_elevation": 90,
            "min_elevation": 0,
            "cover_height": 100,
            "change_threshold": 0,
            "time_out": 1,
            "condition_mode": "and"
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2023-07-09T12:29:40.090906+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/entity_id/0": [
        {
          "path": "condition/0/entity_id/0",
          "timestamp": "2023-07-09T12:29:40.091033+00:00",
          "result": {
            "result": true,
            "state": "off",
            "wanted_state": "off"
          }
        }
      ],
      "condition/1": [
        {
          "path": "condition/1",
          "timestamp": "2023-07-09T12:29:40.091169+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/1/conditions/0": [
        {
          "path": "condition/1/conditions/0",
          "timestamp": "2023-07-09T12:29:40.091224+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/1/conditions/0/entity_id/0": [
        {
          "path": "condition/1/conditions/0/entity_id/0",
          "timestamp": "2023-07-09T12:29:40.091282+00:00",
          "result": {
            "result": false,
            "state": "summer",
            "wanted_state": "winter"
          }
        }
      ],
      "condition/2": [
        {
          "path": "condition/2",
          "timestamp": "2023-07-09T12:29:40.091404+00:00",
          "result": {
            "result": true,
            "entities": [
              "sensor.tomorrow_io_home_nowcast_temperature",
              "input_number.backdoor_cover_outdoor_trigger_temperature_trigger_temperature"
            ]
          }
        }
      ],
      "condition/3": [
        {
          "path": "condition/3",
          "timestamp": "2023-07-09T12:29:40.091895+00:00",
          "result": {
            "result": true,
            "entities": [
              "sensor.average_kitchen_temperature",
              "input_number.backdoor_cover_room_trigger_temperature"
            ]
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-07-09T12:29:40.106471+00:00",
          "changed_variables": {
            "context": {
              "id": "01H4XA22VMNMQMXNVQXX04X2V7",
              "parent_id": "01H4XA22TPC4MJ2W6X7ZSA2GW9",
              "user_id": null
            }
          },
          "result": {
            "choice": 0
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2023-07-09T12:29:40.106729+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2023-07-09T12:29:40.106849+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "action/0/choose/0/sequence/0": [
        {
          "path": "action/0/choose/0/sequence/0",
          "timestamp": "2023-07-09T12:29:40.112957+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/sequence/0/conditions/0": [
        {
          "path": "action/0/choose/0/sequence/0/conditions/0",
          "timestamp": "2023-07-09T12:29:40.113391+00:00",
          "result": {
            "result": false,
            "entities": [
              "cover.backdoor"
            ]
          }
        }
      ]
    },
    "config": {
      "variables": {
        "cover_entity": {
          "entity_id": "cover.backdoor"
        },
        "azimuth": 245,
        "distance": 0.1,
        "max_height": 2.3,
        "min_height": 0,
        "default_height": 100,
        "min_position": 0,
        "degrees": 90,
        "default_template": "",
        "azimuth_left": 35,
        "azimuth_right": 45,
        "max_elevation": 90,
        "min_elevation": 0,
        "cover_height": "{%- set deg2rad = pi/180 -%} {

If you want a graph of the calculated blind height you can add the template sensor/(HACS) macro. It may yield some useful insights as to what is going on. Alternatively you could try to graph the cover position but I’m not sure how to get it as its not an entity.

Update Blueprint to v1.1.0

  • Adds support for multiple entities to be controlled with one automation

Import the updated blueprint directly:

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

See the full changelog

Interested in a sensor entity from a macro?

Check the Github

4 Likes

Is there a latest version of the code to get a sensor entity that I can use?

The macro/custom_template on the Github is the latest. The instructions to install and use it are included.:wink:

2 Likes

I have updated to blueprint 1.1.0 - but now I get the following error:

2023-07-13 19:50:14.204 ERROR (MainThread) [homeassistant.components.automation.cover_height_guest_bedroom] Error rendering variables: ValueError: Template error: int got invalid input 'None' when rendering template '{%- set ns = namespace(list_1=[],name_1=[],list_2=[],name_2=[]) %} {%- for c in cover_entity['entity_id'] %}
  {%- set position = state_attr(c,'current_position') | int -%}
  {%- set con_1 = ((position - cover_height | float) | abs >= change_threshold)
  or (cover_height in [default_height, default_template] and position not in [default_height, default_template])%}
  {%- set ns.list_1 = ns.list_1 + [con_1]  -%}
  {%- set con_2 = now() - timedelta(minutes=time_out) >= states[c].last_updated %}
  {%- set ns.list_2 = ns.list_2 + [con_2] %}
  {%- if con_1 == true -%}
    {%- set ns.name_1 = ns.name_1 + [c] -%}
  {% endif %}
  {%if con_2 == true%}
    {%- set ns.name_2 = ns.name_2 + [c] -%}
  {% endif %}
{%endfor%} {%- set dict = {
  'condition_1':ns.list_1,
  'condition_2':ns.list_2,
  'names_1':ns.name_1,
  'names_2':ns.name_2
  } %}
{{dict}}' but no default was specified

Could you show the trace and how you have setup the automation?

I am suspecting that the cover has not the attribute current_position

This is the trace - no other output is given.

{
  "trace": {
    "last_step": null,
    "run_id": "0ff8e724c0b905cc4eb905a49981e2e7",
    "state": "stopped",
    "script_execution": null,
    "timestamp": {
      "start": "2023-07-13T18:40:46.665464+00:00",
      "finish": "2023-07-13T18:40:46.670131+00:00"
    },
    "domain": "automation",
    "item_id": "1688215868969",
    "error": "ValueError: Template error: int got invalid input 'None' when rendering template '{%- set ns = namespace(list_1=[],name_1=[],list_2=[],name_2=[]) %} {%- for c in cover_entity['entity_id'] %}\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.guest_bedroom"
        },
        "azimuth": 245,
        "distance": 0.1,
        "max_height": 2.9,
        "min_height": 1.9,
        "default_height": 100,
        "min_position": 0,
        "degrees": 90,
        "default_template": "",
        "azimuth_left": 45,
        "azimuth_right": 50,
        "max_elevation": 90,
        "min_elevation": 0,
        "cover_height": "{%- set deg2rad = pi/180 -%} {

I’ve not changed anything with the setup - I’m targetting the entities that are exposed using the Overkiz integration on HA (Somfy).

It happens to all my screens.

Thanks, I found the bug.

Apparently the entity selector provides a string if one cover is set and a list of strings when multiple are set.
But it stays a list if you go from multiple entities back to one, by removing the other entities from the automation. :sweat_smile:

Where in testing on my system it showed (first tested multiple covers)

      "variables": {
        "cover_entity": {
          "entity_id": ["cover.guest_bedroom"]

I have build in a check to convert to a list when only a string is detected. You can download v1.1.1 with the fix with the button from the v1.1.0 release post above.

1 Like

I am trying to visualize how this would work for my dumb blinds, blinds that don’t report how open they are nor can open incrementally. They are RF controlled and you can setup certain heights to stop at as well. I think ideally just close all the way when sun coming through and open when sun passes. Any advice on this setup?

You can setup a template cover entity: Template Cover - Home Assistant

With distance set to 0 the blueprint will set the cover to 0% (closed) when the sun is in FOV and otherwise to default, which you can set to 100% (open) to get the behaviour you want. Alternatively you could just use a template condition in your own automation, the blueprint is a kinda overkill if you just want it to be either open or closed