Dear all,
I have this package yaml to govern the timer on lights (in this case just one for test)
homeassistant:
customize:
automation.luci_accese_timer_acceso:
hidden: true
automation.luci_spente_fine_timer:
hidden: true
automation.luci_spente_timer_cancellato:
hidden: true
input_number:
minuti_luci:
name: Minuti Timer Luci
initial: 1
min: 0
max: 60
step: 1
icon: mdi:timer
input_select:
luci_timer:
name: Luci Timer
options:
- Seleziona Luci
- Luce del Balcone della Sala
initial: Seleziona Luci
icon: mdi:selection
timer:
light_on:
name: Timer Luci
automation:
- alias: Luci accese timer acceso
trigger:
platform: state
entity_id:
- light.luce_del_balcone_della_sala
to: 'on'
condition:
- condition: template
value_template: >
{{ trigger.entity_id == 'light.' + states('input_select.luci_timer')|lower }}
action:
service: timer.start
entity_id: timer.light_on
data_template:
duration: "{{ (states('input_number.minuti_luci')|int(2) * 60)|timestamp_custom('%H:%M:%S',false) }}"
- alias: Luci spente timer cancellato
trigger:
platform: state
entity_id:
- light.luce_del_balcone_della_sala
to: 'off'
condition:
- condition: template
value_template: >
{{ trigger.entity_id == 'light.' + states('input_select.luci_timer')|lower }}
action:
service: timer.cancel
entity_id: timer.light_on
- alias: Luci spente fine timer
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.light_on
action:
service: light.turn_off
data_template:
entity_id: "light.{{ states('input_select.luci_timer')|lower }}"
I have put this timer_light.yaml in the /packages directory and in the configuration.yaml I have insered this:
homeassistant:
# Packages Source
packages: !include_dir_named packages
After reboot I have this settings in Lovelace:
So far all appears good, apart the fact that the timer don’t turn off the light.
Can anyone help me to understand where is the mistake?
Many thanks!