Skip to content

Commit ed7c676

Browse files
authored
Merge pull request #96 from lukas-clarke/fix-turn_on_none_error
Fix turn on none error
2 parents 7330972 + f37b3fc commit ed7c676

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
.idea/
161+
# ignoring md files so that context files can be created here
162+
*.md

custom_components/eight_sleep/climate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async def async_setup_entry(
5252
eight,
5353
user,
5454
"climate",
55+
hass,
5556
)
5657
for user in eight.users.values()
5758
]
@@ -80,10 +81,12 @@ def __init__(
8081
eight: EightSleep,
8182
user: EightUser,
8283
sensor: str,
84+
hass: HomeAssistant,
8385
) -> None:
8486
"""Initialize the thermostat."""
8587
super().__init__(entry, coordinator, eight, user, sensor)
86-
self._attr_temperature_unit = self.hass.config.units.temperature_unit
88+
# Set temperature unit and ranges based on Home Assistant config
89+
self._attr_temperature_unit = hass.config.units.temperature_unit
8790
if self._attr_temperature_unit == UnitOfTemperature.CELSIUS:
8891
self._attr_min_temp = MIN_TEMP_C
8992
self._attr_max_temp = MAX_TEMP_C

custom_components/eight_sleep/pyEight/eight.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,20 @@ def room_temperature(self) -> float | None:
333333
tmp = None
334334
tmp2 = None
335335
for user in self.users.values():
336+
current_temp = user.current_room_temp
337+
if current_temp is None:
338+
continue # Skip users with no temperature data
339+
336340
if user.current_session_processing:
337341
if tmp is None:
338-
tmp = user.current_room_temp
342+
tmp = current_temp
339343
else:
340-
tmp = (tmp + user.current_room_temp) / 2
344+
tmp = (tmp + current_temp) / 2
341345
else:
342346
if tmp2 is None:
343-
tmp2 = user.current_room_temp
347+
tmp2 = current_temp
344348
else:
345-
tmp2 = (tmp2 + user.current_room_temp) / 2
349+
tmp2 = (tmp2 + current_temp) / 2
346350

347351
if tmp is not None:
348352
return tmp

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "Eight Sleep Integration",
3-
"homeassistant": "2023.9.1",
3+
"homeassistant": "2025.1.1",
44
"render_readme": true
55
}

0 commit comments

Comments
 (0)