I’ve had a good night reminder script for a while (that spins up when we say ‘bedtime’ to google, alexa or just put the house in ‘night’ mode), but I just enhanced it using Generative AI to spice things up a bit. Would love to see what else folks have HA remind them to do before they go to bed. This is using the ‘variables+history’ HACS integration that is fantasic for composing long messages and storing AI responses in. I also have my own custom notifier that distributes the message (under certain conditions) to displays, TTS devices and phone notifications, but that’s a post for another day…
alias: .say unavailable sensors and opened doors and sump pump
sequence:
- service: variable.update_sensor
metadata: {}
data:
replace_attributes: true
attributes:
message: >-
Good night.
It is currently {{state_attr('weather.chezaggar','temperature')}}
degrees outside and {{states('weather.chezaggar')}}. Tonight, expect
{{states('sensor.chezaggar_condition_night_0d')}}.
Before you head up to bed, please
{%-if states('input_text.window_and_door_check') != '' %}
Check that the {{states('input_text.window_and_door_check')}} are locked.
{%-endif%}
{%-if states('sensor.24_hour_sump_pump_watts') | float < 100 and
states('sensor.24_hour_precipitation') | float > 0.5 and
states('sensor.sump_pump_monitor') != '' %}
{{states('sensor.sump_pump_monitor')}}.
{%-endif%}
{%-if states('input_boolean.guests_in_basement') == 'on' and (as_timestamp(now()) - as_timestamp(states.light.basement_bedroom_lights.last_changed)) /60 > 300 %}
Consider turning off the "Guests in Basement" switch as the basement bedroom lights have not been on in the last 5 hours.
{%-endif%}
{%-if states('sensor.maggar_surfacelaptop_sessionstate') == 'Unlocked' %}
Mark's office PC is still on. Please check it.
{%-endif%}
{%-if states('sensor.sensors_unavailable') != '' %}
The following sensors might be offline and need checking: {{ states('sensor.sensors_unavailable') }}.
{%-endif%}
{%-if states('binary_sensor.workday_tomorrow') == 'on' and states('input_boolean.pretenditsweekend') == 'off' and states('binary_sensor.liam_laptop_charging') == "off" and states('person.liam') == 'home' %}
It doesn't seem like Liam's laptop is plugged in. Please make sure it is charging!
{%-endif%}
{%-if states('vacuum.roborock_q_revo') != 'docked' and states('vacuum.roborock_q_revo') != 'cleaning' %}
The main floor Roborock is not docked or responsive. Please check it.
{%-endif%}
Clear the main floor of obstacles and ensure the roborock water tanks are good to go so the floor will be clean in the morning.
value: "{{now()}}"
target:
entity_id: sensor.goodnight_message
- service: google_generative_ai_conversation.generate_content
metadata: {}
data:
prompt: >-
Take the following text and summarize it in the style of a caring and
trustworthy person with a direct manner. Do not include emojis or hash
tags in your response.
{{state_attr('sensor.goodnight_message','message')}}
response_variable: ai_response
continue_on_error: true
- service: variable.update_sensor
metadata: {}
data:
replace_attributes: false
attributes:
response: "{{ai_response['text']}}"
value: "{{now()}}"
target:
entity_id: sensor.goodnight_message
continue_on_error: true
- event: UNotify
event_data:
message: |-
{% if state_attr('sensor.goodnight_message','response') != none %}
{{state_attr('sensor.goodnight_message','response')}}
{%else%}
Note that Google Generative AI was not available for this message.
{{state_attr('sensor.goodnight_message','message')}}
{%endif%}
message_speak: "yes"
message_speak_target: kitchen
tag: goodnight
mode: single