Forked from allenporter/notify_agent_agenda.yaml
Last active
December 29, 2023 22:39
-
-
Save jak119/0abf5489a67c364311490785be974a6e to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: Conversation agent Agenda Notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original: https://gist.github.com/allenporter/e70d9eb090c7dbdd593cf526e07b4abe | |
# Found in comments: | |
# https://gist.github.com/allenporter/e70d9eb090c7dbdd593cf526e07b4abe?permalink_comment_id=4796049#gistcomment-4796049 | |
blueprint: | |
name: Daily Conversation agent Agenda Notification | |
description: | |
Conversation agent generates a personalized notification based on the | |
upcoming calendar agenda, location, and weather information in your language. | |
domain: automation | |
input: | |
language: | |
name: Language | |
description: Language of Assistant Response | |
selector: | |
language: | |
default: "en" | |
user: | |
name: User | |
description: User who is being addressed | |
selector: | |
entity: | |
multiple: false | |
filter: | |
- domain: | |
- person | |
notify_time: | |
name: Notification time | |
description: Time the automation is triggered to send the notification. | |
selector: | |
time: {} | |
default: 07:00:00 | |
notify_service: | |
name: Notify service name | |
description: The name of the notify service where the notification should be sent. | |
selector: | |
text: {} | |
default: notify.notify | |
notify_target: | |
name: Notify target | |
description: The target of the notify service. | |
selector: | |
text: {} | |
default: | |
calendar_entities: | |
name: Calendar | |
description: The calendar entity to use for finding upcoming calendar events. | |
selector: | |
entity: | |
multiple: true | |
filter: | |
- domain: | |
- calendar | |
calendar_duration: | |
name: Calendar Event duration | |
description: How many hours ahead to look for upcoming calendar events. | |
selector: | |
duration: | |
default: | |
hours: 18 | |
weather_entity: | |
name: Weather Entity | |
description: The weather entity to use for upcoming weather forecast. | |
selector: | |
entity: | |
multiple: false | |
filter: | |
- domain: | |
- weather | |
zone_entity: | |
name: Home Zone Entity | |
description: The zone entity to use to determine approximate location for understanding typical weather. | |
selector: | |
entity: | |
multiple: false | |
filter: | |
- domain: | |
- zone | |
conversation_agent: | |
name: Conversation Agent | |
selector: | |
conversation_agent: | |
prompt: | |
name: Conversation Agent Prompt | |
selector: | |
text: | |
multiline: true | |
type: text | |
default: |- | |
Please generate text for a notification that will be sent to the users | |
smartphone with helpful information. | |
You are a helpful personal agent that generates text for the user: | |
- Your answers are helpful, friendly, warm, insightful. | |
- Your answers are not technical, and do not include Home Assistant internal details such as entities in responses. | |
- Your messages help the user prepare for their day, for example: | |
- Making note of unusual weather for the location and time of year (but not mundane details like "0% chance of precipitation") | |
- How much time remaining until their first meeting | |
- Anything that may be special or unique, such as celebrating a birthday | |
trigger: | |
platform: time | |
at: !input notify_time | |
action: | |
- variables: | |
language: !input language | |
user: !input user | |
weather_entity: !input weather_entity | |
calendar_entities: !input calendar_entities | |
zone_entity: !input zone_entity | |
calendar_duration: !input calendar_duration | |
prompt: !input prompt | |
- alias: Fetch Calendar Agenda | |
service: calendar.get_events | |
data: | |
duration: !input calendar_duration | |
target: | |
entity_id: !input calendar_entities | |
response_variable: events_responses | |
- alias: "Conversation Agent Notification Text" | |
service: conversation.process | |
data: | |
text: |- | |
Name of User: {{ state_attr(user, "friendly_name") }} | |
Time: {{ now() }} | |
{%- if zone_entity is defined %} | |
Latitude: {{ state_attr(zone_entity, 'latitude') | round(1) }} | |
Longitude: {{ state_attr(zone_entity, 'longitude') | round(1) }} | |
{% endif %} | |
{%- if weather_entity is defined %} | |
{%- set forecast = state_attr(weather_entity, 'forecast')[0] %} | |
{%- set temperature_unit = state_attr(weather_entity, 'temperature_unit') -%} | |
Weather: {{ forecast.condition }} ({{ forecast.temperature }}{{ temperature_unit }}, {{ forecast.precipitation }}% precipitation) | |
{%- endif %} | |
{%- for calendar_entity in calendar_entities %} | |
Calendar "{{ state_attr(calendar_entity, 'friendly_name') }}" events for the next {{ calendar_duration.hours }} hours: | |
{%- set agenda = events_responses[calendar_entities[loop.index0]] %} | |
{%- if "events" in agenda and agenda.events %} | |
{%- for event in agenda.events %} | |
- Summary: {{ event.summary }} | |
Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %} | |
{%- if event.descripton is defined %} | |
Descripton: {{ event.descripton }} | |
{% endif -%} | |
{%- if event.location is defined %} | |
Location: {{ event.location }} | |
{% endif -%} | |
{%- endfor %} | |
{%- else %} | |
- No upcoming events. | |
{%- endif %} | |
{%- endfor %} | |
Respond in RFC 5646 Language: "{{language}}" | |
{{ prompt }} | |
agent_id: !input conversation_agent | |
response_variable: agent | |
- alias: "Send notification" | |
service: !input notify_service | |
data: | |
target: !input notify_target | |
title: "{{ now().strftime('%A %B %d') }} Agenda" | |
message: "{{ agent.response.speech.plain.speech }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment