Skip to content

Commit e08f455

Browse files
committed
Collect context from smile, when present
This works when performing a remove()
1 parent 22dd0ba commit e08f455

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

plugwise/smile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,11 @@ async def set_schedule_state(self, loc_id: str, name: str, state: str) -> bool:
522522

523523
locator = f'.//*[@id="{schema_rule_id}"]/contexts'
524524
contexts = self._domain_objects.find(locator)
525-
subject = f'<context><zone><location id="{loc_id}" /></zone></context>'
526-
subject = etree.fromstring(subject)
525+
locator = f'.//*[@id="{loc_id}"].../...'
526+
subject = contexts.find(locator)
527+
if subject is None:
528+
subject = f'<context><zone><location id="{loc_id}" /></zone></context>'
529+
subject = etree.fromstring(subject)
527530

528531
if state == "off":
529532
self._last_active[loc_id] = name

0 commit comments

Comments
 (0)