-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesp32-event-automation.yaml
More file actions
67 lines (66 loc) · 1.96 KB
/
esp32-event-automation.yaml
File metadata and controls
67 lines (66 loc) · 1.96 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
alias: "esp32 event "
description: An esp32 has sent a boot or deep sleep event to ha
triggers:
- trigger: event
event_type: esphome.esp32-boot
id: boot
- trigger: event
event_type: esphome.esp32-sleep
id: sleep
conditions: []
actions:
- variables:
esp_device: "{{ trigger.event.data.message.split(' ')[0].replace('-', '_') }}"
purpose: "{{ ' '.join(trigger.event.data.message.split(' ')[1:]) }}"
action: "{{ trigger.id }}"
wake_at: >
{% set ts = trigger.event.data.wake_at | default(0) | int %} {{ " " if
ts == 0 else "wake at " ~ (ts | timestamp_custom("%H:%M:%S")) }}
- action: notify.send_message
metadata: {}
data:
message: >-
{{ now().strftime('%Y-%m-%dT%H:%M:%S') }} {{ purpose}} ({{ esp_device
}}) {{ action }} {{ wake_at }}
target:
entity_id: notify.<your log file >
- choose:
- conditions:
- condition: trigger
id:
- boot
sequence:
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.{{ esp_device }}_online
- conditions:
- condition: trigger
id:
- sleep
sequence:
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.{{ esp_device }}_online
default:
- action: notify.mobile_app_<your phone>
metadata: {}
data:
message: esp32 event automation error
- if:
- condition: template
value_template: >-
{{ (trigger.event.data.notify | default(true) | string | lower) !=
'false' }}
- condition: sun
before: sunset
after: sunrise
then:
- action: notify.mobile_app_<your phone>
metadata: {}
data:
message: "{{ purpose}} ({{ esp_device }}) {{ action }} {{ wake_at }}"
mode: single