/
blueprint_notif_multi_calendriers_gpt_tts.yaml
364 lines (347 loc) · 13.7 KB
/
blueprint_notif_multi_calendriers_gpt_tts.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
blueprint:
name: Notification Agenda Multi-Calendriers
source_url: https://github.com/Mattieug/ha_blueprints/blob/main/blueprint_notif_multi_calendriers_gpt_tts.yaml
description:
Envoie des notifications Telegram et voix basées sur jusqu’à 5 agendas, la météo et la localisation.
D'après un script de fixtse (https://github.com/fixtse/blueprints/blob/main/multiple_notify_agent_calendar_agenda.yaml)
domain: automation
author: mattieug
input:
weather_entity:
name: Entité Météo
description: Entité de la météo à utiliser.
selector:
entity:
domain: weather
zone_entity:
name: Entité Zone
description: Entité de la zone pour la localisation.
selector:
entity:
domain: zone
calendar_entity_1:
name: Calendrier 1
description: Premier calendrier à surveiller.
selector:
entity:
domain: calendar
calendar_entity_2:
name: Calendrier 2
description: Second calendrier à surveiller.
selector:
entity:
domain: calendar
calendar_entity_3:
name: Calendrier 3
description: Troisième calendrier à surveiller.
selector:
entity:
domain: calendar
calendar_entity_4:
name: Calendrier 4
description: Quatrième calendrier à surveiller.
selector:
entity:
domain: calendar
calendar_entity_5:
name: Calendrier 5
description: Cinquième calendrier à surveiller.
selector:
entity:
domain: calendar
calendar_duration:
name: Durée de l'Agenda
description: Durée pour laquelle les événements du calendrier sont listés.
default:
hours: 18
selector:
duration:
trigger_time_1:
name: Heure du Premier Déclencheur
description: Heure à laquelle le premier déclencheur se déclenche.
selector:
time: {}
trigger_time_2:
name: Heure du second Déclencheur
description: Heure à laquelle le second déclencheur se déclenche.
selector:
time: {}
trigger_time_3:
name: Heure du troisième Déclencheur
description: Heure à laquelle le troisième déclencheur se déclenche.
selector:
time: {}
telegram_notification_entity:
name: Entité de Notification Telegram
description: Entité Telegram utilisée pour envoyer des notifications.
default: "notify."
selector:
text: {}
media_player_entity:
name: Entité Media Player
description: Entité du lecteur multimédia pour la lecture des annonces.
selector:
entity:
domain: media_player
media_player_volume:
name: Volume des annonces
description: Niveau de volume pour les annonces
selector:
number:
min: 0.0
max: 1.0
step: 0.01
media_content_id:
name: ID du fichier audio de notification
description: Identifiant du contenu audio à jouer.
default: media-source://media_source/local/JingleB.mp3
selector:
text: {}
prompt_gpt:
name: Prompt pour GPT
description: Consignes pour GPT
selector:
text:
multiline: true
type: text
default: |-
Génère une annonce en français pour une notification qui sera lue à l'utilisateur avec des informations utiles.
N'utilise surtout pas de format markdown qui ne serait pas reconnu par le moteur TextToSpeech.
Tu es un agent personnel utile qui génère du texte pour l'utilisateur :
- Tes réponses sont utiles, amicales, chaleureuses, perspicaces avec un peu d'humour.
- Tes réponses ne sont pas techniques et n'incluent pas de détails internes de Home Assistant comme les entités dans les réponses.
- Tes messages aident l'utilisateur à gérer sa journée en fonction de l'heure précise actuelle et des agendas.
- Commence toujours par indiquer la date et l'heure et le saint du jour.
- Les 3 premiers calendriers appartiennent à 3 enfants différents Marilou, Quentin et Camille (attention c'est un garçon), le 4eme aux parents et le dernier contient les jours fériés,
- Utilise le nom du calendrier pour t'y référer, fournis des recommandations individuelles pour chaque calendrier, et fais des remarques spéciales si certains événements correspondent dans le temps et que le titre ou la description fait mention entre les calendriers
- Note les conditions météorologiques inhabituelles pour le lieu et la période de l'année (mais pas de détails banals comme "0% de chance de précipitations")
- Combien de temps reste-t-il jusqu'au premier cour ou rendez-vous
- Tout ce qui peut être spécial ou unique, comme célébrer un anniversaire. Attention à rester utile, ne pas ajouter de phrase comme "aujourd'hui pas d'anniversaire" ou "pas de jour férié" ou "pas d'évènement"
- S'il n'y a rien à signaler de particulier (anniversaire ou jour férié), ne le mentionne pas.
- Aurel&Matt correspond au calendrier des parents : Aurélia et Mattieu.
- Toujours indiquer l'heure à laqelle le prochain evenement commence et se termine
- pour les enfants, donne un aperçu des cours des prochaines heures de la journee et du lendemain.
- Indiquer si un professeur est absent ou un cours annulé. ne rien dire si ce n'est pas le cas.
- LV2 signifie langue vivante 2. Remplace l'abréviation.
- Mets le nom des matières en minuscules
- Genere l'annonce sous forme d'un poeme avec des rimes riches
- Ajoute une petite phrase à propos de notre chien Sloubi pour faire rire les enfants
- Attention à toujours etre precis sur les horaires des evenements
conversation_agent_id:
name: ID de l'Agent de Conversation
description: "ID de l'agent de conversation à utiliser (Agent GPT pour que le script fonctionne)"
selector:
conversation_agent:
tts_service:
name: Service TTS
description: Service de synthèse vocale à utiliser pour lire les notifications.
selector:
entity:
domain: tts
trigger:
- platform: time
at: !input "trigger_time_1"
- platform: time
at: !input "trigger_time_2"
- platform: time
at: !input "trigger_time_3"
action:
- variables:
weather_entity: !input "weather_entity"
zone_entity: !input "zone_entity"
calendar_entity_1: !input "calendar_entity_1"
calendar_entity_2: !input "calendar_entity_2"
calendar_entity_3: !input "calendar_entity_3"
calendar_entity_4: !input "calendar_entity_4"
calendar_entity_5: !input "calendar_entity_5"
calendar_duration: !input "calendar_duration"
conversation_agent: !input "conversation_agent_id"
prompt: !input "prompt_gpt"
agenda_1: ""
agenda_2: ""
agenda_3: ""
agenda_4: ""
agenda_5: ""
- alias: Fetch First Calendar Agenda
service: calendar.list_events
data:
duration:
hours: 18
minutes: 0
seconds: 0
target:
entity_id: !input "calendar_entity_1"
response_variable: agenda_1
- alias: Fetch Second Calendar Agenda
service: calendar.list_events
data:
duration: !input "calendar_duration"
target:
entity_id: !input "calendar_entity_2"
response_variable: agenda_2
- alias: Fetch Third Calendar Agenda
service: calendar.list_events
data:
duration: !input "calendar_duration"
target:
entity_id: !input "calendar_entity_3"
response_variable: agenda_3
- alias: Fetch 4 Calendar Agenda
service: calendar.list_events
data:
duration: !input "calendar_duration"
target:
entity_id: !input "calendar_entity_4"
response_variable: agenda_4
enabled: true
- alias: Fetch 5 Calendar Agenda
service: calendar.list_events
data:
duration: !input "calendar_duration"
target:
entity_id: !input "calendar_entity_5"
response_variable: agenda_5
enabled: true
- alias: Conversation Agent Notification Text
service: conversation.process
data:
text: >-
Heure: {{ now() }}
Latitude: {{ state_attr(zone_entity, 'latitude') | round(1) }}
Longitude: {{ state_attr(zone_entity, 'longitude') | round(1) }}
{%- set forecast = state_attr(weather_entity, 'forecast')[0] %}
{%- set temperature_unit = state_attr(weather_entity,'temperature_unit')
-%}
Météo: {{ forecast.condition }} ({{
forecast.temperature}}{{temperature_unit }}, {{ forecast.precipitation
}}% precipitation)
Calendar "{{ state_attr(calendar_entity_1, 'friendly_name') }}" events
for the next {{ calendar_duration.hours }} hours:
{%- if agenda_1.events %}
{%- for event in agenda_1.events %}
- Summary: {{ event.summary }}
Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
{%- if event.description is defined %}
Description: {{ event.description }}
{% endif -%}
{%- if event.location is defined %}
Location: {{ event.location }}
{% endif -%}
{%- endfor %}
{%- else %}
- No upcoming events.
{%- endif %}
Calendar "{{ state_attr(calendar_entity_2, 'friendly_name') }}" events
for the next {{ calendar_duration.hours }} hours:
{%- if agenda_2.events %}
{%- for event in agenda_2.events %}
- Summary: {{ event.summary }}
Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
{%- if event.description is defined %}
Description: {{ event.description }}
{% endif -%}
{%- if event.location is defined %}
Location: {{ event.location }}
{% endif -%}
{%- endfor %}
{%- else %}
- No upcoming events.
{%- endif %}
Calendar "{{ state_attr(calendar_entity_3, 'friendly_name') }}" events
for the next {{ calendar_duration.hours }} hours:
{%- if agenda_3.events %}
{%- for event in agenda_3.events %}
- Summary: {{ event.summary }}
Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
{%- if event.description is defined %}
Description: {{ event.description }}
{% endif -%}
{%- if event.location is defined %}
Location: {{ event.location }}
{% endif -%}
{%- endfor %}
{%- else %}
- No upcoming events.
{%- endif %}
Calendar "{{ state_attr(calendar_entity_4, 'friendly_name') }}" events
for the next {{ calendar_duration.hours }} hours:
{%- if agenda_4.events %}
{%- for event in agenda_4.events %}
- Summary: {{ event.summary }}
Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
{%- if event.description is defined %}
Description: {{ event.description }}
{% endif -%}
{%- if event.location is defined %}
Location: {{ event.location }}
{% endif -%}
{%- endfor %}
{%- else %}
- No upcoming events.
{%- endif %}
Calendar "{{ state_attr(calendar_entity_5, 'friendly_name') }}" events
for the next {{ calendar_duration.hours }} hours:
{%- if agenda_5.events %}
{%- for event in agenda_5.events %}
- Summary: {{ event.summary }}
Start-End: {% if event.start is defined %}{{ event.start }} to {{ event.end }}{% else %}All Day{% endif %}
{%- if event.description is defined %}
Description: {{ event.description }}
{% endif -%}
{%- if event.location is defined %}
Location: {{ event.location }}
{% endif -%}
{%- endfor %}
{%- else %}
- No upcoming events.
{%- endif %}
{{ prompt }}
agent_id: !input "conversation_agent_id"
response_variable: agent
- variables:
reponse_gpt: "{{ agent.response.speech.plain.speech }}"
- alias: Send notification
service: !input "telegram_notification_entity"
data:
title: "{{ now().strftime('%A') }} Agenda"
message: "{{ reponse_gpt }}"
- service: tts.clear_cache
data: {}
- alias: Create Snapshot of Current Media State
service: scene.create
data:
scene_id: current_state_temp
snapshot_entities:
- !input "media_player_entity"
- service: media_player.volume_set
data:
volume_level: 0.79
target:
entity_id: !input "media_player_entity"
- service: media_player.play_media
target:
entity_id: !input "media_player_entity"
data:
media_content_id: !input "media_content_id"
media_content_type: audio/mpeg
- service: tts.speak
data:
cache: false
media_player_entity_id: !input "media_player_entity"
message: "{{ reponse_gpt }}"
language: fr
target:
entity_id: !input "tts_service"
- service: media_player.play_media
target:
entity_id: !input "media_player_entity"
data:
media_content_id: !input "media_content_id"
media_content_type: audio/mpeg
enabled: true
- alias: Restore Original Media Player State
service: scene.turn_on
data: {}
target:
entity_id: scene.current_state_temp
mode: restart