383 lines
14 KiB
YAML
383 lines
14 KiB
YAML
################################################################################
|
|
# PACKAGE: View Road Announcement Router
|
|
################################################################################
|
|
#
|
|
# Version: 1.2
|
|
# Date: 2026-05-06
|
|
#
|
|
# Purpose:
|
|
# Central announcement router for general Home Assistant announcements.
|
|
# Other scripts and automations can call script.view_road_announcement and pass
|
|
# values such as channels, title, short_announcement, long_announcement,
|
|
# payload, and indicator.
|
|
#
|
|
# Changes:
|
|
# 1.2:
|
|
# - Updated Lounge Google Home voice channel to use working Piper TTS setup.
|
|
# - Added Piper voice option en_GB-alba-medium.
|
|
# - Removed separate TTS language option from the voice channel.
|
|
#
|
|
# 1.1:
|
|
# - Removed old YAML Pushover notify service setup.
|
|
# - Uses existing Pushover integration notify entities.
|
|
# - Added quiet time channel blocking.
|
|
# - Added Lounge Google Home voice announcement channel.
|
|
#
|
|
# Notes:
|
|
# - Use input_boolean helpers for channel enable/disable control.
|
|
# - Binary sensors are read-only, so input_boolean is the correct helper type.
|
|
# - Channels with no action block yet intentionally do nothing.
|
|
#
|
|
################################################################################
|
|
|
|
################################################################################
|
|
# PUSHOVER NOTIFY SERVICES
|
|
################################################################################
|
|
#
|
|
# Pushover is configured using the Home Assistant Pushover integration.
|
|
#
|
|
# Expected notify entities:
|
|
#
|
|
# notify.pushover_zorruno
|
|
# notify.pushover_kim
|
|
#
|
|
# No YAML notify: block is needed in this package.
|
|
#
|
|
################################################################################
|
|
|
|
################################################################################
|
|
# CHANNEL ENABLE HELPERS
|
|
################################################################################
|
|
|
|
input_boolean:
|
|
announcement_channel_pushover_zorruno:
|
|
name: Announcement Channel - Pushover Zorruno
|
|
icon: mdi:cellphone-message
|
|
initial: true
|
|
|
|
announcement_channel_pushover_kim:
|
|
name: Announcement Channel - Pushover Kim
|
|
icon: mdi:cellphone-message
|
|
initial: true
|
|
|
|
announcement_channel_sony_tv_lounge:
|
|
name: Announcement Channel - Sony TV Lounge
|
|
icon: mdi:television
|
|
initial: true
|
|
|
|
announcement_channel_lounge_google_home_voice:
|
|
name: Announcement Channel - Lounge Google Home Voice
|
|
icon: mdi:speaker
|
|
initial: true
|
|
|
|
announcement_channel_lounge_touchscreen_voice:
|
|
name: Announcement Channel - Lounge Touchscreen Voice
|
|
icon: mdi:tablet-dashboard
|
|
initial: true
|
|
|
|
announcement_channel_mqtt_view_rd_feed:
|
|
name: Announcement Channel - MQTT View Rd Feed
|
|
icon: mdi:message-processing
|
|
initial: true
|
|
|
|
################################################################################
|
|
# MAIN ANNOUNCEMENT ROUTER SCRIPT
|
|
################################################################################
|
|
|
|
script:
|
|
view_road_announcement:
|
|
alias: View Road Announcement
|
|
icon: mdi:bullhorn
|
|
mode: parallel
|
|
max: 20
|
|
|
|
fields:
|
|
channels:
|
|
name: Channels
|
|
description: Comma separated list of announcement channels to use.
|
|
example: "pushover_zorruno, sony_tv_lounge"
|
|
selector:
|
|
text:
|
|
|
|
title:
|
|
name: Title
|
|
description: Announcement title.
|
|
example: "View Road"
|
|
selector:
|
|
text:
|
|
|
|
short_announcement:
|
|
name: Short Announcement
|
|
description: Short announcement text.
|
|
example: "Garage door"
|
|
selector:
|
|
text:
|
|
|
|
long_announcement:
|
|
name: Long Announcement
|
|
description: Longer announcement text.
|
|
example: "The garage door has been opened."
|
|
selector:
|
|
text:
|
|
multiline: true
|
|
|
|
payload:
|
|
name: Payload
|
|
description: Payload value such as On, Off, Open, Closed, etc.
|
|
example: "Open"
|
|
selector:
|
|
text:
|
|
|
|
indicator:
|
|
name: Indicator
|
|
description: Future indicator data such as LED number, colour, or flash pattern.
|
|
example: "red, led 2, flash fast"
|
|
selector:
|
|
text:
|
|
|
|
sequence:
|
|
##########################################################################
|
|
# DEFAULT VALUES
|
|
##########################################################################
|
|
#
|
|
# If a value is not passed, the default below is used.
|
|
# If a value is passed as "", it clears the default to blank.
|
|
#
|
|
# quiet_time_blocked_channels:
|
|
# Channels in this list will not run while input_boolean.quiet_time is on.
|
|
#
|
|
##########################################################################
|
|
|
|
- variables:
|
|
default_channels: "pushover_zorruno, pushover_kim, sony_tv_lounge, lounge_google_home_voice, lounge_touchscreen_voice, mqtt_view_rd_feed"
|
|
default_title: "View Road"
|
|
default_short_announcement: "Home automation announcement"
|
|
default_long_announcement: "Home automation announcement"
|
|
default_payload: ""
|
|
default_indicator: ""
|
|
|
|
quiet_time_blocked_channels:
|
|
- "google_home_voice"
|
|
- "lounge_google_home_voice"
|
|
- "lounge_touchscreen_voice"
|
|
|
|
lounge_google_home_voice_media_player: "media_player.lounge_google_tichome_speaker"
|
|
lounge_google_home_voice_tts_entity: "tts.piper"
|
|
lounge_google_home_voice_piper_voice: "en_GB-jenny_dioco-medium"
|
|
lounge_google_home_voice_volume_level: 0.80
|
|
|
|
##########################################################################
|
|
# RESOLVE PASSED VALUES
|
|
##########################################################################
|
|
|
|
- variables:
|
|
ann_channels_raw: >-
|
|
{% if channels is defined %}
|
|
{{ channels }}
|
|
{% elif channel is defined %}
|
|
{{ channel }}
|
|
{% elif Channel is defined %}
|
|
{{ Channel }}
|
|
{% else %}
|
|
{{ default_channels }}
|
|
{% endif %}
|
|
|
|
ann_title: >-
|
|
{% if title is defined %}
|
|
{{ title }}
|
|
{% elif Title is defined %}
|
|
{{ Title }}
|
|
{% else %}
|
|
{{ default_title }}
|
|
{% endif %}
|
|
|
|
ann_short_announcement: >-
|
|
{% if short_announcement is defined %}
|
|
{{ short_announcement }}
|
|
{% elif Short_Announcement is defined %}
|
|
{{ Short_Announcement }}
|
|
{% else %}
|
|
{{ default_short_announcement }}
|
|
{% endif %}
|
|
|
|
ann_long_announcement: >-
|
|
{% if long_announcement is defined %}
|
|
{{ long_announcement }}
|
|
{% elif Long_Announcement is defined %}
|
|
{{ Long_Announcement }}
|
|
{% else %}
|
|
{{ default_long_announcement }}
|
|
{% endif %}
|
|
|
|
ann_payload: >-
|
|
{% if payload is defined %}
|
|
{{ payload }}
|
|
{% elif Payload is defined %}
|
|
{{ Payload }}
|
|
{% else %}
|
|
{{ default_payload }}
|
|
{% endif %}
|
|
|
|
ann_indicator: >-
|
|
{% if indicator is defined %}
|
|
{{ indicator }}
|
|
{% elif Indicator is defined %}
|
|
{{ Indicator }}
|
|
{% else %}
|
|
{{ default_indicator }}
|
|
{% endif %}
|
|
|
|
##########################################################################
|
|
# NORMALISE CHANNEL LISTS AND MESSAGE TEXT
|
|
##########################################################################
|
|
|
|
- variables:
|
|
ann_channels_normalised: >-
|
|
{{ ',' ~ (ann_channels_raw | string | lower | replace(' ', '') | replace('\n', '') | trim(',')) ~ ',' }}
|
|
|
|
ann_quiet_time_blocked_channels_normalised: >-
|
|
{{ ',' ~ (quiet_time_blocked_channels | join(',') | lower | replace(' ', '') | replace('\n', '') | trim(',')) ~ ',' }}
|
|
|
|
ann_sony_tv_message: >-
|
|
{% set short_text = ann_short_announcement | string | trim %}
|
|
{% set payload_text = ann_payload | string | trim %}
|
|
{% if short_text | length > 0 and payload_text | length > 0 %}
|
|
{{ short_text }} is {{ payload_text }}
|
|
{% elif short_text | length > 0 %}
|
|
{{ short_text }}
|
|
{% else %}
|
|
{{ payload_text }}
|
|
{% endif %}
|
|
|
|
ann_voice_message: >-
|
|
{% set long_text = ann_long_announcement | string | trim %}
|
|
{% set short_text = ann_short_announcement | string | trim %}
|
|
{% set payload_text = ann_payload | string | trim %}
|
|
{% if long_text | length > 0 %}
|
|
{{ long_text }}
|
|
{% elif short_text | length > 0 and payload_text | length > 0 %}
|
|
{{ short_text }} is {{ payload_text }}
|
|
{% elif short_text | length > 0 %}
|
|
{{ short_text }}
|
|
{% else %}
|
|
{{ payload_text }}
|
|
{% endif %}
|
|
|
|
##########################################################################
|
|
# CHANNEL: PUSHOVER ZORRUNO
|
|
##########################################################################
|
|
|
|
- if:
|
|
- condition: template
|
|
value_template: "{{ ',pushover_zorruno,' in ann_channels_normalised }}"
|
|
- condition: state
|
|
entity_id: input_boolean.announcement_channel_pushover_zorruno
|
|
state: "on"
|
|
then:
|
|
- action: notify.pushover_zorruno
|
|
data:
|
|
title: "{{ ann_title }}"
|
|
message: "{{ ann_long_announcement }}"
|
|
|
|
##########################################################################
|
|
# CHANNEL: PUSHOVER KIM
|
|
##########################################################################
|
|
|
|
- if:
|
|
- condition: template
|
|
value_template: "{{ ',pushover_kim,' in ann_channels_normalised }}"
|
|
- condition: state
|
|
entity_id: input_boolean.announcement_channel_pushover_kim
|
|
state: "on"
|
|
then:
|
|
- action: notify.pushover_kim
|
|
data:
|
|
title: "{{ ann_title }}"
|
|
message: "{{ ann_long_announcement }}"
|
|
|
|
##########################################################################
|
|
# CHANNEL: SONY TV LOUNGE
|
|
##########################################################################
|
|
|
|
- if:
|
|
- condition: template
|
|
value_template: "{{ ',sony_tv_lounge,' in ann_channels_normalised }}"
|
|
- condition: state
|
|
entity_id: input_boolean.announcement_channel_sony_tv_lounge
|
|
state: "on"
|
|
then:
|
|
- action: notify.sony_android_tv_lounge
|
|
data:
|
|
title: "{{ ann_title }}"
|
|
message: "{{ ann_sony_tv_message }}"
|
|
|
|
##########################################################################
|
|
# CHANNEL: LOUNGE GOOGLE HOME VOICE
|
|
##########################################################################
|
|
#
|
|
# Also accepts google_home_voice as an alias channel name.
|
|
#
|
|
# This channel is blocked during quiet time by default.
|
|
#
|
|
##########################################################################
|
|
|
|
- if:
|
|
- condition: template
|
|
value_template: >-
|
|
{{
|
|
',lounge_google_home_voice,' in ann_channels_normalised
|
|
or ',google_home_voice,' in ann_channels_normalised
|
|
}}
|
|
- condition: state
|
|
entity_id: input_boolean.announcement_channel_lounge_google_home_voice
|
|
state: "on"
|
|
- condition: template
|
|
value_template: >-
|
|
{{ not (
|
|
is_state('input_boolean.quiet_time', 'on')
|
|
and (
|
|
',lounge_google_home_voice,' in ann_quiet_time_blocked_channels_normalised
|
|
or ',google_home_voice,' in ann_quiet_time_blocked_channels_normalised
|
|
)
|
|
) }}
|
|
- condition: template
|
|
value_template: "{{ ann_voice_message | string | trim | length > 0 }}"
|
|
then:
|
|
- action: media_player.volume_set
|
|
data:
|
|
entity_id: "{{ lounge_google_home_voice_media_player }}"
|
|
volume_level: "{{ lounge_google_home_voice_volume_level | float(0.8) }}"
|
|
|
|
- delay:
|
|
seconds: 1
|
|
|
|
- action: tts.speak
|
|
target:
|
|
entity_id: "{{ lounge_google_home_voice_tts_entity }}"
|
|
data:
|
|
cache: false
|
|
media_player_entity_id: "{{ lounge_google_home_voice_media_player }}"
|
|
message: "{{ ann_voice_message }}"
|
|
options:
|
|
voice: "{{ lounge_google_home_voice_piper_voice }}"
|
|
preferred_format: mp3
|
|
preferred_sample_rate: 44100
|
|
|
|
##########################################################################
|
|
# CHANNEL: LOUNGE TOUCHSCREEN VOICE
|
|
##########################################################################
|
|
#
|
|
# Placeholder only. No action yet.
|
|
#
|
|
# This channel is listed in quiet_time_blocked_channels for future use.
|
|
#
|
|
##########################################################################
|
|
|
|
##########################################################################
|
|
# CHANNEL: MQTT VIEW RD FEED
|
|
##########################################################################
|
|
#
|
|
# Placeholder only. No action yet.
|
|
#
|
|
##########################################################################
|