Skip to content

Commit b0d6e03

Browse files
authored
Merge pull request #8 from avataar/update-prices-jan-2025
Updated prices as of January 2025
2 parents ff0df1c + d7b2b2f commit b0d6e03

File tree

2 files changed

+168
-95
lines changed

2 files changed

+168
-95
lines changed

custom_components/bg_electricity_regulated_pricing/const.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,61 @@
2323
"electrohold": {
2424
"day": .14875,
2525
"night": .05997,
26-
"fees": .01623 + .00754 + .04232
26+
"fees": .00102 + .01521 + .00754 + .04232
2727
},
2828
# Section 6.2, https://www.dker.bg/uploads/reshenia/2023/res_c_14_23.pdf
2929
"evn": {
3030
"day": .14667,
3131
"night": .05531,
32-
"fees": .01623 + .00803 + .04366
32+
"fees": .00102 + .01521 + .00803 + .04366
3333
},
3434
# Section 6.3, https://www.dker.bg/uploads/reshenia/2023/res_c_14_23.pdf
3535
"energo_pro": {
3636
"day": .15076,
3737
"night": .05279,
38-
"fees": .01623 + .00959 + .04825
38+
"fees": .00102 + .01521 + .00959 + .04825
3939
}
4040
}
4141

42-
PROVIDER_PRICES = {
42+
PROVIDER_PRICES_BEFORE_JANUARY_2025 = {
4343
# Section 6.1, https://www.dker.bg/uploads/reshenia/2024/res-c-17-2024.pdf
4444
"electrohold": {
4545
"day": .16210,
4646
"night": .07104,
47-
"fees": .01354 + .00770 + .03803
47+
"fees": .00085 + .0127 + .00770 + .03803
4848
},
4949
# Section 6.2, https://www.dker.bg/uploads/reshenia/2024/res-c-17-2024.pdf
5050
"evn": {
5151
"day": .15926,
5252
"night": .06833,
53-
"fees": .01354 + .00819 + .03704
53+
"fees": .00085 + .0127 + .00819 + .03704
5454
},
5555
# Section 6.3, https://www.dker.bg/uploads/reshenia/2024/res-c-17-2024.pdf
5656
"energo_pro": {
5757
"day": .16341,
5858
"night": .06636,
59-
"fees": .01354 + .00977 + .03689
59+
"fees": .00085 + .0127 + .00977 + .03689
60+
}
61+
}
62+
63+
PROVIDER_PRICES = {
64+
# Section II.1, II.3, II.7, https://www.dker.bg/uploads/reshenia/2025/res_c-03_25.pdf
65+
"electrohold": {
66+
"day": .17564,
67+
"night": .07698,
68+
"fees": .00085 + .01366 + .00770 + .04203
69+
},
70+
# Section II.1, II.4, II.8, https://www.dker.bg/uploads/reshenia/2025/res_c-03_25.pdf
71+
"evn": {
72+
"day": .17257,
73+
"night": .07404,
74+
"fees": .00085 + .01366 + .00819 + .04106
75+
},
76+
# Section II.1, II.5, II.9, https://www.dker.bg/uploads/reshenia/2025/res_c-03_25.pdf
77+
"energo_pro": {
78+
"day": .17706,
79+
"night": .07192,
80+
"fees": .00085 + .01366 + .00977 + .04135
6081
}
6182
}
6283

@@ -65,6 +86,10 @@
6586
"until": 1719777600, # midnight 2024-07-01 UTC+2
6687
"prices": PROVIDER_PRICES_BEFORE_JULY_2024
6788
},
89+
{
90+
"until": 1735682400, # midnight 2025-01-01 UTC+2
91+
"prices": PROVIDER_PRICES_BEFORE_JANUARY_2025
92+
},
6893
{
6994
"prices": PROVIDER_PRICES
7095
}

tests/test_init.py

Lines changed: 136 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,37 @@
3030
}
3131
}
3232

33+
EXPECTED_PRICES_BEFORE_JANUARY_2025 = {
34+
"electrohold": {
35+
"day": 0.265656,
36+
"night": 0.156384
37+
},
38+
"evn": {
39+
"day": 0.261648,
40+
"night": 0.152532
41+
},
42+
"energo_pro": {
43+
"day": 0.268344,
44+
"night": 0.151884
45+
},
46+
"custom": {
47+
"day": 0.25,
48+
"night": 0.15
49+
}
50+
}
51+
3352
EXPECTED_PRICES = {
3453
"electrohold": {
35-
"day": 0.265644,
36-
"night": 0.156372
54+
"day": 0.287856,
55+
"night": 0.169464
3756
},
3857
"evn": {
39-
"day": 0.261636,
40-
"night": 0.15252
58+
"day": 0.283596,
59+
"night": 0.16536
4160
},
4261
"energo_pro": {
43-
"day": 0.268332,
44-
"night": 0.151872
62+
"day": 0.291228,
63+
"night": 0.16506
4564
},
4665
"custom": {
4766
"day": 0.25,
@@ -54,94 +73,114 @@
5473
"until": 1719777600, # midnight 2024-07-01 UTC+2
5574
"prices": EXPECTED_PRICES_BEFORE_JULY_2024
5675
},
76+
{
77+
"until": 1735682400, # midnight 2025-01-01 UTC+2
78+
"prices": EXPECTED_PRICES_BEFORE_JANUARY_2025
79+
},
5780
{
5881
"prices": EXPECTED_PRICES
5982
}
6083
]
6184

6285

6386
@pytest.mark.parametrize("provider", ("electrohold", "evn", "energo_pro", "custom"))
64-
async def test_setup_and_remove_config_entry(hass: HomeAssistant,
65-
provider: str) -> None:
66-
"""Test setting up and removing a config entry."""
67-
for mp in [[mock_time, EXPECTED_PRICES], [mock_time_before_july_2024, EXPECTED_PRICES_BEFORE_JULY_2024]]:
68-
mock = mp[0]
69-
expected_prices = mp[1]
70-
with mock(21, 59):
71-
await do_setup_test(hass, provider, "dual", "day",
72-
expected_prices)
73-
await do_setup_test(hass, provider, "single", "day",
74-
expected_prices)
75-
76-
with mock(22, 0):
77-
await do_setup_test(hass, provider, "dual", "night",
78-
expected_prices)
79-
await do_setup_test(hass, provider, "single", "day",
80-
expected_prices)
81-
82-
with mock(5, 59):
83-
await do_setup_test(hass, provider, "dual", "night",
84-
expected_prices)
85-
await do_setup_test(hass, provider, "single", "day",
86-
expected_prices)
87-
88-
with mock(6, 0):
89-
await do_setup_test(hass, provider, "dual", "day",
90-
expected_prices)
91-
await do_setup_test(hass, provider, "single", "day",
92-
expected_prices)
93-
94-
# Meter clock is 30 minutes ahead
95-
with mock(21, 30):
96-
await do_setup_test(hass, provider, "dual", "night",
97-
expected_prices, 30)
98-
await do_setup_test(hass, provider, "single", "day",
99-
expected_prices, 30)
100-
101-
with mock(5, 30):
102-
await do_setup_test(hass, provider, "dual", "day",
103-
expected_prices, 30)
104-
await do_setup_test(hass, provider, "single", "day",
105-
expected_prices, 30)
106-
107-
# Meter clock is 30 minutes behind
108-
with mock(22, 29):
109-
await do_setup_test(hass, provider, "dual", "day",
110-
expected_prices, -30)
111-
await do_setup_test(hass, provider, "single", "day",
112-
expected_prices, -30)
113-
114-
with mock(6, 29):
115-
await do_setup_test(hass, provider, "dual", "night",
116-
expected_prices, -30)
117-
await do_setup_test(hass, provider, "single", "day",
118-
expected_prices, -30)
119-
120-
# Meter clock is 10 hours ahead
121-
with mock(12, 0):
122-
await do_setup_test(hass, provider, "dual", "night",
123-
expected_prices, 600)
124-
await do_setup_test(hass, provider, "single", "day",
125-
expected_prices, 600)
126-
127-
with mock(20, 0):
128-
await do_setup_test(hass, provider, "dual", "day",
129-
expected_prices, 600)
130-
await do_setup_test(hass, provider, "single", "day",
131-
expected_prices, 600)
132-
133-
# Meter clock is 10 hours behind
134-
with mock(8, 0):
135-
await do_setup_test(hass, provider, "dual", "night",
136-
expected_prices, -600)
137-
await do_setup_test(hass, provider, "single", "day",
138-
expected_prices, -600)
139-
140-
with mock(16, 0):
141-
await do_setup_test(hass, provider, "dual", "day",
142-
expected_prices, -600)
143-
await do_setup_test(hass, provider, "single", "day",
144-
expected_prices, -600)
87+
async def test_prices_before_july_2024(hass: HomeAssistant, provider: str) -> None:
88+
"""Test setting up and removing a config entry before July 2024."""
89+
await do_setup_test_with_mock(hass, provider, mock_time_before_july_2024,
90+
EXPECTED_PRICES_BEFORE_JULY_2024)
91+
92+
93+
@pytest.mark.parametrize("provider", ("electrohold", "evn", "energo_pro", "custom"))
94+
async def test_prices_before_january_2025(hass: HomeAssistant, provider: str) -> None:
95+
"""Test setting up and removing a config entry before January 2025."""
96+
await do_setup_test_with_mock(hass, provider, mock_time_before_january_2025,
97+
EXPECTED_PRICES_BEFORE_JANUARY_2025)
98+
99+
100+
@pytest.mark.parametrize("provider", ("electrohold", "evn", "energo_pro", "custom"))
101+
async def test_prices_current(hass: HomeAssistant, provider: str) -> None:
102+
"""Test setting up and removing a config entry with current prices."""
103+
await do_setup_test_with_mock(hass, provider, mock_time,
104+
EXPECTED_PRICES)
105+
106+
107+
async def do_setup_test_with_mock(hass: HomeAssistant,
108+
provider: str, mock, expected_prices) -> None:
109+
with mock(21, 59):
110+
await do_setup_test(hass, provider, "dual", "day",
111+
expected_prices)
112+
await do_setup_test(hass, provider, "single", "day",
113+
expected_prices)
114+
115+
with mock(22, 0):
116+
await do_setup_test(hass, provider, "dual", "night",
117+
expected_prices)
118+
await do_setup_test(hass, provider, "single", "day",
119+
expected_prices)
120+
121+
with mock(5, 59):
122+
await do_setup_test(hass, provider, "dual", "night",
123+
expected_prices)
124+
await do_setup_test(hass, provider, "single", "day",
125+
expected_prices)
126+
127+
with mock(6, 0):
128+
await do_setup_test(hass, provider, "dual", "day",
129+
expected_prices)
130+
await do_setup_test(hass, provider, "single", "day",
131+
expected_prices)
132+
133+
# Meter clock is 30 minutes ahead
134+
with mock(21, 30):
135+
await do_setup_test(hass, provider, "dual", "night",
136+
expected_prices, 30)
137+
await do_setup_test(hass, provider, "single", "day",
138+
expected_prices, 30)
139+
140+
with mock(5, 30):
141+
await do_setup_test(hass, provider, "dual", "day",
142+
expected_prices, 30)
143+
await do_setup_test(hass, provider, "single", "day",
144+
expected_prices, 30)
145+
146+
# Meter clock is 30 minutes behind
147+
with mock(22, 29):
148+
await do_setup_test(hass, provider, "dual", "day",
149+
expected_prices, -30)
150+
await do_setup_test(hass, provider, "single", "day",
151+
expected_prices, -30)
152+
153+
with mock(6, 29):
154+
await do_setup_test(hass, provider, "dual", "night",
155+
expected_prices, -30)
156+
await do_setup_test(hass, provider, "single", "day",
157+
expected_prices, -30)
158+
159+
# Meter clock is 10 hours ahead
160+
with mock(12, 0):
161+
await do_setup_test(hass, provider, "dual", "night",
162+
expected_prices, 600)
163+
await do_setup_test(hass, provider, "single", "day",
164+
expected_prices, 600)
165+
166+
with mock(20, 0):
167+
await do_setup_test(hass, provider, "dual", "day",
168+
expected_prices, 600)
169+
await do_setup_test(hass, provider, "single", "day",
170+
expected_prices, 600)
171+
172+
# Meter clock is 10 hours behind
173+
with mock(8, 0):
174+
await do_setup_test(hass, provider, "dual", "night",
175+
expected_prices, -600)
176+
await do_setup_test(hass, provider, "single", "day",
177+
expected_prices, -600)
178+
179+
with mock(16, 0):
180+
await do_setup_test(hass, provider, "dual", "day",
181+
expected_prices, -600)
182+
await do_setup_test(hass, provider, "single", "day",
183+
expected_prices, -600)
145184

146185

147186
async def do_setup_test(hass: HomeAssistant, provider: str, tariff_type: str,
@@ -215,10 +254,19 @@ def mock_time_before_july_2024(hour: int, minute: int):
215254
return_value=datetime(2023, 12, 23, hour, minute, 0, 0, pytz.UTC))
216255

217256

257+
def mock_time_before_january_2025(hour: int, minute: int):
258+
hour -= 2
259+
if hour < 0:
260+
hour += 24
261+
return mock.patch(
262+
"custom_components.bg_electricity_regulated_pricing.sensor.now_utc",
263+
return_value=datetime(2024, 12, 30, hour, minute, 0, 0, pytz.UTC))
264+
265+
218266
def mock_time(hour: int, minute: int):
219267
hour -= 2
220268
if hour < 0:
221269
hour += 24
222270
return mock.patch(
223271
"custom_components.bg_electricity_regulated_pricing.sensor.now_utc",
224-
return_value=datetime(2024, 7, 1, hour, minute, 0, 0, pytz.UTC))
272+
return_value=datetime(2025, 1, 1, hour, minute, 0, 0, pytz.UTC))

0 commit comments

Comments
 (0)