Skip to content

Commit

Permalink
Update more speech logic to use OpenAI. #1368
Browse files Browse the repository at this point in the history
  • Loading branch information
CCOSTAN committed May 25, 2024
1 parent 1ce3d22 commit 12104c2
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 232 deletions.
28 changes: 2 additions & 26 deletions config/automation/Speech/announcements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,9 @@
{%- macro greeting_sentence(person, is_are) -%}
{{ [
"Welcome back home " ~ person,
"You had me at hello " ~ person,
"Guess who is home?" ~ person ~ is_are ,
"The wifi just got a little more crowded. Welcome Home" ~ person,
person ~ is_are + " now in the house.",
"Welcome Home " ~ person + ". We have missed you. Or at least Molly did.",
"Our home is now complete, Rest your head and relax your feet! Welcome Back " ~ person,
"Life is like a song, you’re back where you belong. Welcome home " ~ person,
"Hey there " ~ person + " Welcome Home!",
"Knock Knock. Who is There? " ~ person ~ is_are ,
"The garage door opener just told me that " ~ person ~ is_are +" home.",
person + " can not hide from the system. Welcome home.",
person ~ "! You are home!",
"I know a secret! " ~ person ~ is_are +" home!",
"Hey " ~ person +". Your arrival has been recorded by the Smartest house on the block.",
"Take note Molly! " ~ person ~ is_are +" home.",
"I am sensing a disturbance in the force. " ~ person +" must be home!",
"And the house becomes a home. Welcome back " ~ person,
person ~ is_are + " now here. Hash tag Welcome Home.",
person ~ is_are + " now here. Hash tag Home.",
person ~ is_are + " now here. Hash tag Smart Home.",
"Just a quick announcement. " ~ person +" has arrived!",
"Hey" ~ person + "! High Five! Glad you are finally home.",
"Pardon the interruption but " ~ person ~ is_are +" home!",
"My systems are picking up the presence of additional humans. " ~ person ~ is_are +" being identified as home.",
"Welcome home "~person + "! It is nice to see you again! Let me turn on the lights. ",
"It looks like "~person ~ is_are + " finally home! I will get the house ready for you. "
person ~ is_are + " home now."
] | random }}
[Welcome them home in a random style]
{%- endmacro -%}
{{greeting_sentence(person, is_are)}}
Expand Down
9 changes: 2 additions & 7 deletions config/automation/Speech/guest_mode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
- input_boolean.guest_mode
- service: script.speech_engine
data:
value1: >
{{ [
"Guest Mode has been disabled and normal automations will continue.",
"Let me disable guest mode since there are no longer any guests in the house. ",
"I have disabled guest mode and have resumed normal operations! ",
"Disabling guest mode! "
] | random }}
value1: >-
Guest Mode has been disabled and normal automations will continue.
call_no_announcement: 1
5 changes: 0 additions & 5 deletions config/automation/Speech/nest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
- sensor.upstairs_thermostat_hvac_state
from: 'off'

# condition:
# - condition: template
# value_template: >-
# {{ as_timestamp(states.automation.nest_status.attributes.last_triggered) > as_timestamp(now()) - (1800) }}

action:
- service: script.speech_engine
data:
Expand Down
2 changes: 1 addition & 1 deletion config/automation/dark_rainy_day.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

- service: script.speech_engine
data:
value1: "It is getting a little dark inside the house because of the {{trigger.entity_id.split('_')[2]|replace('precip','rain')|replace('counter','lightning')|replace('carlo','rain') }} {{trigger.entity_id.split('_')[3]|replace('intensity',' ')| replace('carlo','and clouds')}} outside. I will turn on some extra lights in the living room."
value1: "Because of the {{trigger.entity_id.split('_')[2]|replace('precip','rain')|replace('counter','lightning')|replace('carlo','rain') }} {{trigger.entity_id.split('_')[3]|replace('intensity',' ')| replace('carlo','and clouds')}} outside. I will turn on some extra lights in the living room."
call_window_check: 1
call_garage_check: 1

Expand Down
1 change: 1 addition & 0 deletions config/logger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ logs:
homeassistant.components.http: warn
homeassistant.components.ipp: critical
homeassistant.components.media_player: info
homeassistant.components.mqtt.discovery: critical
homeassistant.components.rest.sensor: critical
homeassistant.components.recorder: error
homeassistant.components.sensor.pi_hole: critical
Expand Down
17 changes: 3 additions & 14 deletions config/packages/alarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,8 @@ automation:
value1: >-
{% set opening = state_attr(trigger.entity_id, "friendly_name")%}
{%- macro opening_sentence(opening) -%}
{{ [
"The " ~ opening +" has been opened for about 5 minutes. I will shut down the Air Conditioner so you can enjoy the fresh air.",
"Since the " ~ opening +" is still open, I will turn off the air conditioners until you close it",
"The " ~ opening +" has been left open, I will turn off the AC to save some money for you.",
"We cant have the Air Conditioning running AND have " ~ opening +" open so I will turn off the AC.",
"Since running the AC while " ~ opening +" is open, I will turn off the Air Conditioner.",
"Once the " ~ opening +" is closed, I will turn the Air Conditioner back on",
"So we dont waste money, I will turn off the AC until " ~ opening +" has been closed.",
"The " ~ opening +" is open and we are cooling the outside. I will fix that by turning off the AC for now.",
"The fresh Air from the " ~ opening +" is great so I will turn off the AC until it is closed again.",
"When Doors and windows are left open like the " ~ opening +", I will remember to turn off the AC."
] | random }}
{{"Since the " ~ opening +" has been left open, I will turn off the air conditioners until you close it" }}
[Give a snarky reason for this action]
{%- endmacro -%}
{{opening_sentence(opening)}}
call_outside_weather: 1
Expand All @@ -294,10 +284,9 @@ automation:
value_template: "{{ states('climate.downstairs') == 'off' }}"

action:
- service: climate.set_hvac_mode
- service: climate.turn_on
data:
entity_id: climate.downstairs
hvac_mode: 'auto'

#-------------------------------------------#-------------------------------------------
- alias: 'Alarm lights in Living room'
Expand Down
27 changes: 7 additions & 20 deletions config/packages/garadget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ automation:
conditions:
- condition: state
entity_id: cover.large_garage_door
state: 'opened'
state: 'open'
- condition: state
entity_id: cover.small_garage_door
state: 'opened'
state: 'open'

action:
- service: input_boolean.turn_on
Expand All @@ -264,19 +264,6 @@ automation:
{%- endif %} The small Garage Door is open.
{% endif %}"
- service: script.tweet_engine_image
data:
tweet: >
{{ [
"Wind speed is {{ states('sensor.pirateweather_wind_speed')|round}} miles per hour. For safety, I'm going to close the @garadget doors.",
"Getting pretty windy! {{ states('sensor.pirateweather_wind_speed')|round}}MPH. Time to ask @Garadget to close the garage doors."
] | random + "(https://amzn.to/2jQLpVQ)"}}
image: >-
{{ [
"/config/www/custom_ui/floorplan/images/branding/windy.png"
] | random }}
##############################################################################

- alias: Is the Garage door Open at night - Checks every 30 minutes or 5 minutes after we drive away.
Expand Down Expand Up @@ -306,9 +293,9 @@ automation:
- condition: or
conditions:
- condition: template
value_template: "{{ states('cover.large_garage_door') == 'opened' }}"
value_template: "{{ states('cover.large_garage_door') == 'open' }}"
- condition: template
value_template: "{{ states('cover.small_garage_door') == 'opened' }}"
value_template: "{{ states('cover.small_garage_door') == 'open' }}"
- condition: and
conditions:
- condition: state
Expand All @@ -317,9 +304,9 @@ automation:
- condition: or
conditions:
- condition: template
value_template: "{{ states('cover.large_garage_door') == 'opened' }}"
value_template: "{{ states('cover.large_garage_door') == 'open' }}"
- condition: template
value_template: "{{ states('cover.small_garage_door') == 'opened'}}"
value_template: "{{ states('cover.small_garage_door') == 'open'}}"

action:
- service: script.notify_engine
Expand All @@ -333,5 +320,5 @@ automation:

- service: script.speech_engine
data:
value1: "Please check the garage doors. The Small garage is {{ states('cover.small_garage_door')}} and the large garage is {{ states('cover.large_garage_door')}}"
value1: "Please check the garage doors. The Small garage is {{ states('cover.small_garage_door')}} and the large garage is {{ states('cover.large_garage_door')}} [Only mention the garage door that is open]"

1 change: 0 additions & 1 deletion config/packages/neato.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ automation:
{{ [
"Neato is asking for help. The error reported is " ~ error + " . Please find him and help him.",
"Please be nice and help Neato. He is complaining about " ~ error + ".",
"If you don't want to vacuum, you need to help Neato. He is complaining about " ~ error +" and needs help.",
"Something is wrong with Neato. Please find him and help him. I have detected a " ~ error + " error."
] | random }}
Expand Down
4 changes: 1 addition & 3 deletions config/packages/phynplus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ automation:
- service: script.speech_engine
data:
value1: >
{{ [
"I have been asked to Turn the House Water back on. Please verify there are no leaks in the house. "
] | random }}
I have been asked to Turn the House Water back on. Please verify there are no leaks in the house.
call_no_announcement: 1
4 changes: 2 additions & 2 deletions config/packages/rheem_econet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ automation:
group: 'information'
- service: script.speech_engine
data:
value1: "Please be aware that the hot water has dropped below 30% availability. Please consider taking a shower at another time."
value1: "Please be aware that the hot water has dropped below 30% availability. Please consider taking a shower at another time. Gallons used today: {{sensor.phyn_daily_water_usage}}"

- wait_template: "{{ states('sensor.rheem_wh_available_hot_water')|float > 50 }}"
timeout: '01:00:00' # Adjust timeout as needed
- service: script.speech_engine
data:
value1: "The available hot water is now above 50%. Normal showering can resume."
value1: "The available hot water is now above 50%. Normal showering can resume. Gallons used today: {{sensor.phyn_daily_water_usage}}"



Expand Down
3 changes: 2 additions & 1 deletion config/script/speech_processing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ speech_processing:
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:
Take the following system generated information and review and relay the information as yourself.
Here is the information:
{{ speech_message }}
response_variable: agent

Expand Down
Loading

0 comments on commit 12104c2

Please sign in to comment.