Lots of troubleshooting and stuff related to OpenAI #1368

This commit is contained in:
CCOSTAN 2024-07-24 05:48:36 +00:00
parent 6a1c81c0cb
commit ca3b3b3360
12 changed files with 5606 additions and 105 deletions

View File

@ -1 +1 @@
2024.8.0.dev202407020219
2024.8.0.dev202407200219

View File

@ -39,7 +39,7 @@
personarriving: >
{% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %}
{%- macro greeting_sentence(person) -%}
{{ ["[Welcome " ~ person + " home]"] }}
{{"[Welcome " + person + " home]" }}
{%- endmacro -%}
{{greeting_sentence(person)}}

View File

@ -113,7 +113,7 @@ group: !include_dir_merge_named group
sensor: !include_dir_merge_list sensor
automation: !include_dir_merge_list automation
scene: !include_dir_merge_list scene
switch: !include_dir_merge_list switch
# switch: !include_dir_merge_list switch
script: !include_dir_merge_named script
input_boolean: !include_dir_merge_named input_boolean
shell_command: !include_dir_merge_named shell_command

View File

@ -1,39 +0,0 @@
#-------------------------------------------
# @BrianHanifin's Light sensor speech helper. - https://gist.github.com/brianhanifin/1f9436c7b6c28917c9be02605b6cff74
#-------------------------------------------
#------LightSensor Node---http://amzn.to/2oUgj5i
homeassistant:
customize:
sensor.lights_on:
icon: mdi:sensor
friendly_name: Lights on
#emulated_hue_
#---Sensor for Light-----------------------------
sensor:
- platform: template
sensors:
lights_on:
value_template: >
{% macro get_lights_on() -%}
{%- for group in states.light|groupby('state') -%}
{%- for entity in group.list -%}
{%- if entity.state == 'on'
and entity.entity_id != 'light.dummy'
and entity.entity_id != 'light.garage_entry_light'
and entity.entity_id != 'light.hue'
and entity.entity_id != 'light.living_room'
and entity.entity_id != 'light.kitchen_undercabinet'
and entity.entity_id != 'light.porch_light'
and entity.entity_id != 'light.shoe_closet_light'
and not ('gateway_light' in entity.entity_id)
and not ('hub' in entity.entity_id)
and not (entity.entity_id).endswith('_led')
and not (entity.entity_id).endswith('nightlight')
and not (entity.entity_id).startswith('light.lamplinc') -%}
{{ entity.entity_id }}{{ ' ' }}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{%- endmacro %}
{{ get_lights_on()|trim|replace(' ', ',') }}

View File

@ -7,22 +7,34 @@ homeassistant:
input_boolean.lastmsg:
friendly_name: 'Repeat Message'
icon: mdi:repeat-once
#-------------------------------------------
input_boolean:
lastmsg:
name: Last Message
initial: off
#-------------------------------------------
mqtt:
sensor:
- state_topic: "polly/lastmsg"
name: "Last Message"
- state_topic: "polly/lastmsg_openai"
name: "Last AI Message"
template:
- trigger:
platform: event
event_type: openai_instructions_sent
sensor:
- name: "OpenAI"
state: "{{now()}}"
attributes:
instructions: "{{ trigger.event.data.instructions }}"
- trigger:
platform: event
event_type: openai_response
sensor:
- name: "OpenAI"
state: "{{now()}}"
attributes:
response: "{{ trigger.event.data.response }}"
##############################################################################
### Automations -
##############################################################################
@ -46,7 +58,7 @@ automation:
options:
voice: JennyNeural
message: >-
{{states.sensor.last_ai_message.state}}
"{{ state_attr('sensor.openai', 'response') }}"
cache: false
- service: input_boolean.turn_off

View File

@ -2,17 +2,14 @@
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# Neato Support for D7 Connected Botvac - control my [Neato Vacuum](https://amzn.to/2kqnnqu) with Home Assistant.
# Switched from Neato to Dreame Vacuum - https://amzn.to/4f7NpFP
#-------------------------------------------
##############################################################################
### Configuration - Authentication via the DEVELOPER Portal
### HACS - https://github.com/Tasshack/dreame-vacuum
##############################################################################
# neato:
# client_id: !secret neato_client_id
# client_secret: !secret neato_client_secret
automation:
##############################################################################
@ -20,19 +17,18 @@ automation:
### https://www.vcloudinfo.com/2020/05/home-assistant-neato-vacuum-automation.html
##############################################################################
- alias: 'Help Neato'
- alias: 'Help Vacuum'
id: 6548de52-a4a4-4df2-9d66-9c2c15577a7e
trigger:
- platform: state
entity_id: vacuum.neato_vac
to: 'error'
entity_id: sensor.l10s_vacuum_error
from: 'No error'
- platform: event
event_type: event_did_someone_help_neato_loop
event_type: event_did_someone_help_vacuum_loop
condition:
- condition: state
entity_id: vacuum.neato_vac
state: 'error'
- condition: template
value_template: "{{ states('sensor.l10s_vacuum_error') != 'No error' }}"
action:
- wait_template: "{{ states.group.family.state == 'home' }}"
@ -40,27 +36,27 @@ automation:
- delay: 00:05:00
- service: vacuum.locate
entity_id: vacuum.neato_vac
entity_id: vacuum.l10s_vacuum
- service: script.speech_engine
data:
value1: >
{% set error = states.vacuum.neato_vac.attributes['status'] %}
{{ "Neato Vacuum is complaining about " ~ error ~ " [ask Residents to help]" }}
value1: >
{% set error_description = state_attr('sensor.l10s_vacuum_error', 'description') %}
{{ "Vacuum is complaining: " ~ error_description ~ " [ask Residents to help]" }}
- service: script.notify_engine
data:
title: 'Help Neato'
value1: "{{ states.vacuum.neato_vac.attributes['status'] }}"
title: 'Help vacuum'
value1: "{{ state_attr('sensor.l10s_vacuum_error', 'description') }}"
who: 'family'
ios_category: 'camera'
camera_entity: 'camera.neato_vac_cleaning_map'
camera_entity: 'camera.l10s_vacuum_map'
content_type: 'jpeg'
group: 'information'
- delay: 00:01:00
- service: vacuum.locate
entity_id: vacuum.neato_vac
entity_id: vacuum.l10s_vacuum
- delay: 00:20:00
- event: event_did_someone_help_neato_loop
- event: event_did_someone_help_vacuum_loop

View File

@ -11,12 +11,11 @@
speech_processing:
mode: queued
sequence:
- service: mqtt.publish
data:
topic: 'polly/lastmsg'
payload: "Message: {{ now().strftime('%-I') }}:{{ now().strftime('%M') }} {{ now().strftime('%p') }}. {{ speech_message | striptags | truncate(220)}}"
retain: true
- event: openai_instructions_sent
event_data:
instructions: "{{ speech_message | striptags }}"
- condition: and
conditions:
- condition: or
@ -60,23 +59,10 @@ speech_processing:
0.2
{% endif %}
# - service: tts.amazon_polly_say
# data:
# entity_id: media_player.livingroomCC
# message: >-
# <speak>
# <amazon:auto-breaths>
# {{ speech_message }}
# </amazon:auto-breaths>
# </speak>
# cache: true
- service: conversation.process
data:
agent_id: conversation.openai_conversation
text: >-
Take the following system generated information and review and relay the information as yourself.
Here is the information:
{{ speech_message }}
response_variable: agent
@ -89,11 +75,9 @@ speech_processing:
{{ 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
- event: openai_iresponse
event_data:
response: "{{ now().strftime('%B %d,%Y %-I:%M %p') }} {{ now().strftime('%p') }}. {{ agent.response.speech.plain.speech | striptags}}"
- service: input_boolean.turn_off
data:

View File

@ -6,17 +6,11 @@
{%- macro responsibilities() -%}
{% set day_of_week = now().strftime('%a') %}
{% if day_of_week in ['Wed', 'Sun'] %}
Today is {{ now().strftime('%A') }} and {{ now().strftime('%A') }} is garbage day.
Today is garbage day.
{% if day_of_week == 'Wed' %}
Both Recycling and regular Garbage goes out.
{% endif %}
{% endif %}
{% set day_of_year = now().strftime('%j')|int(9999) %}
{% if day_of_year % 2 != 0 %}
Today is Justin's day to do the chores.
{% else %}
Today is Paige's day to do the chores.
{% endif %}
{%- endmacro -%}
{%- macro inside_weather() -%}
@ -51,10 +45,16 @@
{%- endif -%}
{%- endif %}
{% endfor -%}
{%- if states('sensor.pirateweather_alerts') == '1' -%}
{%- set alert_description = state_attr('sensor.pirateweather_alerts', 'description') %}
[WEATHER ALERT: Summarize the WHAT, WHEN and IMPACTS.] {{ alert_description }}
{%- endif %}
{%- endmacro -%}
{%- macro lightning() -%}
There have been {{ states('sensor.blitzortung_lightning_counter') }} lightning strikes detected within {{(states('sensor.blitzortung_lightning_distance') | int(9999)/ 1.69) | round (1, 'floor')}} Miles of our House. Please make sure everyone is inside the house.
There have been {{ states('sensor.blitzortung_lightning_counter') }} lightning strikes detected within {{(states('sensor.blitzortung_lightning_distance') | int(9999)/ 1.69) | round (1, 'floor')}} Miles of our House.
Nearest Storm Distance : {{states('sensor.pirateweather_nearest_storm_distance')}} Miles.
{%- endmacro -%}
{%- macro fridge() -%}
@ -215,11 +215,27 @@
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
{# Augmenting the System Prompt for OpenAI #}
{% set current_date = now() %}
{% set month = current_date.strftime('%B') %}
{% set day_of_week = now().strftime('%a') %}
{% set hour = now().hour %}
{% set minute = now().minute %}
{% set day = current_date.strftime('%d') %}
{% set year = current_date.strftime('%Y') %}
{% set time = current_date.strftime('%I:%M %p') %}
Current date time: {{ month }} {{ day }}, {{ year }} {{ time }}
Residents:
- Carlo (Dad): {{ states('person.carlo') }}
- Stacey (Mom): {{ states('person.stacey') }}
- Justin (Son): {{ states('person.justin') }}
- Paige (Daughter): {{ states('person.paige') }}
and our cat Molly: Always home.
[Avoid repeating information from the last broadcast if it was recently broadcasted]
Last broadcast: {{states('input_text.lastmsg_openai')}}
New Information:
{% if call_no_announcement != 1 %}
{% if now().strftime('%H')|int(9999)< 12 and now().strftime('%H')|int(9999)> 6 %}
Good morning.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long