Skip to content

Commit 946affd

Browse files
committed
Handle last_used == None
1 parent 8bd14ff commit 946affd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

plugwise/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,15 +611,17 @@ async def set_schedule_state(
611611
"""Activate/deactivate the Schedule, with the given name, on the relevant Thermostat.
612612
613613
Determined from - DOMAIN_OBJECTS.
614-
In HA Core used to set the hvac_mode: in practice switch between schedule on - off.
614+
Used in HA Core to set the hvac_mode: in practice switch between schedule on - off.
615615
"""
616616
# Input checking
617617
if new_state not in ["on", "off"]:
618618
raise PlugwiseError("Plugwise: invalid schedule state.")
619619
if name is None:
620620
for device in self.gw_devices:
621-
if device["location"] == loc_id:
621+
if device["location"] == loc_id and device["last_used"]:
622622
name = device["last_used"]
623+
else:
624+
return
623625

624626
if self._smile_legacy:
625627
await self._set_schedule_state_legacy(loc_id, name, new_state)

0 commit comments

Comments
 (0)