Hi!
I’m trying to reduce the amount of automations in my Home Assistant using blueprints for my covers.
I want to manage as many automations as possible using a single blueprint with an adaptative behavior depending on the fact it’s a room with people sleeping or if the windows has an opening sensor.
For that, I use inputs in my blueprints, some of them being optional (opening_sensor and sleep_mode).
When I test if the inputs are defined, it doesn’t work and the rest of my automation crashes if I didn’t set a window sensor or a binary input to manage the presence of sleepers.
I tried so many times, with several syntaxes but I couldn’t find a way to fix it.
Some one could telle me what’s going wrong with my blueprint?
Thank’s
blueprint:
name: Ouverture et fermeture crépusculaire des volets
description: Ouvre et ferme les volets au crépuscule
domain: automation
input:
cover_target:
name: Volet
description: Le volet à fermer
selector:
entity:
domain: cover
sun_elevation:
name: Elévation soleil
description: Elévation du soleil d'ouverture et de fermeture du volet (input_number dans le Lovelace)
selector:
entity:
domain: input_number
activated_automation:
name: Actionneur activation règle
description: Activation / désactivation de l'automatisme crépusculaire (input_boolean dans le Lovelace)
selector:
entity:
domain: input_boolean
opening_sensor:
name: Capteur ouverture de fenêtre / porte-fenêtre
description: Ouverture et fermeture du volet si la fenêtre associée est fermée (entité facultative)
default: {}
selector:
entity:
domain: binary_sensor
sleep_mode:
name: Présence dormeur
description: Ouverture du volet le matin si la pièce est inoccupée / Fermeture du volet avant l'aube si la pièce est occupée (entité facultative)
default: {}
selector:
entity:
domain: input_boolean
mode: single
trigger:
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
above: !input sun_elevation
id: "aurore"
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: !input sun_elevation
id: "crépuscule"
- platform: state
entity_id: !input opening_sensor
to: "on"
id: "fenêtre ouverte"
- platform: state
entity_id: !input opening_sensor
to: "off"
id: "fenêtre fermée"
variables:
var_opening_sensor: !input opening_sensor
var_sleep_mode: !input sleep_mode
var_activated_automation: !input activated_automation
action:
choose:
- alias: "Fermeture volet crépuscule"
conditions:
- condition: template
value_template: >
{{ trigger.id == 'crépuscule' and is_state(var_activated_automation,'on') and (var_opening_sensor == none or (var_opening_sensor != none and is_state(var_opening_sensor,'off'))) }}
sequence:
- service: cover.close_cover
target:
entity_id: !input cover_target
- alias: "Ouverture volet aube si chambre innoccupée"
conditions:
- condition: template
value_template: >
{{ trigger.id == 'aurore' and is_state(var_activated_automation,'on') and (var_opening_sensor == none or (var_opening_sensor != none and is_state(var_opening_sensor,'off'))) and (var_sleep_mode == none or (var_sleep_mode != none and is_state(var_sleep_mode,'off'))) }}
sequence:
- service: cover.open_cover
target:
entity_id: !input cover_target
- alias: "Fermeture volet aube si chambre occupée"
conditions:
- condition: template
value_template: >
{{ trigger.id == 'aurore' and is_state(var_activated_automation,'on') and var_sleep_mode != none and is_state(var_sleep_mode,'on') }}
sequence:
- service: cover.close_cover
target:
entity_id: !input cover_target
- alias: "Ouverture volet si fenêtre ouverte"
conditions:
- condition: trigger
id: "fenêtre ouverte"
- condition: state
entity_id: !input activated_automation
state: "on"
sequence:
- service: cover.open_cover
target:
entity_id: !input cover_target
- alias: "Fermeture volet si fenêtre fermée"
conditions:
- condition: trigger
id: "fenêtre fermée"
- condition: state
entity_id: !input activated_automation
state: "on"
- condition: numeric_state
entity_id: sun.sun
attribute: elevation
below: !input sun_elevation
sequence:
- service: cover.close_cover
target:
entity_id: !input cover_target