-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHOME_ASSISTANT_AUTOMATIONS_TEMPLATE.yaml
More file actions
507 lines (412 loc) · 16.3 KB
/
Copy pathHOME_ASSISTANT_AUTOMATIONS_TEMPLATE.yaml
File metadata and controls
507 lines (412 loc) · 16.3 KB
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# Home Assistant Automations for ArduiBeeScale
#
# Copy this to /config/automations.yaml in Home Assistant
# OR
# Create individual automation files in /config/automations/
# Then reference them in configuration.yaml with:
# automation: !include_dir_list automations/
#
# Date: 2025-11-16
# ==============================================================================
# ALERT 1: HIGH TEMPERATURE
# ==============================================================================
# Description: Alert when temperature exceeds 35°C for more than 5 minutes
# Why: Indicates potential stress for bees or ventilation issue
- id: "alert_high_temperature_ruche_001"
alias: "Alerte Température Élevée Ruche 001"
description: "Notification when temperature exceeds 35°C"
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.temperature_ruche_001
above: 35
for:
minutes: 5
condition:
- condition: state
entity_id: sensor.temperature_ruche_001
state: "!=unavailable"
action:
# Persistent notification in HA
- service: persistent_notification.create
data:
notification_id: "temp_high_alert_001"
title: "⚠️ Température Élevée Ruche 001"
message: >-
Température actuelle: {{ states('sensor.temperature_ruche_001') }}°C
(Seuil alerte: 35°C)
Durée: > 5 minutes
# Email notification (if configured)
- service: notify.email
data:
title: "🌡️ Alerte Température Ruche 001"
message: >-
La température de la ruche 001 dépasse 35°C!
Température actuelle: {{ states('sensor.temperature_ruche_001') }}°C
Humidité: {{ states('sensor.humidity_ruche_001') }}%
Heure de l'alerte: {{ now().strftime('%H:%M:%S') }}
Recommandations:
- Vérifier la ventilation
- Assurer un accès à l'eau
- Surveiller le comportement des abeilles
# Log to file
- service: logbook.log
data:
name: "Alerte Température"
message: "Température ruche 001: {{ states('sensor.temperature_ruche_001') }}°C"
entity_id: sensor.temperature_ruche_001
trigger_variables:
temp: "{{ states('sensor.temperature_ruche_001') | float(0) }}"
---
# ==============================================================================
# ALERT 2: LOW TEMPERATURE
# ==============================================================================
# Description: Alert when temperature drops below 10°C
# Why: Indicates cold stress or heater malfunction
- id: "alert_low_temperature_ruche_001"
alias: "Alerte Température Basse Ruche 001"
description: "Alert when temperature is too low"
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.temperature_ruche_001
below: 10
for:
hours: 2
action:
- service: persistent_notification.create
data:
notification_id: "temp_low_alert_001"
title: "❄️ Température Basse Ruche 001"
message: >-
Température actuelle: {{ states('sensor.temperature_ruche_001') }}°C
(Alerte < 10°C)
- service: notify.email
data:
title: "❄️ Alerte Température Basse"
message: >-
Température anormalement basse détectée!
Température: {{ states('sensor.temperature_ruche_001') }}°C
---
# ==============================================================================
# ALERT 3: LOW BATTERY
# ==============================================================================
# Description: Alert when battery level drops below 20%
# Why: Indicates need for battery replacement
- id: "alert_low_battery_ruche_001"
alias: "Alerte Batterie Faible Ruche 001"
description: "Notification when battery is low (<20%)"
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.batterie_ruche_001
below: 20
action:
- service: persistent_notification.create
data:
notification_id: "battery_low_alert_001"
title: "🔋 Batterie Faible Ruche 001"
message: >-
Batterie: {{ states('sensor.batterie_ruche_001') }}%
Tension: {{ states('sensor.tension_batterie_ruche_001') }}V
Action: Remplacer les piles dès que possible
- service: notify.email
data:
title: "🔋 Batterie Faible - Action Requise"
message: >-
La batterie de la ruche 001 est faible:
{{ states('sensor.batterie_ruche_001') }}%
Tension: {{ states('sensor.tension_batterie_ruche_001') }}V
Veuillez remplacer les piles (4x AA) dès que possible.
---
# ==============================================================================
# ALERT 4: CRITICAL BATTERY
# ==============================================================================
# Description: Alert when battery drops below 5%
# Why: System will stop working very soon
- id: "alert_critical_battery_ruche_001"
alias: "Alerte Batterie Critique Ruche 001"
description: "Alert when battery is critical (<5%)"
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.batterie_ruche_001
below: 5
action:
- service: persistent_notification.create
data:
notification_id: "battery_critical_alert_001"
title: "🚨 BATTERIE CRITIQUE Ruche 001"
message: >-
BATTERIE CRITIQUE: {{ states('sensor.batterie_ruche_001') }}%
⚠️ DANGER: Le système arrêtera bientôt de fonctionner!
Remplacez immédiatement les piles!
- service: notify.email
data:
title: "🚨 BATTERIE CRITIQUE - REMPLACER IMMÉDIATEMENT"
message: >-
ALERTE URGENTE!
La batterie de la ruche 001 est CRITIQUE:
{{ states('sensor.batterie_ruche_001') }}%
Tension: {{ states('sensor.tension_batterie_ruche_001') }}V
⚠️ Le système s'arrêtera très bientôt!
ACTION IMMÉDIATE REQUISE:
1. Vous rendre à la ruche
2. Remplacer les 4 piles AA
3. Redémarrer le système
---
# ==============================================================================
# ALERT 5: NO DATA RECEIVED
# ==============================================================================
# Description: Alert when no data received for 4 hours
# Why: Indicates WiFi, MQTT, or sensor failure
- id: "alert_no_data_ruche_001"
alias: "Alerte Pas de Données Ruche 001"
description: "Alert when no data received for 4 hours"
mode: single
trigger:
- platform: state
entity_id: sensor.temperature_ruche_001
to: "unavailable"
for:
hours: 4
action:
- service: persistent_notification.create
data:
notification_id: "no_data_alert_001"
title: "❌ Pas de Données Ruche 001"
message: >-
Aucune données reçues depuis 4 heures!
Causes possibles:
- Perte de connexion WiFi
- Batterie épuisée
- Défaillance du capteur
- Problème MQTT
Actions à tenter:
1. Vérifier la connexion WiFi
2. Vérifier la batterie
3. Redémarrer le système Arduino
- service: notify.email
data:
title: "❌ Perte de Connexion Ruche 001"
message: >-
La ruche 001 ne transmet plus de données depuis 4 heures!
Dernière données: {{ as_timestamp(state_attr('sensor.temperature_ruche_001', 'last_updated')) | timestamp_custom('%Y-%m-%d %H:%M:%S') }}
Diagnostique suggéré:
- WiFi déconnecté?
- Batterie épuisée?
- Capteur en panne?
---
# ==============================================================================
# ALERT 6: ABNORMAL WEIGHT LOSS
# ==============================================================================
# Description: Alert if weight loss > 5kg in 24 hours (harvest or queen death)
# Why: Could indicate significant event in hive
- id: "alert_abnormal_weight_loss_ruche_001"
alias: "Alerte Perte Poids Anormale Ruche 001"
description: "Alert if weight loss exceeds normal range"
mode: single
trigger:
- platform: template
value_template: >
{% set current = states('sensor.poids_ruche_001') | float(0) %}
{% set previous = states('sensor.poids_ruche_001', rounded_seconds=86400) | float(0) %}
{{ (previous - current) > 5 and current > 0 }}
action:
- service: persistent_notification.create
data:
notification_id: "weight_loss_alert_001"
title: "📉 Perte de Poids Anormale Ruche 001"
message: >-
Perte de poids importante détectée!
Poids actuel: {{ states('sensor.poids_ruche_001') }}kg
Perte estimée: > 5kg en 24h
Causes possibles:
- Récolte de miel?
- Essaimage?
- Problème grave dans la ruche
Recommandation: Inspection manuelle requise
- service: notify.email
data:
title: "📉 Perte de Poids Importante - Inspection Recommandée"
message: >-
Perte de poids anormale détectée à la ruche 001:
> 5kg en 24 heures
Poids actuel: {{ states('sensor.poids_ruche_001') }}kg
Causes possibles:
- Récolte de miel
- Essaimage ou désertion
- Problème sanitaire
Une inspection manuelle est recommandée.
---
# ==============================================================================
# ALERT 7: HUMIDITY OUT OF RANGE
# ==============================================================================
# Description: Alert if humidity outside 30-80% range
# Why: Indicates ventilation or condensation problems
- id: "alert_humidity_high_ruche_001"
alias: "Alerte Humidité Élevée Ruche 001"
description: "Alert when humidity > 80%"
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.humidity_ruche_001
above: 80
for:
hours: 2
action:
- service: persistent_notification.create
data:
notification_id: "humidity_high_alert_001"
title: "💧 Humidité Élevée Ruche 001"
message: >-
Humidité: {{ states('sensor.humidity_ruche_001') }}%
(Alerte: > 80%)
Recommandations:
- Améliorer la ventilation
- Ajouter des trous d'aération
- Vérifier les fuites d'eau
- service: notify.email
data:
title: "💧 Humidité Élevée - Ventilation à Améliorer"
message: >-
L'humidité de la ruche 001 est trop élevée:
{{ states('sensor.humidity_ruche_001') }}%
Cela peut causer des problèmes de moisissure et de maladies.
---
# ==============================================================================
# DAILY SUMMARY REPORT
# ==============================================================================
# Description: Send daily summary at 20:00
# Why: Provides overview of hive conditions
- id: "daily_summary_ruche_001"
alias: "Rapport Quotidien Ruche 001"
description: "Send daily summary report at 20:00"
mode: single
trigger:
- platform: time
at: "20:00:00"
action:
- service: notify.email
data:
title: "📋 Rapport Quotidien Ruche 001"
message: >
**Rapport Quotidien - {{ now().strftime('%d %B %Y') }}**
**Température:**
- Actuelle: {{ states('sensor.temperature_ruche_001') }}°C
- Min: {{ state_attr('sensor.temperature_ruche_001', 'min_value') | default('N/A') }}°C
- Max: {{ state_attr('sensor.temperature_ruche_001', 'max_value') | default('N/A') }}°C
**Humidité:**
- Actuelle: {{ states('sensor.humidity_ruche_001') }}%
**Poids:**
- Actuel: {{ states('sensor.poids_ruche_001') }}kg
- Net: {{ states('sensor.poids_net_ruche_001') | default('N/A') }}kg
**Batterie:**
- {{ states('sensor.batterie_ruche_001') }}% ({{ states('sensor.tension_batterie_ruche_001') }}V)
**Statuts:**
- Température: {{ states('sensor.etat_temperature_ruche_001') }}
- Batterie: {{ states('sensor.etat_batterie_ruche_001') }}
✅ Tous les systèmes fonctionnent correctement.
- service: logbook.log
data:
name: "Rapport Quotidien"
message: "Rapport quotidien envoyé pour ruche 001"
---
# ==============================================================================
# WEEKLY SUMMARY REPORT
# ==============================================================================
# Description: Send weekly summary every Sunday at 19:00
- id: "weekly_summary_ruche_001"
alias: "Rapport Hebdomadaire Ruche 001"
description: "Send weekly summary report"
mode: single
trigger:
- platform: time
at: "19:00:00"
- platform: time_pattern
weekday: "sun"
action:
- service: notify.email
data:
title: "📊 Rapport Hebdomadaire Ruche 001"
message: >
**Rapport Hebdomadaire**
**Semaine du {{ (now() - timedelta(days=7)).strftime('%d %B') }}
au {{ now().strftime('%d %B %Y') }}**
**Statistiques Température:**
- Moyenne: {{ state_attr('sensor.temperature_ruche_001', 'mean') | default('N/A') }}°C
- Min: {{ state_attr('sensor.temperature_ruche_001', 'min_value') | default('N/A') }}°C
- Max: {{ state_attr('sensor.temperature_ruche_001', 'max_value') | default('N/A') }}°C
**Bilan Poids:**
- Poids actuel: {{ states('sensor.poids_ruche_001') }}kg
- Changement semaine: {{ state_attr('sensor.poids_ruche_001', 'change_week') | default('N/A') }}kg
**Alertes cette semaine:**
- Aucune alerte majeure ✅
**Recommandations:**
- Continuer à surveiller
- Vérifier batterie mensuellement
- Inspecter manuellement avant récolte
---
# ==============================================================================
# TEST AUTOMATION (For verification)
# ==============================================================================
# Description: Test automation that sends message when triggered manually
- id: "test_automation_ruche_001"
alias: "Test - Alerte Test Ruche 001"
description: "Test automation for debugging (comment out after testing)"
mode: single
trigger:
# Manual trigger: Home Assistant → Developer Tools → Automation → Select this automation → Test
platform: event
event_type: "automation_test"
event_data:
automation_id: "test_automation_ruche_001"
action:
- service: persistent_notification.create
data:
notification_id: "test_alert_001"
title: "✅ Test Automatisation Réussi"
message: >
Cette automatisation fonctionne correctement!
Données actuelles:
- Température: {{ states('sensor.temperature_ruche_001') }}°C
- Humidité: {{ states('sensor.humidity_ruche_001') }}%
- Poids: {{ states('sensor.poids_ruche_001') }}kg
- Batterie: {{ states('sensor.batterie_ruche_001') }}%
- service: notify.email
data:
title: "✅ Test Notification Email"
message: "Si vous recevez cet email, les notifications fonctionnent!"
---
# ==============================================================================
# NOTES FOR CUSTOMIZATION
# ==============================================================================
#
# To add these automations to Home Assistant:
#
# 1. Copy the entire content of this file
# 2. In Home Assistant, go to Settings → Automations & Scenes
# 3. Click "Create Automation"
# 4. Click three dots → Edit in YAML
# 5. Paste each automation block (between the "---" lines)
#
# OR
#
# 1. Save this file as /config/automations/arduibeescale_001.yaml
# 2. In configuration.yaml, add:
# automation: !include_dir_list automations/
# 3. Restart Home Assistant
#
# CUSTOMIZATION HINTS:
# - Change entity IDs (sensor.temperature_ruche_001) to match your setup
# - Adjust thresholds (35°C, 20%, etc.) to your preferences
# - Modify email recipients and messages
# - Add additional conditions (e.g., only alert during certain hours)
# - Add multiple hives by duplicating and changing IDs
#
# TESTING:
# - Settings → Automations & Scenes → Automation
# - Click "Test automation" button next to automation name
# - Check Services and Logs for debugging
#
# ==============================================================================