Skip to content

Commit 125e449

Browse files
authored
Merge pull request #264 from plugwise/fix_85910_2
Fix for Core #85910 based on v0.27.1 release
2 parents 9f2d79c + 930d0aa commit 125e449

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
# v0.27.4: Fix for HA Core Issue https://github.com/home-assistant/core/issues/85910
4+
5+
(# v0.27.3, v0.27.2: not released)
6+
37
# v0.27.1: More cooling-related updates, based on additional info from Plugwise
48
- Updates for Anna+Elga and Adam-OnOff systems
59
- Loria/Thermastage fix

plugwise/helper.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,26 @@ def schedules_temps(
144144

145145
length = len(schedule_list)
146146
schedule_list = sorted(schedule_list)
147+
before_first: bool = False
148+
first_schedule_day: int = 0
147149
for i in range(length):
148150
j = (i + 1) % (length)
149151
now = dt.datetime.now().time()
150152
today = dt.datetime.now().weekday()
151153
day_0 = schedule_list[i][0]
152-
day_1 = schedule_list[j][0]
153-
if j < i:
154-
day_1 = schedule_list[i][0] + 2
155154
time_0 = schedule_list[i][1]
155+
day_1 = schedule_list[j][0]
156156
time_1 = schedule_list[j][1]
157+
# Handle Monday-now is before first schedule point
158+
if i == 0 and now < time_0:
159+
before_first = True
160+
first_schedule_day = day_0
161+
# Roll over from end to beginning of schedule = next Monday
162+
if j < i:
163+
day_1 = first_schedule_day + 7 # day_7 = day_0, day_8 = day_1 etc.
164+
# Roll over to next Monday when now is before first schedule point
165+
if today == 0 and before_first:
166+
today = 7
157167
if in_between(today, day_0, day_1, now, time_0, time_1):
158168
return schedule_list[i][2]
159169

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise"
7-
version = "0.27.1"
7+
version = "0.27.4"
88
license = {file = "LICENSE"}
99
description = "Plugwise Smile (Adam/Anna/P1), Stretch and USB (Stick) module for Python 3."
1010
readme = "README.md"

tests/test_smile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ async def device_test(self, smile=pw_smile.Smile, testdata=None):
377377
_LOGGER.info("Asserting testdata:")
378378
bsw_list = ["binary_sensors", "central", "climate", "sensors", "switches"]
379379
# Make sure to test with the day set to Sunday, needed for full testcoverage of schedules_temps()
380-
with freeze_time("2022-05-15 23:59:59"):
380+
with freeze_time("2022-05-16 00:00:01"):
381381
await smile._full_update_device()
382382
smile.get_all_devices()
383383
data = await smile.async_update()

0 commit comments

Comments
 (0)