diff --git a/config/automations.yaml b/config/automations.yaml old mode 100755 new mode 100644 diff --git a/config/group/MQTT.yaml b/config/group/MQTT.yaml index 6860e314..83bc77f1 100755 --- a/config/group/MQTT.yaml +++ b/config/group/MQTT.yaml @@ -2,3 +2,4 @@ MQTT: entities: - sensor.medicine_time - sensor.last_message + - sensor.last_ai_message diff --git a/config/packages/triggers/last_message.yaml b/config/packages/triggers/last_message.yaml index f597b769..0238a0d5 100755 --- a/config/packages/triggers/last_message.yaml +++ b/config/packages/triggers/last_message.yaml @@ -19,6 +19,9 @@ mqtt: sensor: - state_topic: "polly/lastmsg" name: "Last Message" + + - state_topic: "polly/lastmsg_openai" + name: "Last AI Message" ############################################################################## ### Automations - @@ -34,18 +37,19 @@ automation: to: 'on' action: - - service: tts.amazon_polly_say + - service: tts.cloud_say entity_id: - media_player.livingroomCC - media_player.entry_alarm_panel - media_player.bedroom_alarm_panel data: - message: > - - {{states.sensor.last_message.state}} - - cache: true + options: + voice: JennyNeural + message: >- + {{states.sensor.last_ai_message.state}} + cache: false - service: input_boolean.turn_off entity_id: - input_boolean.lastmsg + diff --git a/config/recorder.yaml b/config/recorder.yaml index 6dee079b..b28670e6 100755 --- a/config/recorder.yaml +++ b/config/recorder.yaml @@ -41,6 +41,7 @@ exclude: - sensor.ha_uptime - sensor.large_garage_door_since - sensor.last_message + - sensor.last_ai_message - sensor.low_battery - sensor.medicine_time - sensor.network diff --git a/config/script/speech_processing.yaml b/config/script/speech_processing.yaml index 4870173a..25b2eaec 100755 --- a/config/script/speech_processing.yaml +++ b/config/script/speech_processing.yaml @@ -14,7 +14,7 @@ speech_processing: - service: mqtt.publish data: topic: 'polly/lastmsg' - payload: "This message is from {{ now().strftime('%-I') }}:{{ now().strftime('%M') }} {{ now().strftime('%p') }}. {{ speech_message | striptags | truncate(220)}}" + payload: "Message: {{ now().strftime('%-I') }}:{{ now().strftime('%M') }} {{ now().strftime('%p') }}. {{ speech_message | striptags | truncate(220)}}" retain: true - condition: and @@ -53,11 +53,11 @@ speech_processing: {{ media_player }} volume_level: >- {% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %} - 0.3 + 0.2 {% elif now().strftime('%H')|int > 12 and now().strftime('%H')|int < 20 %} 0.3 {% else %} - 0.3 + 0.2 {% endif %} # - service: tts.amazon_polly_say @@ -71,15 +71,29 @@ speech_processing: # # cache: true + - service: conversation.process + data: + agent_id: conversation.openai_conversation + text: >- + Please take the following system generated information and review and relay the information as yourself. There should be no followups in your response since this is a broadcast only. Here is the information: + {{ speech_message }} + response_variable: agent + - service: tts.cloud_say data: entity_id: media_player.livingroomCC options: voice: JennyNeural message: >- - {{ speech_message }} + {{ agent.response.speech.plain.speech }} cache: true + - service: mqtt.publish + data: + topic: 'polly/lastmsg_openai' + payload: "Message: {{ now().strftime('%-I') }}:{{ now().strftime('%M') }} {{ now().strftime('%p') }}. {{ agent.response.speech.plain.speech | striptags | truncate(220)}}" + retain: true + - service: input_boolean.turn_off data: entity_id: