-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolax_remotecontrol_persistence.yaml
127 lines (127 loc) · 4.18 KB
/
solax_remotecontrol_persistence.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
blueprint:
name: Solax Remotecontrol Persistence
description: Ensures that Solax Remotecontrol persists through Home Assistant restarts and when the inverter goes idle.
domain: automation
input:
remotecontrol_trigger:
name: Remotecontrol Trigger
description: The remotecontrol trigger entity.
selector:
entity:
filter:
- domain:
- button
integration: solax_modbus
run_mode:
name: Run mode
description: The run mode of the inverter.
selector:
entity:
filter:
- domain:
- sensor
integration: solax_modbus
wake_inverter:
name: Wake Inverter
description: The action to wake the inverter.
selector:
action:
remotecontrol_autorepeat_duration:
name: Remotecontrol Autorepeat Duration
description: The remotecontrol autorepeat duration entity.
selector:
entity:
filter:
- domain:
- number
integration: solax_modbus
remotecontrol_autorepeat_remaining:
name: Remotecontrol Autorepeat Remaining
description: The remotecontrol autorepeat remaining entity.
selector:
entity:
filter:
- domain:
- sensor
integration: solax_modbus
remotecontrol_autorepeat_end:
name: Remotecontrol Autorepeat End
description: The helper which retains the remotecontrol autorpeat end time in case of a Home Assistant restart.
selector:
entity:
filter:
- domain:
- input_datetime
remotecontrol_power_control:
name: Remotecontrol Power Control
description: The remotecontrol power control entity.
selector:
entity:
filter:
- domain:
- select
integration: solax_modbus
source_url: https://github.com/Excentyl/ha-blueprints/blob/main/solax_remotecontrol_persistence.yaml
variables:
remotecontrol_autorepeat_duration_var: !input remotecontrol_autorepeat_duration
remotecontrol_autorepeat_remaining_var: !input remotecontrol_autorepeat_remaining
remotecontrol_autorepeat_end_var: !input remotecontrol_autorepeat_end
mode: queued
max_exceeded: silent
triggers:
- trigger: state
entity_id: !input remotecontrol_trigger
id: remotecontrol_trigger
- trigger: homeassistant
event: start
id: home_assistant_start
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- remotecontrol_trigger
sequence:
- if:
- condition: state
entity_id: !input run_mode
state: Idle Mode
- condition: not
conditions:
- condition: state
entity_id: !input remotecontrol_power_control
state: Enabled No Discharge
then: !input wake_inverter
- action: input_datetime.set_datetime
metadata: {}
data:
datetime: >-
{{ now() + timedelta(seconds=states(remotecontrol_autorepeat_duration_var) | int) }}
target:
entity_id: !input remotecontrol_autorepeat_end
- conditions:
- condition: trigger
id:
- home_assistant_start
sequence:
- wait_template: >-
{{ states(remotecontrol_autorepeat_remaining_var) | int(-1) != -1 }}
- variables:
duration_remaining: >-
{{ as_timestamp(states(remotecontrol_autorepeat_end_var)) - as_timestamp(now()) }}
- if:
- condition: template
value_template: "{{ duration_remaining > 0 }}"
then:
- action: number.set_value
metadata: {}
data:
value: "{{ duration_remaining }}"
target:
entity_id: !input remotecontrol_autorepeat_duration
- action: button.press
metadata: {}
data: {}
target:
entity_id: !input remotecontrol_trigger