AutomationDataset/galway-it-meetup/galway-it-meetup_automation...

252 lines
9.1 KiB
YAML

- alias: Agenda with Shopping List
description: This automation fetches the weather forecast, the news (via custom
sensors), calendar events, and shopping list items, processes the information
using a conversation agent, and sends a notification with the agenda for the day.
I use telegram as the notification service, but others might be suitable for you!
triggers:
- at: 08:00:00
trigger: time
- trigger: time
at: '14:00:00'
actions:
- variables:
weather_entity: weather.home
calendar_entity: calendar.house
zone_entity: zone.home
calendar_duration:
hours: 18
sensor_local: '{{ states(''sensor.local_bulletin'') }}'
sensor_national: '{{ states(''sensor.irish_bulletin'') }}'
prompt: "Please generate text that will be sent to the users\nsmartphone with\
\ helpful information.\n\nYou are a helpful personal agent that generates\
\ text for the user:\n- Your answers are helpful, friendly, warm, insightful.\n\
- Your answers are not technical.\n- If reporting on weather, headlines or\
\ bulletins, report the information and report it accurately.\n- Your messages\
\ help the user prepare for their day, for example:\n - Making note of unusual\
\ weather for the location and time of year\n - How much time remaining until\
\ their first meeting\n - Anything that may be special or unique, such as\
\ celebrating a birthday\n "
- alias: Fetch Weather Forecast
action: weather.get_forecasts
data:
type: daily
target:
entity_id:
- '{{ weather_entity }}'
response_variable: daily_forecast
- variables:
forecast_entity: '{{ daily_forecast[weather_entity] }}'
forecast: '{{ forecast_entity.forecast[0] }}'
- alias: Fetch Calendar Agenda
action: calendar.get_events
data:
duration:
hours: 18
target:
entity_id: calendar.house
response_variable: events_response
- alias: Fetch Shopping List
action: todo.get_items
data:
status: needs_action
target:
entity_id: todo.shopping_list
response_variable: todo_response
- alias: Fetch Calendar Agenda
action: calendar.get_events
data:
duration:
hours: 18
target:
entity_id: calendar.house
response_variable: events_response
- alias: Conversation Agent Notification Text
action: conversation.process
data:
text: "Time: {{ now().strftime(\"%A %B %d %H:%M %p\") }}\n{%- if weather_entity\
\ is defined %}\n{%- set temperature_unit = state_attr(weather_entity, 'temperature_unit')\
\ -%}\nForecast: {{ forecast.condition }} ({{ forecast.temperature }}{{ temperature_unit\
\ }}, {{ forecast.precipitation }}% precipitation)\n{%- endif %}\nLocal News\
\ Headlines - {{ sensor_local }} National News - {{ sensor_national }}\n\
Calendar \"{{ state_attr(calendar_entity, 'friendly_name') }}\" events for\
\ the next {{ calendar_duration.hours }} hours:\n{%- set agenda = (events_response\
\ | items | first)[1] %}\n{%- if agenda.events %}\n {%- for event in agenda.events\
\ %}\n - Summary: {{ event.summary }}\n Start-End: {% if event.start is\
\ defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif\
\ %}\n {%- if event.description is defined %}\n Description: {{ event.description\
\ }}\n {% endif -%}\n {%- if event.location is defined %}\n Location:\
\ {{ event.location }}\n {% endif -%}\n {%- endfor %}\n{%- else %}\n \
\ - No upcoming events.\n{%- endif %}\n{{ prompt }}"
agent_id: conversation.google_generative_ai
response_variable: agent
- sequence:
- alias: Send notification
action: notify.telegram_bot
data:
target: null
title: '{{ now().strftime(''%A'') }} Agenda'
message: '{{ agent.response.speech.plain.speech }}'
enabled: true
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- alias: Send notification
action: notify.telegram_bot
data:
target: null
title: 'Headlines:'
message: '{{ sensor_local }}, {{ sensor_national }}'
enabled: false
- alias: Send notification
action: notify.telegram_bot
data:
target: null
title: 'Current Shopping List:'
message: '{{ todo_response[''todo.shopping_list''][''items''] | map(attribute=''summary'')
| list }}'
- alias: Who's at the door?
description: Summarizes motion events detected by the doorbell camera.
triggers:
- trigger: state
entity_id:
- binary_sensor.camera_cell_motion_detection_3
- binary_sensor.camera_cell_motion_detection
- binary_sensor.camera_cell_motion_detection_2
to: 'on'
conditions: []
actions:
- action: llmvision.stream_analyzer
metadata: {}
data:
remember: true
use_memory: true
duration: 5
max_frames: 4
include_filename: false
target_width: 1280
max_tokens: 100
temperature: 0.2
generate_title: true
expose_images: true
image_entity:
- camera.camera_fluent
message: Summarize the events based on a series of images captured at short
intervals. You are a doorbell camera, looking out onto a common footpath.
Focus only on moving subjects such as people, vehicles, and other active elements.
Ignore static objects and scenery. Provide a clear and concise account of
movements and interactions. Do not mention or imply the existence of images—present
the information as if directly observing the events. If there is no movement
detected in any frames, return only 'all clear'
provider: 01JTRRH7YMV69TQVWZRAX2EX2R
response_variable: llm_response
- action: llmvision.remember
metadata: {}
data:
camera_entity: camera.camera_fluent
title: Motion detected
summary: ''
enabled: false
- if:
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: '{{ llm_response.response_text != ''All clear'' }}'
- condition: template
value_template: '{{ llm_response.response_text != ''All clear.'' }}'
- condition: template
value_template: '{{ llm_response.response_text != ''all clear.'' }}'
- condition: template
value_template: '{{ llm_response.response_text != ''all clear'' }}'
then:
- action: input_text.set_value
metadata: {}
data:
value: '{{ now().strftime(''%d-%m %H:%M:%S'') }} - {{ llm_response.response_text
}}'
target:
entity_id: input_text.vision_llm
- action: notify.mobile_app_phone
metadata: {}
data:
message: '{{ llm_response.response_text }}'
title: Spotted
- action: camera.snapshot
metadata: {}
target:
entity_id: camera.camera_fluent
data:
filename: /tmp/{{ camera.camera_fluent }}_{{ now().strftime("%Y%m%d-%H%M%S")
}}.jpg
enabled: false
- delay:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
mode: single
- alias: Baked beans tag is scanned
description: Adds Baked Beans to the shopping list when the tag is scanned, and
sends a notification to mobile apps. Useful for all sorts of shopping, especially
when you run out of something and need to add it to the list quickly.
triggers:
- trigger: tag
tag_id: a22c63a0-43e0-42e7-ad5b-f3274500cda4
conditions: []
actions:
- action: shopping_list.add_item
metadata: {}
data:
name: Baked Beans
- action: notify.mobile_app_erdnuss
metadata: {}
data:
message: Baked Beans added
title: Addition to shopping list
- action: notify.mobile_app_xiaomi
metadata: {}
data:
message: Baked Beans added
title: Addition to shopping list
mode: single
- alias: Tomorrow Weather Check
description: Sends a notification if a web scrape sensor indicates a weather alert
for tomorrow, ensuring household members are informed of any weather warnings.
triggers:
- entity_id:
- sensor.tomorrow_web_scrape_color
to: null
enabled: true
trigger: state
conditions:
- condition: template
value_template: '{{ trigger.to_state.state != ''Currently no warnings in operation.''
}}'
- condition: template
value_template: '{{ trigger.to_state.state != ''unavailable'' }}'
- condition: template
value_template: '{{ trigger.to_state.state != null }}'
- condition: template
value_template: '{{ trigger.to_state.state != Gray }}'
- condition: template
value_template: '{{ trigger.to_state.state != ''Gray'' }}'
actions:
- variables:
msg: A {{ trigger.to_state.state }} Weather Alert for Tomorrow Has Been Issued!
- data:
title: Weather Alert Tomorrow!
message: '{{ msg }}'
data:
tag: weather_alert
action: notify.mobile_app_phone
- data:
title: Weather Alert Tomorrow!
message: '{{ msg }}'
data:
tag: weather_alert
action: notify.mobile_app_phone_2
mode: single