Skip to content

Instantly share code, notes, and snippets.

@clempat
Last active December 19, 2020 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clempat/b2534120c51307d0c36b94e143594cba to your computer and use it in GitHub Desktop.
Save clempat/b2534120c51307d0c36b94e143594cba to your computer and use it in GitHub Desktop.
blueprint:
name: Ne pas chauffer l'extérieur
description:
Eteindre le chauffage lors de l'ouverture d'une fenêtre, puis le rallumer
à la fermeture
domain: automation
input:
windows:
name: Fenêtres
description: Entitée représentant toutes les fenêtres de la pièce
selector:
entity:
domain: binary_sensor
device_class: window
delay:
name: Délai
description: Délai à partir duquel le chauffage s'éteins (secondes)
default: 0
selector:
number:
min: 0.0
max: 120.0
unit_of_measurement: secondes
step: 1.0
mode: slider
climate:
name: Thermostat
description: Thermostat contrôlant le chauffage de la pièce.
selector:
entity:
domain: climate
trigger:
platform: state
entity_id: !input "windows"
for:
seconds: !input "delay"
action:
# in order to use in template
- variables:
climate_input: !input "climate"
climate_object_id: "{{ states[climate_input].object_id }}"
prev_scene_id: "prev_state_climate_{{climate_object_id}}"
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "on" }}'
sequence:
- service: scene.create
data_template:
scene_id: "{{prev_scene_id}}"
snapshot_entities: !input "climate"
- service: climate.turn_off
entity_id: !input "climate"
default:
- service: >
{% if states("scene." ~ prev_scene_id) != "unknown" %}
scene.turn_on
{% else %}
climate.turn_on
{% endif %}
data:
entity_id: >
{% if states("scene." ~ prev_scene_id) != "unknown" %}
scene.{{prev_scene_id}}
{% else %}
{{climate_input}}
{% endif %}
@clempat
Copy link
Author

clempat commented Dec 19, 2020

  • I need to fix the condition using right entity I’d which I updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment