homeassistant/archive/packages/timer.yaml

118 lines
3.3 KiB
YAML

# values to store within HA
variable:
test_timer_countdown:
value: 0
attributes:
icon: mdi:timer
# dummy device value to turn on and off
test_timer_device:
value: 'OFF'
attributes:
icon: mdi:flash
input_number:
test_timer_duration:
name: "Duration"
unit_of_measurement: seconds
initial: 3
min: 1
max: 15
step: 1
icon: mdi:camera-timer
script:
start_test_timer:
sequence:
- service: variable.set_variable
data:
variable: test_timer_countdown
value_template: '{{ states.input_number.test_timer_duration.state | int }}'
- service: variable.set_variable
data:
variable: test_timer_device
value: 'ON'
- service: automation.turn_on
data:
entity_id: automation.test_timer_countdown
- service: automation.turn_on
data:
entity_id: automation.test_timer_zero_trigger
abort_test_timer:
sequence:
- service: automation.turn_off
data:
entity_id: automation.test_timer_countdown
- service: automation.turn_off
data:
entity_id: automation.test_timer_zero_trigger
- service: variable.set_variable
data:
variable: test_timer_device
value: 'OFF'
- service: persistent_notification.create
data:
message: "Timer was Aborted"
title: "ALERT"
#
automation:
- alias: test_timer_zero_trigger
initial_state: false
trigger:
platform: numeric_state
entity_id: variable.test_timer_countdown
below: 1
action:
- service: automation.turn_off
entity_id: automation.test_timer_countdown
- service: variable.set_variable
data:
variable: test_timer_device
value: 'OFF'
#
- alias: test_timer_countdown
initial_state: false
trigger:
platform: time_pattern
seconds: '/1'
action:
- service: variable.set_variable
data:
variable: test_timer_countdown
value_template: '{{ [((variable.state | int) - 1), 0] | max }}'
# lovelace ui view for timer, copy into ui-lovelace.yaml as a view (lovelace in yaml mode)
# - title: Timer
# cards:
# - type: vertical-stack
# cards:
# - type: horizontal-stack
# cards:
# - type: entity-button
# name: start timer countdown
# icon: mdi:timer
# tap_action:
# action: call-service
# service: script.turn_on
# service_data:
# entity_id: script.start_test_timer
# entity: script.start_test_timer
# - type: entity-button
# name: abort timer
# icon: mdi:timer-off
# tap_action:
# action: call-service
# service: script.turn_on
# service_data:
# entity_id: script.abort_test_timer
# entity: script.abort_test_timer
# - type: entities
# entities:
# - entity: variable.test_timer_countdown
# - entity: variable.test_timer_device
# name: dummy device
# - entity: input_number.test_timer_duration