2026-04-30 11:57:39 -04:00
|
|
|
######################################################################
|
|
|
|
|
# @CCOSTAN - Follow Me on X
|
|
|
|
|
# For more info visit https://www.vcloudinfo.com/click-here
|
|
|
|
|
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
|
# Speech Processing Script - shared spoken announcement delivery
|
|
|
|
|
# Sends OpenAI-polished speech to Chromecast targets and routed Echo announcements.
|
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
|
# Related Issue: 798
|
|
|
|
|
# Notes: Operates only when family/guest/vacation and speech notification
|
|
|
|
|
# guards allow it, with time-aware volume.
|
2026-05-03 15:52:51 -04:00
|
|
|
# Notes: Set `speech_direct: true` for exact visitor-facing announcements that should not be rewritten by the LLM.
|
2026-04-30 11:57:39 -04:00
|
|
|
# Notes: Garage Echo is an always-on announcement target. Office Echo is
|
|
|
|
|
# added when switch.office_lamp_switch is on, which tracks active PC work.
|
|
|
|
|
######################################################################
|
2018-01-01 19:00:45 -05:00
|
|
|
|
|
|
|
|
speech_processing:
|
2020-08-02 12:20:08 -04:00
|
|
|
mode: queued
|
2018-01-01 19:00:45 -05:00
|
|
|
sequence:
|
|
|
|
|
|
2024-07-24 05:48:36 +00:00
|
|
|
- event: openai_instructions_sent
|
|
|
|
|
event_data:
|
|
|
|
|
instructions: "{{ speech_message | striptags }}"
|
2026-05-03 15:52:51 -04:00
|
|
|
|
|
|
|
|
- variables:
|
|
|
|
|
direct_speech: "{{ speech_direct | default(false) | bool }}"
|
|
|
|
|
routed_media_players: "{{ media_player | string | lower }}"
|
|
|
|
|
speech_response: "{{ speech_message | striptags | trim }}"
|
2024-07-24 05:48:36 +00:00
|
|
|
|
2018-01-01 19:00:45 -05:00
|
|
|
- condition: and
|
|
|
|
|
conditions:
|
|
|
|
|
- condition: or
|
|
|
|
|
conditions:
|
|
|
|
|
- condition: state
|
|
|
|
|
entity_id: group.family
|
|
|
|
|
state: 'home'
|
|
|
|
|
- condition: state
|
|
|
|
|
entity_id: input_boolean.guest_mode
|
|
|
|
|
state: 'on'
|
2026-03-23 10:11:56 -04:00
|
|
|
- condition: state
|
|
|
|
|
entity_id: input_boolean.vacation_mode
|
|
|
|
|
state: 'on'
|
2018-01-01 19:00:45 -05:00
|
|
|
- condition: or
|
|
|
|
|
conditions:
|
|
|
|
|
- condition: and
|
|
|
|
|
conditions:
|
|
|
|
|
- condition: state
|
|
|
|
|
entity_id: group.bed
|
|
|
|
|
state: 'off'
|
|
|
|
|
- condition: time
|
|
|
|
|
after: '08:00:00'
|
2024-09-25 15:51:00 +00:00
|
|
|
before: '22:00:00'
|
2018-01-01 19:00:45 -05:00
|
|
|
- condition: state
|
|
|
|
|
entity_id: input_boolean.alert_mode
|
|
|
|
|
state: 'on'
|
|
|
|
|
- condition: state
|
|
|
|
|
entity_id: input_boolean.speech_notifications
|
|
|
|
|
state: 'on'
|
|
|
|
|
|
|
|
|
|
- service: switch.turn_on
|
2019-03-20 18:03:58 -04:00
|
|
|
entity_id: switch.lr_amp
|
2018-01-12 13:01:51 -05:00
|
|
|
|
2018-01-01 19:00:45 -05:00
|
|
|
- service: media_player.volume_set
|
2020-09-26 10:52:45 -04:00
|
|
|
data:
|
2022-06-23 13:13:36 -04:00
|
|
|
entity_id: >
|
|
|
|
|
{{ media_player }}
|
2018-01-01 19:00:45 -05:00
|
|
|
volume_level: >-
|
|
|
|
|
{% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %}
|
2024-05-24 14:07:49 +00:00
|
|
|
0.2
|
2018-01-01 19:00:45 -05:00
|
|
|
{% elif now().strftime('%H')|int > 12 and now().strftime('%H')|int < 20 %}
|
2024-05-21 19:55:44 +00:00
|
|
|
0.3
|
2018-01-01 19:00:45 -05:00
|
|
|
{% else %}
|
2024-05-24 14:07:49 +00:00
|
|
|
0.2
|
2018-01-01 19:00:45 -05:00
|
|
|
{% endif %}
|
|
|
|
|
|
2026-05-03 15:52:51 -04:00
|
|
|
- choose:
|
|
|
|
|
- conditions:
|
|
|
|
|
- condition: template
|
|
|
|
|
value_template: "{{ not direct_speech }}"
|
|
|
|
|
sequence:
|
|
|
|
|
- service: conversation.process
|
|
|
|
|
data:
|
|
|
|
|
agent_id: conversation.openai_conversation
|
|
|
|
|
text: >-
|
|
|
|
|
{{ speech_message }}
|
|
|
|
|
response_variable: agent
|
2024-05-24 14:07:49 +00:00
|
|
|
|
2026-05-03 15:52:51 -04:00
|
|
|
- variables:
|
|
|
|
|
speech_response: "{{ agent.response.speech.plain.speech }}"
|
2026-04-30 11:57:39 -04:00
|
|
|
|
2024-05-21 19:55:44 +00:00
|
|
|
- service: tts.cloud_say
|
2020-09-26 10:52:45 -04:00
|
|
|
data:
|
2026-04-30 11:57:39 -04:00
|
|
|
entity_id: >
|
|
|
|
|
{{ media_player }}
|
2024-05-21 19:55:44 +00:00
|
|
|
options:
|
|
|
|
|
voice: JennyNeural
|
2018-01-01 19:00:45 -05:00
|
|
|
message: >-
|
2026-04-30 11:57:39 -04:00
|
|
|
{{ speech_response }}
|
2025-03-04 18:17:35 +00:00
|
|
|
cache: false
|
2018-01-01 19:00:45 -05:00
|
|
|
|
2026-04-30 11:57:39 -04:00
|
|
|
- choose:
|
|
|
|
|
- conditions:
|
|
|
|
|
- condition: template
|
|
|
|
|
value_template: "{{ 'media_player.garage' not in routed_media_players }}"
|
|
|
|
|
sequence:
|
|
|
|
|
- service: notify.alexa_media_garage
|
|
|
|
|
continue_on_error: true
|
|
|
|
|
data:
|
|
|
|
|
message: "{{ speech_response }}"
|
|
|
|
|
data:
|
|
|
|
|
type: announce
|
|
|
|
|
|
|
|
|
|
- choose:
|
|
|
|
|
- conditions:
|
|
|
|
|
- condition: state
|
|
|
|
|
entity_id: switch.office_lamp_switch
|
|
|
|
|
state: 'on'
|
|
|
|
|
- condition: template
|
|
|
|
|
value_template: "{{ 'media_player.office' not in routed_media_players }}"
|
|
|
|
|
sequence:
|
|
|
|
|
- service: notify.alexa_media_office
|
|
|
|
|
continue_on_error: true
|
|
|
|
|
data:
|
|
|
|
|
message: "{{ speech_response }}"
|
|
|
|
|
data:
|
|
|
|
|
type: announce
|
|
|
|
|
|
2024-07-26 13:58:13 +00:00
|
|
|
- event: openai_response
|
2024-07-24 05:48:36 +00:00
|
|
|
event_data:
|
2026-04-30 11:57:39 -04:00
|
|
|
response: "{{ now().strftime('%B %d,%Y %-I:%M %p') }} {{ speech_response }}"
|
2024-05-24 14:07:49 +00:00
|
|
|
|
2018-01-01 19:00:45 -05:00
|
|
|
- service: input_boolean.turn_off
|
|
|
|
|
data:
|
|
|
|
|
entity_id:
|
|
|
|
|
- input_boolean.alert_mode
|
|
|
|
|
- input_boolean.lastmsg
|