-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset auto.yaml
51 lines (49 loc) · 1.32 KB
/
reset auto.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
- id: reset_pzem_004t_on_button
alias: Reset Energy Consumption on Button
description: ''
trigger:
- platform: state
entity_id: input_button.pzem_004t_button1
condition: []
action:
- service: automation.trigger
data:
skip_condition: true
target:
entity_id: automation.reset_energy_consumption_every_month
initial_state: 'on'
- id: reset_pzem_004t_every_month
alias: Reset Energy Consumption every Month
description: ''
trigger:
- platform: time
at: '00:00:01'
- platform: homeassistant
event: start
condition:
- condition: template
value_template: >
{% if now().day == 1 -%}
{{ now() - state_attr('automation.reset_energy_consumption_every_month', 'last_triggered') > timedelta(hours=24) }}
{%- else -%}
False
{%- endif %}
action:
- service: shell_command.send_reset_to_pzem_004t
data: {}
mode: single
- id: set_power_alarm_of_pzem_004t_on_button
alias: Set Power Alarm on Button
description: ''
trigger:
- platform: state
entity_id:
- input_button.pzem_004t_button0
condition: []
action:
- service: modbus.write_register
data:
address: 1
hub: PZEM_004T_V3
value: '{{ states(''input_number.pzem_004t_box1'') | round(0) }}'
mode: single