-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_charging_prices.yaml
More file actions
340 lines (306 loc) · 10.9 KB
/
Copy path02_charging_prices.yaml
File metadata and controls
340 lines (306 loc) · 10.9 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
###############################################################################
# packages/02_charging_prices.yaml (FIX + network tariffs)
###############################################################################
input_number:
vat_percent:
name: PVM pirkimui %
min: 0
max: 30
step: 0.1
unit_of_measurement: "%"
mode: box
icon: mdi:percent
initial: 21
dedamosios_buy_eur_kwh:
name: Dedamosios pirkimui (€/kWh)
min: -0.50
max: 1.00
step: 0.0001
unit_of_measurement: "€/kWh"
mode: box
icon: mdi:plus-minus-variant
dedamosios_sell_eur_kwh:
name: Dedamosios pardavimui (€/kWh)
min: -0.50
max: 1.00
step: 0.0001
unit_of_measurement: "€/kWh"
mode: box
icon: mdi:plus-minus-variant
# ---- NAUJA: tinklų dieninis / naktinis tarifas ----
network_day_eur_kwh:
name: Tinklų dieninis tarifas (€/kWh)
min: 0
max: 1
step: 0.0001
unit_of_measurement: "€/kWh"
mode: box
icon: mdi:weather-sunny
network_night_eur_kwh:
name: Tinklų naktinis tarifas (€/kWh)
min: 0
max: 1
step: 0.0001
unit_of_measurement: "€/kWh"
mode: box
icon: mdi:weather-night
input_boolean:
sell_same_as_buy:
name: Pardavimo kaina tokia pati kaip pirkimo
icon: mdi:sync
# >>> VIENAS bendras TEMPLATE blokas <<<
template:
- sensor:
# --- Kainos ir galios ---
- name: "np_base_price_eur_per_kwh"
unique_id: np_base_price_eur_per_kwh
unit_of_measurement: "€/kWh"
state_class: measurement
state: >
{% set p = states('sensor.nord_pool_lt_current_price')|float(0) %}
{% set u = state_attr('sensor.nord_pool_lt_current_price','unit_of_measurement') or '' %}
{{ (p / 1000) if 'MWh' in u else p }}
attributes:
source_entity: sensor.nord_pool_lt_current_price
# ---- NAUJA: tinklų tarifas pagal laiką (diena/naktis, žiema/vasara, savaitgalis) ----
- name: "network_tariff_eur_per_kwh"
unique_id: network_tariff_eur_per_kwh
unit_of_measurement: "€/kWh"
state_class: measurement
icon: mdi:transmission-tower
state: >
{% set day = states('input_number.network_day_eur_kwh')|float(0) %}
{% set night = states('input_number.network_night_eur_kwh')|float(0) %}
{% set now_ = now() %}
{% set weekday = now_.weekday() %} {# 0=Mon, 6=Sun #}
{% set hour = now_.hour %}
{% set is_weekend = weekday >= 5 %}
{% set is_summer = now_.dst().total_seconds() != 0 %}
{# Savaitgaliais visada naktinis #}
{% if is_weekend %}
{{ night }}
{% else %}
{# Darbo dienos #}
{% if is_summer %}
{# Vasara: naktinis 00:00–08:00 #}
{% if hour < 8 %}
{{ night }}
{% else %}
{{ day }}
{% endif %}
{% else %}
{# Žiema: naktinis 23:00–07:00 #}
{% if hour >= 23 or hour < 7 %}
{{ night }}
{% else %}
{{ day }}
{% endif %}
{% endif %}
{% endif %}
- name: "buy_price_eur_per_kwh"
unique_id: buy_price_eur_per_kwh
unit_of_measurement: "€/kWh"
state_class: measurement
icon: mdi:cash-plus
state: >
{% set base = states('sensor.np_base_price_eur_per_kwh')|float(0) %}
{% set vat = states('input_number.vat_percent')|float(21) / 100 %}
{% set add = states('input_number.dedamosios_buy_eur_kwh')|float(0) %}
{% set netw = states('sensor.network_tariff_eur_per_kwh')|float(0) %}
{{ base * (1 + vat) + add + netw }}
- name: "sell_price_eur_per_kwh"
unique_id: sell_price_eur_per_kwh
unit_of_measurement: "€/kWh"
state_class: measurement
icon: mdi:cash-minus
state: >
{% if is_state('input_boolean.sell_same_as_buy','on') %}
{{ states('sensor.buy_price_eur_per_kwh') }}
{% else %}
{% set base = states('sensor.np_base_price_eur_per_kwh')|float(0) %}
{% set add = states('input_number.dedamosios_sell_eur_kwh')|float(0) %}
{{ base - add }}
{% endif %}
- name: "import_power_kw"
unique_id: import_power_kw
unit_of_measurement: "kW"
device_class: power
state_class: measurement
icon: mdi:transmission-tower-import
state: >
{% set w = states('sensor.solis_waveshare_meter_total_active_power')|float(0) %}
{{ (0 - w) / 1000 if w < 0 else 0 }}
- name: "export_power_kw"
unique_id: export_power_kw
unit_of_measurement: "kW"
device_class: power
state_class: measurement
icon: mdi:transmission-tower-export
state: >
{% set w = states('sensor.solis_waveshare_meter_total_active_power')|float(0) %}
{{ w / 1000 if w > 0 else 0 }}
- name: "import_cost_rate_eur_per_h"
unique_id: import_cost_rate_eur_per_h
unit_of_measurement: "€/h"
state_class: measurement
icon: mdi:cash-clock
state: >
{{ states('sensor.import_power_kw')|float(0) * states('sensor.buy_price_eur_per_kwh')|float(0) }}
- name: "export_revenue_rate_eur_per_h"
unique_id: export_revenue_rate_eur_per_h
unit_of_measurement: "€/h"
state_class: measurement
icon: mdi:cash-clock
state: >
{{ states('sensor.export_power_kw')|float(0) * states('sensor.sell_price_eur_per_kwh')|float(0) }}
- name: "net_cost_rate_eur_per_h"
unique_id: net_cost_rate_eur_per_h
unit_of_measurement: "€/h"
state_class: measurement
icon: mdi:scale-balance
state: >
{{ states('sensor.import_cost_rate_eur_per_h')|float(0) - states('sensor.export_revenue_rate_eur_per_h')|float(0) }}
# --- Aliasai integracijoms ir suvestinėms ---
- name: "import_cost_total"
unique_id: import_cost_total_alias
unit_of_measurement: "EUR"
state_class: total_increasing
icon: mdi:currency-eur
state: "{{ states('sensor.import_cost_total_eur')|float(0) }}"
- name: "export_revenue_total"
unique_id: export_revenue_total_alias
unit_of_measurement: "EUR"
state_class: total_increasing
icon: mdi:currency-eur
state: "{{ states('sensor.export_revenue_total_eur')|float(0) }}"
- name: "import_energy"
unique_id: import_energy_alias
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
icon: mdi:transmission-tower-import
state: "{{ states('sensor.import_energy_kwh')|float(0) }}"
- name: "export_energy"
unique_id: export_energy_alias
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
icon: mdi:transmission-tower-export
state: "{{ states('sensor.export_energy_kwh')|float(0) }}"
- name: "net_cost_daily"
unique_id: net_cost_daily
unit_of_measurement: "EUR"
icon: mdi:scale-balance
state: >
{{ states('sensor.import_cost_daily')|float(0) - states('sensor.export_revenue_daily')|float(0) }}
- name: "net_cost_monthly"
unique_id: net_cost_monthly
unit_of_measurement: "EUR"
icon: mdi:scale-balance
state: >
{{ states('sensor.import_cost_monthly')|float(0) - states('sensor.export_revenue_monthly')|float(0) }}
- name: "net_cost_yearly"
unique_id: net_cost_yearly
unit_of_measurement: "EUR"
icon: mdi:scale-balance
state: >
{{ states('sensor.import_cost_yearly')|float(0) - states('sensor.export_revenue_yearly')|float(0) }}
- name: "buy_to_sell_ratio_daily_kwh"
unique_id: buy_to_sell_ratio_daily_kwh
icon: mdi:ratio
state: >
{% set imp = states('sensor.import_energy_daily')|float(0) %}
{% set exp = states('sensor.export_energy_daily')|float(0) %}
{% if exp > 0 %} {{ (imp / exp)|round(3) }} {% else %} {{ None }} {% endif %}
- name: "buy_to_sell_ratio_monthly_kwh"
unique_id: buy_to_sell_ratio_monthly_kwh
icon: mdi:ratio
state: >
{% set imp = states('sensor.import_energy_monthly')|float(0) %}
{% set exp = states('sensor.export_energy_monthly')|float(0) %}
{% if exp > 0 %} {{ (imp / exp)|round(3) }} {% else %} {{ None }} {% endif %}
- name: "buy_to_sell_ratio_yearly_kwh"
unique_id: buy_to_sell_ratio_yearly_kwh
icon: mdi:ratio
state: >
{% set imp = states('sensor.import_energy_yearly')|float(0) %}
{% set exp = states('sensor.export_energy_yearly')|float(0) %}
{% if exp > 0 %} {{ (imp / exp)|round(3) }} {% else %} {{ None }} {% endif %}
sensor:
- platform: integration
unique_id: import_energy_kwh
name: Import Energy kWh
source: sensor.import_power_kw
method: trapezoidal
unit_time: h
round: 3
- platform: integration
unique_id: export_energy_kwh
name: Export Energy kWh
source: sensor.export_power_kw
method: trapezoidal
unit_time: h
round: 3
- platform: integration
unique_id: import_cost_total_eur
name: Import Cost Total EUR
source: sensor.import_cost_rate_eur_per_h
method: trapezoidal
unit_time: h
round: 4
- platform: integration
unique_id: export_revenue_total_eur
name: Export Revenue Total EUR
source: sensor.export_revenue_rate_eur_per_h
method: trapezoidal
unit_time: h
round: 4
utility_meter:
import_cost_daily:
name: Import Cost Daily
source: sensor.import_cost_total
cycle: daily
import_cost_monthly:
name: Import Cost Monthly
source: sensor.import_cost_total
cycle: monthly
import_cost_yearly:
name: Import Cost Yearly
source: sensor.import_cost_total
cycle: yearly
export_revenue_daily:
name: Export Revenue Daily
source: sensor.export_revenue_total
cycle: daily
export_revenue_monthly:
name: Export Revenue Monthly
source: sensor.export_revenue_total
cycle: monthly
export_revenue_yearly:
name: Export Revenue Yearly
source: sensor.export_revenue_total
cycle: yearly
import_energy_daily:
name: Import Energy Daily
source: sensor.import_energy
cycle: daily
import_energy_monthly:
name: Import Energy Monthly
source: sensor.import_energy
cycle: monthly
import_energy_yearly:
name: Import Energy Yearly
source: sensor.import_energy
cycle: yearly
export_energy_daily:
name: Export Energy Daily
source: sensor.export_energy
cycle: daily
export_energy_monthly:
name: Export Energy Monthly
source: sensor.export_energy
cycle: monthly
export_energy_yearly:
name: Export Energy Yearly
source: sensor.export_energy
cycle: yearly