Files
Home-Assistant-Configs/packages/time.yaml
2023-09-27 15:52:29 -04:00

100 lines
2.2 KiB
YAML

input_boolean:
night_mode:
name: Night Mode
icon: mdi:lightbulb-night
goodnight:
name: Goodnight
icon: mdi:sleep
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'time_date'
- 'time_utc'
- 'beat'
intent_script:
SetTimer:
action:
service: timer.start
target:
entity_id: "{{ room }}"
data:
duration: >
{% if unit == 'hours' %}
{{ (time * 60) * 60 }}
{% elif unit == 'minutes' %}
{{ time * 60}}
{% elif unit == 'seconds' %}
{{ time }}
{% endif %}
speech:
text: "Okay"
CancelTimer:
action:
service: timer.cancel
target:
entity_id: "{{ room }}"
speech:
text: "Okay"
PauseTimer:
action:
service: timer.pause
target:
entity_id: "{{ room }}"
speech:
text: "Okay"
ResumeTimer:
action:
service: timer.start
target:
entity_id: "{{ room }}"
speech:
text: "Okay"
automation:
- id: 849b72f0-89e9-421b-9e75-01a6d977488d
alias: Timer Handling
description: This automation will handle when house timers (usually set by voice) are finished
mode: queued
max: 10
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.kitchen_timer
id: kitchen-finished
action:
- choose:
- conditions: "{{ trigger.id == 'kitchen-finished' }}"
sequence:
- service: script.speech_engine
data:
type: normal
who: common
message: "The timer for the kitchen is finished"
script:
timer_modify:
alias: Timer Modify
description: For adding/subtracting time from a running timer
mode: restart
sequence:
- service: timer.pause
target:
entity_id: "{{ timer }}"
- delay:
seconds: 1
- variables:
modify: >
{% set x = state_attr(timer, 'remaining') ~ '-0000' %}
{% set y = strptime(x, '%H:%M:%S%z') %}
{{ (as_timestamp(y) + change) | timestamp_custom('%H:%M:%S', false) }}
- service: timer.start
target:
entity_id: "{{ timer }}"
data:
duration: "{{ modify }}"