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
| template:
- sensor:
- name: "Electricity price estimation for tomorrow"
state: >
{% set factor_today = this.attributes.factor_today %}
{% set factor_tomorrow = this.attributes.factor_tomorrow %}
{% set difference = factor_tomorrow - factor_today %}
{% if difference > 0.5 %}
Cheaper
{% elif difference < -0.5 %}
More expensive
{% else %}
Around the same
{% endif %}
availability: >
{{ true }}
attributes:
factor_today: >
{% set day = this.attributes.day_today * this.attributes.season_factor_day %}
{% set solar = this.attributes.solar_today * this.attributes.season_factor_solar %}
{% set wind = this.attributes.wind_today * this.attributes.season_factor_wind %}
{% set factor = day + solar + wind %}
{{ factor | round(1) }}
factor_tomorrow: >
{% set day = this.attributes.day_tomorrow * this.attributes.season_factor_day %}
{% set solar = this.attributes.solar_tomorrow * this.attributes.season_factor_solar %}
{% set wind = this.attributes.wind_tomorrow * this.attributes.season_factor_wind %}
{% set factor = day + solar + wind %}
{{ factor | round(1) }}
season_factor_solar: >
{% set factors = {
'summer': 4,
'autumn': 2,
'winter': 1,
'spring': 3
} %}
{{ factors[states('sensor.season')] }}
season_factor_wind: >
{% set factors = {
'summer': 3,
'autumn': 5,
'winter': 6,
'spring': 4
} %}
{{ factors[states('sensor.season')] }}
season_factor_day: >
{% set factors = {
'summer': 3,
'autumn': 3,
'winter': 3,
'spring': 2
} %}
{{ factors[states('sensor.season')] }}
solar_season_max: >
{% set factors = {
'summer': 38,
'autumn': 33,
'winter': 29,
'spring': 40
} %}
{{ factors[states('sensor.season')] }}
solar_today: >
{% set solar_season_max = this.attributes.solar_season_max %}
{% set solar = states('sensor.energy_production_today') | float(0) %}
{{ min([1,solar/solar_season_max]) | round(3) }}
solar_tomorrow: >
{% set solar_season_max = this.attributes.solar_season_max %}
{% set solar = states('sensor.energy_production_tomorrow') | float(0) %}
{{ min([1,solar/solar_season_max]) | round(3) }}
wind_today: >
{% set factors = {
0: 0,
1: 0.02,
2: 0.1,
3: 0.2,
4: 0.3,
5: 0.5,
6: 0.7,
7: 0.9,
8: 1,
9: 0.95,
10: 0.8,
11: 0.3,
12: 0.1,
} %}
{% set wind_bft = states('sensor.weather_wind_force') | float(0) | round %}
{{ factors[wind_bft] }}
wind_tomorrow: >
{% set factors = {
0: 0,
1: 0.02,
2: 0.1,
3: 0.2,
4: 0.3,
5: 0.5,
6: 0.7,
7: 0.9,
8: 1,
9: 0.95,
10: 0.8,
11: 0.3,
12: 0.1,
} %}
{% set wind_bft = states('sensor.weather_wind_force_1d') | float(0) | round %}
{{ factors[wind_bft] }}
day_today: >
{% set factors = {
'Mon': 0.65,
'Tue': 0.6,
'Wed': 0.6,
'Thu': 0.6,
'Fri': 0.7,
'Sat': 0.9,
'Sun': 1,
} %}
{% set day = as_timestamp(now()) | timestamp_custom("%a") %}
{{ factors[day] }}
day_tomorrow: >
{% set factors = {
'Mon': 0.65,
'Tue': 0.6,
'Wed': 0.6,
'Thu': 0.6,
'Fri': 0.7,
'Sat': 0.9,
'Sun': 1,
} %}
{% set day = as_timestamp(now() + timedelta(days=1)) | timestamp_custom("%a") %}
{{ factors[day] }} |