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?
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.
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.
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.
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.