Skip to content

Instantly share code, notes, and snippets.

@gerardag
Created June 30, 2021 17:24
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 gerardag/a54b7f804cfc0457542d42245074e3ad to your computer and use it in GitHub Desktop.
Save gerardag/a54b7f804cfc0457542d42245074e3ad to your computer and use it in GitHub Desktop.
Hablemos de Domótica - Vacaciones
# -----------------------------------------------------------
# Con este automatismo lo que hacemos es setear true o false
# un campo para que Home Assistant sepa si estamos de
# vacaciones.
# -----------------------------------------------------------
- id: "Turn on vacation mode"
alias: ⛱️ Turn ON Vacation state
description: ""
trigger:
- platform: state
entity_id: calendar.<your_calendar_name>
to: "on"
condition: []
action:
- service: script.turn_on_holidays_state
data: {}
entity_id: input_boolean.vacation
mode: restart
# -----------------------------------------------------------
# Encendemos la lámpara 15 minutos antes de la puesta de sol
# -----------------------------------------------------------
- id: "Turn ligh on"
alias: Sunset
description: Turn on light 15 minutes before sunset.
trigger:
- platform: sun
event: sunset
offset: -00:15:00
condition: []
action:
- service: light.turn_on
target:
entity_id: light.light
data:
kelvin: 3200
brightness_pct: 100
mode: restart
# -----------------------------------------------------------
# Apagamos las luces en el caso que el boleano de vacaciones
# esté a true.
#
# Además cuando estas se apagan mandamos un aviso al móvil
# indicando que se han apagado.
# -----------------------------------------------------------
- id: "1608707820998"
alias: Randomly turn off light
description: Randomly turn off lights between 23:30 and 23:59
trigger:
- platform: time
at: "23:27"
condition:
- condition: state
entity_id: input_boolean.vacation
state: "on"
action:
- delay:
'{{ ((range(0, 1) | random) | int) ~ ":" ~ ((range(5, 28) | random) | int) ~
":" ~ ((range(1, 59) | random) | int) }}'
- type: turn_off
device_id: 1234567890
entity_id: light.light
domain: light
- service: script.<your_send_notificacion_service>
data:
title: Bona nit
message: Llum del menjador apagat.
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment