-
Notifications
You must be signed in to change notification settings - Fork 1
/
configuration-ha-slovenia-elektro.yaml
96 lines (90 loc) · 3.25 KB
/
configuration-ha-slovenia-elektro.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
template:
- sensor:
- name: "Current Electricity Price"
unit_of_measurement: "EUR/kWh"
icon: "mdi:currency-eur"
state_class: "measurement"
device_class: "monetary"
unique_id: "current_electricity_price"
state: >
{% set season = states('sensor.current_season') %}
{% set block = states('sensor.current_tariff_block') | int %}
{% set is_workday = is_state('binary_sensor.workday_sensor', 'on') %}
{% set energija_vt = 0.118000 * 0.9 + 0.162900 * 0.1 %}
{% set energija_mt = 0.082000 * 0.9 + 0.144900 * 0.1 %}
{% if block == 1 %}
{% set omreznina = 0.00663 + 0.01295 %}
{% set energija = energija_vt %}
{% elif block == 2 %}
{% set omreznina = 0.00620 + 0.01224 %}
{% set energija = energija_vt %}
{% elif block == 3 %}
{% set omreznina = 0.00589 + 0.01248 %}
{% if season == 'High' %}
{% if is_workday %}
{% set energija = energija_mt %}
{% else %}
{% set energija = energija_vt %}
{% endif %}
{% else %}
{% set energija = energija_vt %}
{% endif %}
{% elif block == 4 %}
{% set omreznina = 0.00592 + 0.01246 %}
{% if season == 'High' %}
{% set energija = energija_mt %}
{% else %}
{% if is_workday %}
{% set energija = energija_mt %}
{% else %}
{% set energija = energija_vt %}
{% endif %}
{% endif %}
{% elif block == 5 %}
{% set omreznina = 0.00589 + 0.01258 %}
{% set energija = energija_mt %}
{% else %}
{% set omreznina = 0 %}
{% set energija = 0 %}
{% endif %}
{{ (energija + omreznina + 0.000130 + 0.000800 + 0.001530) * 1.22 | float(6) }}
sensor:
- platform: template
sensors:
current_season:
friendly_name: "Current Season"
value_template: >
{% set month = now().month %}
{% if month in [11, 12, 1, 2] %}
High
{% else %}
Low
{% endif %}
current_tariff_block:
friendly_name: "Current Tariff Block"
value_template: >
{% set hour = now().hour %}
{% set season = states('sensor.current_season') %}
{% set is_workday = is_state('binary_sensor.workday_sensor', 'on') %}
{% if 0 <= hour < 6 %}
{% set block = 3 %}
{% elif hour == 6 %}
{% set block = 2 %}
{% elif 6 <= hour < 14 %}
{% set block = 1 %}
{% elif 14 <= hour < 16 %}
{% set block = 2 %}
{% elif 16 <= hour < 20 %}
{% set block = 1 %}
{% elif 20 <= hour < 22 %}
{% set block = 2 %}
{% else %}
{% set block = 3 %}
{% endif %}
{% if season == 'Low' %}
{% set block = block + 1 %}
{% endif %}
{% if not is_workday %}
{% set block = block + 1 %}
{% endif %}
{{ block }}