-
Notifications
You must be signed in to change notification settings - Fork 8
/
solis-template.yaml
185 lines (165 loc) · 6.97 KB
/
solis-template.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
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
sensor:
- name: Solis Daily Total load
unique_id: solis_daily_total_load
device_class: energy
state_class: total_increasing
unit_of_measurement: kWh
- name: Solis Date Time (Read Only)
unique_id: solis_date_time_ro
device_class: timestamp
state: >-
{% set y = states('sensor.solis_year_ro')%}
{% set m = states('sensor.solis_month_ro')%}
{% set d = states('sensor.solis_day_ro')%}
{% set h = states('sensor.solis_hour_ro')%}
{% set t = states('sensor.solis_minute_ro')%}
{% set dt = y + "-" + m + "-" + d + " " + h + ":" + t %}
{{as_local(strptime(dt, "%y-%m-%d %H:%M"))}}
- name: Solis Date Time (Read/Write)
unique_id: solis_date_time_rw
device_class: timestamp
state: >-
{% set y = states('sensor.solis_year_rw')%}
{% set m = states('sensor.solis_month_rw')%}
{% set d = states('sensor.solis_day_rw')%}
{% set h = states('sensor.solis_hour_rw')%}
{% set t = states('sensor.solis_minute_rw')%}
{% set s = states('sensor.solis_second_rw')%}
{% set dt = y + "-" + m + "-" + d + " " + h + ":" + t + ":" + s %}
{{as_local(strptime(dt, "%y-%m-%d %H:%M:%S"))}}
- name: "Solis Grid Active Power (Negative)"
unique_id: "Solis Grid Active Power (Negative)"
unit_of_measurement: W
device_class: power
state_class: measurement
state: >-
{{ -1 * states('sensor.solis_grid_active_power') | float }}
- name: "Solis Grid Export Power"
unique_id: "Solis Grid Export Power"
unit_of_measurement: W
device_class: power
state_class: measurement
state: >-
{% set state = states.sensor.solis_grid_active_power.state | float %}
{{ state if state > 0 else 0 }}
- name: "Solis Grid Import Power"
unique_id: "Solis Grid Import Power"
unit_of_measurement: W
device_class: power
state_class: measurement
state: >-
{% set state = states.sensor.solis_grid_active_power.state | float %}
{{ -1 * state if state < 0 else 0 }}
- name: "Solis Grid Mode"
unique_id: "Solis Grid Mode"
state: >-
{% set state = states.sensor.solis_grid_active_power.state | float %}
{% if state > 50 -%}
Export
{%- elif state <-50 -%}
Import
{%- else -%}
Zero
{%- endif %}
- name: "Solis Battery Mode"
unique_id: "Solis Battery Mode"
state: >-
{% set state = states.sensor.solis_battery_current_direction.state | int %}
{{ 'Discharge' if state > 0 else 'Charge' }}
- name: "Solis Manual Storage Mode"
unique_id: "Solis Manual Storage Mode"
state: >-
{{(states('input_boolean.solis_storage_mode_spontaneous') == 'on') | int
+ 2 * (states('input_boolean.solis_storage_mode_timed') == 'on') | int
+ 4 * (states('input_boolean.solis_storage_mode_off_grid') == 'on') | int
+ 8 * (states('input_boolean.solis_storage_mode_wake_up') == 'on') | int
+ 16 * (states('input_boolean.solis_storage_mode_backup') == 'on') | int
+ 32 * (states('input_boolean.solis_storage_mode_grid_charge') == 'on') | int
+ 64 * (states('input_boolean.solis_solis_storage_mode_feed_in_priority') == 'on') | int
}}
- name: "Solis Eco7 Time Remaining"
unique_id: "Solis Eco7 Time Remaining"
state_class: measurement
state: >-
{% if today_at(states('input_datetime.economy_7_end')) < now() -%}
{{(((today_at(states('input_datetime.economy_7_end')) -
today_at(states('input_datetime.economy_7_start')))).total_seconds() / 36) | int / 100}}
{%- else -%}
{{max((((today_at(states('input_datetime.economy_7_end')) -
max(now(), today_at(states('input_datetime.economy_7_start')))).total_seconds() / 36) | int) / 100,0)}}
{%- endif %}
- name: "Solis Flux Discharge Hours Remaining"
unique_id: "Solis Flux Discharge Time Remaining"
state_class: measurement
state: >-
{% if today_at(states('input_datetime.flux_discharge_end')) < now() -%}
{{(((today_at(states('input_datetime.flux_discharge_end')) -
today_at(states('input_datetime.flux_discharge_start')))).total_seconds() / 36) | int / 100}}
{%- else -%}
{{max((((today_at(states('input_datetime.flux_discharge_end')) -
max(now(), today_at(states('input_datetime.flux_discharge_start')))).total_seconds() / 36) | int) / 100,0)}}
{%- endif %}
- name: "Solis Eco7 Charge Current"
unique_id: "Solis Eco7 Charge Current"
device_class: current
state_class: measurement
unit_of_measurement: A
state: >-
{{(
((states('input_number.solis_battery_capacity') | int * 1000) *
((states('input_number.eco7_target_soc') | int) - (states('sensor.solis_battery_soc') | int))
)
/ 10
/
(states('sensor.solis_eco7_time_remaining') | float)
/ (states('sensor.solis_battery_voltage_bms') | float) ) | int / 10
}}
- name: "Solis Flux Discharge Current"
unique_id: "Solis Flux Discharge Current"
device_class: current
state_class: measurement
unit_of_measurement: A
state: >-
{% set value = (
((states('input_number.solis_battery_capacity') | int * 1000) *
((states('sensor.solis_battery_soc') | int) - (states('input_number.flux_target_soc') | int))
)
/ 10
/
(states('sensor.solis_flux_discharge_hours_remaining') | float)
/ (states('sensor.solis_battery_voltage_bms') | float) ) | int / 10 %}
{{ value if value >= 0 else 0 }}
- name: "Solis Battery Charge Power"
unique_id: "Solis Battery Charge Power"
device_class: power
state_class: measurement
unit_of_measurement: W
state: >-
{% set state = states.sensor.solis_battery_current_direction.state | int %}
{{ 0 if state > 0 else states('sensor.solis_battery_power') | float(2) }}
- name: "Solis Battery Discharge Power"
unique_id: "Solis Battery Discharge Power"
device_class: power
state_class: measurement
unit_of_measurement: W
state: >-
{% set state = states.sensor.solis_battery_current_direction.state | int %}
{{ states('sensor.solis_battery_power') | float(2) if state > 0 else 0 }}
- name: 'Target Battery Charge Weekday'
unique_id: 'sensor.target_battery_charge_weekday'
unit_of_measurement: '%'
icon: mdi:battery-90
state: >
{% set charge_end = states('input_number.end_of_day_charge_required') | float %}
{% set charge_now = states('input_number.start_of_day_charge_required') | float %}
{% set home_consumption = states('input_number.daytime_charge_required') | float %}
{% set forecast = states('sensor.energy_production_today') | float %}
{% set capacity = 13 %}
{% set target_charge = ((charge_end + charge_now + home_consumption - forecast) / capacity) * 100 %}
{% if target_charge < 32 %}
{{ 32 }}
{% elif target_charge > 100 %}
{{ 100 }}
{% else %}
{{ target_charge | round(0, default=0) }}
{% endif %}