Snippet content copied to clipboard.
Are you sure to delete this snippet? No, don't delete
  1. alias: Daily Agenda
  2. description: ""
  3. trigger:
  4. - platform: time
  5. at: "10:00:00"
  6. action:
  7. - variables:
  8. weather_entity: weather.thermoking
  9. calendar_number: one
  10. calendar_entity_1: calendar.birthdays
  11. calendar_entity_2: calendar.kids_school
  12. calendar_entity_3: calendar.events
  13. notify_number: three
  14. zone_entity: zone.home
  15. calendar_duration:
  16. hours: 18
  17. prompt: >-
  18. Please generate text for a notification that will be sent to the users
  19. smartphone with helpful information.
  20. You are a helpful personal agent that generates text for the user:
  21. - Your answers are helpful, friendly, warm, insightful.
  22. - Your answers are not technical, and do not include Home Assistant
  23. internal details such as entities in responses.
  24. - Your answers should have some anime refrences for motivation.
  25. - Your messages help the user prepare for their day, for example:
  26. - Each calendar belongs to a different person, use the calendar name to refer to them, provide individual recommendations for each calendar, and make special remarks if some events match in time and the title or description makes a mention between calendars
  27. - Making note of unusual weather for the location and time of year (but not mundane details like "0% chance of precipitation")
  28. - How much time remaining until their first meeting
  29. - Anything that may be special or unique, such as celebrating a birthday
  30. - alias: Fetch First Calendar Agenda
  31. data:
  32. duration:
  33. hours: 18
  34. target:
  35. entity_id: calendar.birthdays
  36. response_variable: agenda_1
  37. action: calendar.get_events
  38. - if:
  39. - condition: template
  40. value_template: "{{ (calendar_number == 'two') or (calendar_number == 'three') }}"
  41. then:
  42. - alias: Fetch Second Calendar Agenda
  43. data:
  44. duration:
  45. hours: 18
  46. response_variable: agenda_2
  47. action: calendar.get_events
  48. target:
  49. entity_id: calendar.kids_school
  50. - if:
  51. - condition: template
  52. value_template: "{{ calendar_number == 'three'}}"
  53. then:
  54. - alias: Fetch Third Calendar Agenda
  55. data:
  56. duration:
  57. hours: 18
  58. target:
  59. entity_id:
  60. - calendar.events
  61. response_variable: agenda_3
  62. action: calendar.get_events
  63. - action: weather.get_forecasts
  64. metadata: {}
  65. data:
  66. type: daily
  67. target:
  68. entity_id: "{{ weather_entity }}"
  69. response_variable: weather.get_forecasts
  70. alias: Fetch Weather Forecast
  71. - variables:
  72. forecast_entity: "{{ daily_forecast[weather_entity] }}"
  73. forecast: "{{ forecast_entity.forecast[0] }}"
  74. - alias: Conversation Agent Notification Text
  75. data:
  76. text: >-
  77. Time: {{ now().strftime("%A %B %d %H:%M %p") }}
  78. {%- if zone_entity is defined %}
  79. Latitude: {{ state_attr(zone_entity, 'latitude') | round(1) }}
  80. Longitude: {{ state_attr(zone_entity, 'longitude') | round(1) }}
  81. {% endif %}
  82. {%- if weather_entity is defined %}
  83. {%- set temperature_unit = state_attr(weather_entity,
  84. 'temperature_unit') -%}
  85. Forecast: {{ forecast.condition }} ({{ forecast.temperature }}{{
  86. temperature_unit }}, {{ forecast.precipitation }}% precipitation)
  87. {%- endif %}
  88. Calendar "{{ state_attr(calendar_entity_1, 'friendly_name') }}" events
  89. for the next {{ calendar_duration.hours }} hours:
  90. {%- set agenda = (agenda_1 | items | first)[1] %}
  91. {%- if agenda.events %}
  92. {%- for event in agenda.events %}
  93. - Summary: {{ event.summary }}
  94. Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
  95. {%- if event.description is defined %}
  96. Description: {{ event.description }}
  97. {% endif -%}
  98. {%- if event.location is defined %}
  99. Location: {{ event.location }}
  100. {% endif -%}
  101. {%- endfor %}
  102. {%- else %}
  103. - No upcoming events.
  104. {%- endif %}
  105. {%- if (calendar_number == "two") or (calendar_number == "three") %}
  106. Calendar "{{ state_attr(calendar_entity_2, 'friendly_name') }}" events
  107. for the next {{ calendar_duration.hours }} hours:
  108. {%- set agenda = (agenda_2 | items | first)[1] %}
  109. {%- if agenda.events %}
  110. {%- for event in agenda.events %}
  111. - Summary: {{ event.summary }}
  112. Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
  113. {%- if event.description is defined %}
  114. Description: {{ event.description }}
  115. {% endif -%}
  116. {%- if event.location is defined %}
  117. Location: {{ event.location }}
  118. {% endif -%}
  119. {%- endfor %}
  120. {%- else %}
  121. - No upcoming events.
  122. {%- endif %}
  123. {%- endif %}
  124. {%- if (calendar_number == "three") %}
  125. Calendar "{{ state_attr(calendar_entity_3, 'friendly_name') }}" events
  126. for the next {{ calendar_duration.hours }} hours:
  127. {%- set agenda = (agenda_3 | items | first)[1] %}
  128. {%- if agenda.events %}
  129. {%- for event in agenda.events %}
  130. - Summary: {{ event.summary }}
  131. Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
  132. {%- if event.description is defined %}
  133. Description: {{ event.description }}
  134. {% endif -%}
  135. {%- if event.location is defined %}
  136. Location: {{ event.location }}
  137. {% endif -%}
  138. {%- endfor %}
  139. {%- else %}
  140. - No upcoming events.
  141. {%- endif %}
  142. {%- endif %}
  143. {{ prompt }}
  144. agent_id: conversation.google_generative_ai_3
  145. response_variable: agent
  146. action: conversation.process
  147. - alias: Send notification
  148. data:
  149. title: "{{ now().strftime('%A') }} Agenda"
  150. message: "{{ agent.response.speech.plain.speech }}"
  151. action: notify.mobile_app_luffy1987
  152. - if:
  153. - condition: template
  154. value_template: "{{ (notify_number == 'two') or (notify_number == 'three') }}"
  155. then:
  156. - alias: Send notification
  157. data:
  158. title: "{{ now().strftime('%A') }} Agenda"
  159. message: "{{ agent.response.speech.plain.speech }}"
  160. action: notify.alexa_media_echo_show
  161. - if:
  162. - condition: template
  163. value_template: "{{ notify_number == 'three'}}"
  164. then:
  165. - alias: Send notification
  166. data:
  167. title: "{{ now().strftime('%A') }} Agenda"
  168. message: "{{ agent.response.speech.plain.speech }}"
  169. action: notify.alexa_media_animeking_echo_dot

Edit this Snippet