Blueprint newbee stucks

Hi,
I do my first blueprint but run into problems:
I want to automate some rooms with electrical window opener. If its cold enough outside and no rain open the window(s).
I do an automation for one of the rooms and tested it seriously, working fine.
I start developing a blueprint around this automation for reuse for all rooms later.
BUT: Some room has one window, other have two.
How can I create one blueprint which handles one OR two windows?

Thanks for helping out.

With best regards

Gerhard

Same answer...

blueprint:
  name: Passive Cooling Using Window
  description: Open windows when it is cold enough outside and close windows when the room is too cold
  domain: automation
  author: DI Gerhard Kreuzer
  input:
    rain_sensor:
      name: Rain Sensor
      selector:
        entity:
          filter:
            domain: binary_sensor
    enabled:
      name: Enable Signal
      selector:
        entity:
          filter:
            domain: binary_sensor
    outside_temperature:
      name: Outside Temperature Sensor
      selector:
        entity:
          filter:
            domain: sensor
            device_class: temperature
    inside_temperature:
      name: Inside Temperature Sensor
      selector:
        entity:
          filter:
            domain: sensor
            device_class: temperature
    window:
      name: Window or group of windows
      selector:
        target:
          entity:
            domain: cover
  
variables:
  temp_outside: !input outside_temperature
  temp_inside: !input inside_temperature

triggers:
  - trigger: state
    entity_id: !input rain_sensor
  - trigger: state
    entity_id: !input enabled
  - trigger: state
    entity_id: !input outside_temperature
  - trigger: state
    entity_id: !input inside_temperature
  - trigger: state
    entity_id: !input enabled
    from:
      - "on"
    to:
      - "off"
    id: falling edge on enabled
conditions: []
actions:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: !input rain_sensor
            state:
              - "on"
          - condition: trigger
            id:
              - falling edge on enabled
    then:
      - action: cover.close_cover
        metadata: {}
        target:
          entity_id: !input window
        data: {}
    else:
      - condition: state
        state:
          - "on"
        entity_id: !input enabled
      - if:
          - condition: template
            value_template: "{{ states('temp_inside') | float(20) - states('temp_outside') | float(20) > 2.0 }}"
        then:
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: !input inside_temperature
                    above: 22
                sequence:
                  - action: cover.open_cover
                    metadata: {}
                    target:
                      entity_id: !input window
                    data: {}
              - conditions:
                  - condition: numeric_state
                    entity_id: !input inside_temperature
                    below: 21
                sequence:
                  - action: cover.close_cover
                    metadata: {}
                    target:
                      entity_id: !input window
                    data: {}
        else:
          - action: cover.close_cover
            metadata: {}
            target:
              entity_id: !input window
            data: {}
mode: single

I learned that I have to store the input in variables to use this variabls in my templates.
Ok.
Get it running, but have the wrong name, just for testing different versions. So I deleteed the odd files and found my with all files gone ....
Ok.
Try it again, with little more knowldge about bluprints and now I fail with something like 'dictiomary message malformed ...' The error appears for about 10 seconds on the bottom of the window, this isn't really nice.

The automation which I try to turn in a blueprint works fine.
The input seection works also fine.
Now I don't have an ida whats wrong here.

Variables shouldn't be surrounded by quotes.

condition: template
value_template: |
  {{ states(temp_inside) | float(20) - states(temp_outside) | float(20) > 2.0 }}
1 Like

????
I subtract two numbers and than I compare the result with a number. The result of the comparison is 'true' or 'false'.

I use this statement in my automation without any problems:

alias: OG2 Ordination 9 Fenstersteuerung
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.regensignal
  - trigger: state
    entity_id:
      - binary_sensor.nachtruhe
  - trigger: state
    entity_id:
      - sensor.out_tempmeter_temp
  - trigger: state
    entity_id:
      - sensor.og2_ordination9_tempmeter_temperatur
  - trigger: state
    entity_id:
      - binary_sensor.nachtruhe
    from:
      - "on"
    to:
      - "off"
    id: Nachtruhe endet
conditions: []
actions:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: binary_sensor.regensignal
            state:
              - "on"
          - condition: trigger
            id:
              - Nachtruhe endet
    then:
      - action: cover.close_cover
        metadata: {}
        target:
          entity_id:
            - cover.og2_ordination_9_dachfenster
        data: {}
    else:
      - condition: state
        state:
          - "on"
        entity_id: binary_sensor.nachtruhe
      - if:
          - condition: template
            value_template: >-
              {{ states('sensor.og2_ordination9_tempmeter_temperatur')  |
              float(20)  -  states('sensor.out_tempmeter_temp') |  float(20) >
              2.0 }}
        then:
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: sensor.og2_ordination9_tempmeter_temperatur
                    above: 22
                sequence:
                  - action: cover.open_cover
                    metadata: {}
                    target:
                      entity_id:
                        - cover.og2_ordination_9_dachfenster
                    data: {}
              - conditions:
                  - condition: numeric_state
                    entity_id: sensor.og2_ordination9_tempmeter_temperatur
                    below: 21
                sequence:
                  - action: cover.close_cover
                    metadata: {}
                    target:
                      entity_id:
                        - cover.og2_ordination_9_dachfenster
                    data: {}
        else:
          - action: cover.close_cover
            metadata: {}
            target:
              entity_id:
                - cover.og2_ordination_9_dachfenster
            data: {}
mode: single

As I told you, the automation is syntactical and semantical ok, thee blueprint is based on this automation, but syntactical wrong, but can't find out why.

I think SG just hasn't had his coffee yet this morning... :upside_down_face:

Target selectors return a Target object not an entity ID, so you need to fix that.

You can either switch to a Entity selector for the window input and leave the actions as they are...

    window:
      name: Window or group of windows
      selector:
        entity:
          multiple: true
          filter:
            - domain: cover

... Or keep the Target selector and change all the actions.

action: cover.close_cover
metadata: {}
target: !input window
data: {}

Ya, dat...

Done.
But error still there.

Tell us which error and post the new config.

Also, you have two triggers monitoring the state of the same entity i.e. the enabled input... but your mode is set to single, so you're likely going to see some random failures to trigger. I would get rid of the falling edge on enabled trigger and just use a template condition for that part of the If.

blueprint:
  name: Passive Cooling Using Window
  description: Open windows when it is cold enough outside and close windows when the room is too cold
  domain: automation
  author: DI Gerhard Kreuzer
  input:
    rain_sensor:
      name: Rain Sensor
      selector:
        entity:
          filter:
            domain: binary_sensor
    enabled:
      name: Enable Signal
      selector:
        entity:
          filter:
            domain: binary_sensor
    outside_temperature:
      name: Outside Temperature Sensor
      selector:
        entity:
          filter:
            domain: sensor
            device_class: temperature
    inside_temperature:
      name: Inside Temperature Sensor
      selector:
        entity:
          filter:
            domain: sensor
            device_class: temperature
    window:
      name: Window or group of windows
      selector:
        target:
          entity:
            domain: cover
  
variables:
  temp_outside: !input outside_temperature
  temp_inside: !input inside_temperature

triggers:
  - trigger: state
    entity_id: !input rain_sensor
  - id: enabled
    trigger: state
    entity_id: !input enabled
  - trigger: state
    entity_id: !input outside_temperature
  - trigger: state
    entity_id: !input inside_temperature
conditions: []
actions:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: !input rain_sensor
            state:
              - "on"
          - and:
              - condition: trigger
                id: enabled
              - condition: template
                value_template: "{{ trigger.from_state.state == 'on' and trigger.to_state.state == 'off'}}"
    then:
      - action: cover.close_cover
        metadata: {}
        target: !input window
        data: {}
    else:
      - condition: state
        state:
          - "on"
        entity_id: !input enabled
      - if:
          - condition: template
            value_template: "{{ states(temp_inside) | float(20) - states(temp_outside) | float(20) > 2.0 }}"
        then:
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: !input inside_temperature
                    above: 22
                sequence:
                  - action: cover.open_cover
                    metadata: {}
                    target: !input window
                    data: {}
              - conditions:
                  - condition: numeric_state
                    entity_id: !input inside_temperature
                    below: 21
                sequence:
                  - action: cover.close_cover
                    metadata: {}
                    target: !input window
                    data: {}
        else:
          - action: cover.close_cover
            metadata: {}
            target: !input window
            data: {}
mode: single

The problem is, that the windows should be closed when enabled is switched off.
I can create a lot of triggers and check all the states in each action corresponding to the trigger, but this is lot of 'code'.

But first I have to find out, where the syntax probleem is.

I discovered 'Get Control'. I clicked and here I see, that assigning the cover item makes troubles. No idea why, maybe the input definition has some error. I created a cover group and try to assign this cover group.

Did you fix the discrepancy between the selector and all the cover actions I mentioned in my second post?


I'm not getting any errors with what I have posted in my previous post above.

Just FYI, make sure to restart HA or reload the Automation integration after editing the blueprint.

blueprint:
  name: Passive Cooling Using Window
  description: Open windows when it is cold enough outside and close windows when the room is too cold
  domain: automation
  author: DI Gerhard Kreuzer
  input:
    rain_sensor:
      name: Rain Sensor
      selector:
        entity:
          filter:
            domain: binary_sensor
    enabled:
      name: Enable Signal
      selector:
        entity:
          filter:
            domain: binary_sensor
    outside_temperature:
      name: Outside Temperature Sensor
      selector:
        entity:
          filter:
            domain: sensor
            device_class: temperature
    inside_temperature:
      name: Inside Temperature Sensor
      selector:
        entity:
          filter:
            domain: sensor
            device_class: temperature
    window:
      name: Window or group of windows
      selector:
        entity:
          filter:
            domain: cover
  
variables:
  temp_outside: !input outside_temperature
  temp_inside: !input inside_temperature

triggers:
  - trigger: state
    entity_id: !input rain_sensor
  - trigger: state
    entity_id: !input enabled
  - trigger: state
    entity_id: !input outside_temperature
  - trigger: state
    entity_id: !input inside_temperature
  - trigger: state
    entity_id: !input enabled
    from:
      - "on"
    to:
      - "off"
    id: falling edge on enabled
conditions: []
actions:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: !input rain_sensor
            state:
              - "on"
          - condition: trigger
            id:
              - falling edge on enabled
    then:
      - action: cover.close_cover
        metadata: {}
        target:
          entity_id: !input window
        data: {}
    else:
      - condition: state
        state:
          - "on"
        entity_id: !input enabled
      - if:
          - condition: template
            value_template: "{{ states(temp_inside) | float(20) - states(temp_outside) | float(20) >= 2.0 }}"
        then:
          - choose:
              - conditions:
                  - condition: numeric_state
                    entity_id: !input inside_temperature
                    above: 22
                sequence:
                  - action: cover.open_cover
                    metadata: {}
                    target:
                      entity_id: !input window
                    data: {}
              - conditions:
                  - condition: numeric_state
                    entity_id: !input inside_temperature
                    below: 21
                sequence:
                  - action: cover.close_cover
                    metadata: {}
                    target:
                      entity_id: !input window
                    data: {}
        else:
          - action: cover.close_cover
            metadata: {}
            target:
              entity_id: !input window
            data: {}
mode: single

So, this is working now. I get it wrong with the selector for the cover/group of covers.

I reload the yaml config after a change in the blueprint, I think this is ok.

Its late night here, went to sleep, will see how can I do something with the trigger conditions.
Thanks for helping for now.

Good morning,
ok, trigger problem:

triggers:
  - trigger: state
    entity_id: !input rain_sensor
  - trigger: state
    entity_id: !input outside_temperature
  - trigger: state
    entity_id: !input inside_temperature
  - trigger: state
    entity_id: !input enabled
    from:
      - "on"
    to:
      - "off"
    id: falling edge on enabled
  - trigger: state
    entity_id: !input enabled
    from:
      - "off"
    to:
      - "on"
    id: raising edge on enabled

I do a lot of triggering on raising and falling edges in my automations and I never see a problem with it (but than can be luck only). Is this generally ok?

I altered the trigger definitions, I only react on the falling edge with a special action. On the raising edge, the rest of the logic will be activated (hopefully) and the passive cooling is kicked off.

Please tell me, if this solution is better in HA, thanks a lot.