Files
zorruno-homeassistant/packages/quiet_time_on_off_actions.yaml
T
2026-09-13 15:32:16 +12:00

126 lines
4.6 KiB
YAML

################################################################################
# Quiet Time On / Off Actions Package
################################################################################
#
# TITLE:
# Quiet Time On / Off Actions
#
# FILE:
# quiet_time_on_off_actions.yaml
#
# VERSION:
# V1.3 2026-09-04
#
# PURPOSE:
# Runs local Home Assistant actions when Quiet Time is turned ON or OFF.
#
# The main Quiet Time package owns the helper, daily reset behaviour, and MQTT
# publishing. This package owns extra local Quiet Time actions.
#
# VERSION HISTORY:
# V1.3 2026-09-04
# - Disables Flounder Motion Wake during Quiet Time and requests a one-off
# 10-second presence fade to Screen Off.
# - Restores Flounder Motion Wake when Quiet Time ends.
#
# V1.2 2026-06-20
# - Added Quiet Time OFF action to change OpenHASP panel openhasp_1 back to
# page 1.
#
################################################################################
# AUTOMATIONS
################################################################################
automation:
- id: quiet_time_state_change_actions
alias: "Quiet Time - State Change Actions"
description: "Runs configured Home Assistant actions when Quiet Time is turned on or off."
mode: single
variables:
quiet_time_on_turn_off_entities:
- light.led_matrix_display_led_matrix_display_display
quiet_time_on_turn_on_entities: []
quiet_time_off_turn_off_entities: []
quiet_time_off_turn_on_entities:
- light.led_matrix_display_led_matrix_display_display
quiet_time_off_input_number_values:
- entity_id: input_number.openhasp_1_backlight_level
value: 200
quiet_time_off_openhasp_page_topic: "hasp/openhasp_1/command/page"
quiet_time_off_openhasp_page: 1
triggers:
- trigger: state
entity_id: input_boolean.quiet_time
from:
- "on"
- "off"
to:
- "on"
- "off"
actions:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
sequence:
- repeat:
for_each: "{{ quiet_time_on_turn_off_entities }}"
sequence:
- action: homeassistant.turn_off
target:
entity_id: "{{ repeat.item }}"
- repeat:
for_each: "{{ quiet_time_on_turn_on_entities }}"
sequence:
- action: homeassistant.turn_on
target:
entity_id: "{{ repeat.item }}"
# Stop camera motion from extending presence, then fade the
# current session to the existing Screen Off base state.
- action: switch.turn_off
target:
entity_id: switch.flounder_kiosk_motion_wake
- wait_template: "{{ is_state('switch.flounder_kiosk_motion_wake', 'off') }}"
timeout: "00:00:10"
continue_on_timeout: true
- action: mqtt.publish
data:
topic: "viewroad-commands/flounder/presence/end"
payload: "10"
retain: false
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'off' }}"
sequence:
- repeat:
for_each: "{{ quiet_time_off_turn_off_entities }}"
sequence:
- action: homeassistant.turn_off
target:
entity_id: "{{ repeat.item }}"
- repeat:
for_each: "{{ quiet_time_off_turn_on_entities }}"
sequence:
- action: homeassistant.turn_on
target:
entity_id: "{{ repeat.item }}"
- action: switch.turn_on
target:
entity_id: switch.flounder_kiosk_motion_wake
- repeat:
for_each: "{{ quiet_time_off_input_number_values }}"
sequence:
- action: input_number.set_value
target:
entity_id: "{{ repeat.item.entity_id }}"
data:
value: "{{ repeat.item.value | float }}"
- action: mqtt.publish
data:
topic: "{{ quiet_time_off_openhasp_page_topic }}"
payload: "{{ quiet_time_off_openhasp_page | int }}"
retain: false