-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoil-moisture-automation.yaml
More file actions
54 lines (53 loc) · 1.33 KB
/
soil-moisture-automation.yaml
File metadata and controls
54 lines (53 loc) · 1.33 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
alias: Soil Moisture
description: ""
triggers:
- trigger: state
entity_id:
- input_boolean.esp32_8_online
to: "on"
id: esp32-8
- trigger: state
entity_id:
- input_boolean.esp32_10_online
to: "on"
id: esp32-10
conditions: []
actions:
- variables:
target_hour: 17
target_minute: 0
now_ts: "{{ as_timestamp(now()) }}"
today_target_ts: >
{{ as_timestamp(now().replace(hour=target_hour, minute=target_minute,
second=0)) }}
target_ts: |
{% if now_ts >= today_target_ts or (today_target_ts - now_ts) < 1800 %}
{{ today_target_ts + 86400 }}
{% else %}
{{ today_target_ts }}
{% endif %}
sleep_duration_ms: "{{ ((target_ts - now_ts) * 1000) | int }}"
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- choose:
- conditions:
- condition: trigger
id:
- esp32-8
sequence:
- action: esphome.esp32_8_enter_deep_sleep
data:
duration: "{{ sleep_duration_ms }}"
- conditions:
- condition: trigger
id:
- esp32-10
sequence:
- action: esphome.esp32_10_enter_deep_sleep
data:
duration: "{{ sleep_duration_ms }}"
mode: parallel
max: 2