|
22 | 22 | NOTIFICATIONS, |
23 | 23 | OFF, |
24 | 24 | RULES, |
| 25 | + STATE_OFF, |
25 | 26 | STATE_ON, |
26 | 27 | GwEntityData, |
27 | 28 | SwitchType, |
@@ -201,11 +202,6 @@ async def set_offset(self, dev_id: str, offset: float) -> None: |
201 | 202 |
|
202 | 203 | async def set_preset(self, loc_id: str, preset: str) -> None: |
203 | 204 | """Set the given Preset on the relevant Thermostat - from LOCATIONS.""" |
204 | | - if (presets := self._presets(loc_id)) is None: |
205 | | - raise PlugwiseError("Plugwise: no presets available.") # pragma: no cover |
206 | | - if preset not in list(presets): |
207 | | - raise PlugwiseError("Plugwise: invalid preset.") |
208 | | - |
209 | 205 | current_location = self._domain_objects.find(f'location[@id="{loc_id}"]') |
210 | 206 | location_name = current_location.find("name").text |
211 | 207 | location_type = current_location.find("type").text |
@@ -311,12 +307,12 @@ async def set_schedule_state( |
311 | 307 | Used in HA Core to set the hvac_mode: in practice switch between schedule on - off. |
312 | 308 | """ |
313 | 309 | # Input checking |
314 | | - if new_state not in ("on", "off"): |
| 310 | + if new_state not in (STATE_OFF, STATE_ON): |
315 | 311 | raise PlugwiseError("Plugwise: invalid schedule state.") |
316 | 312 |
|
317 | 313 | # Translate selection of Off-schedule-option to disabling the active schedule |
318 | 314 | if name == OFF: |
319 | | - new_state = "off" |
| 315 | + new_state = STATE_OFF |
320 | 316 |
|
321 | 317 | # Handle no schedule-name / Off-schedule provided |
322 | 318 | if name is None or name == OFF: |
@@ -369,10 +365,10 @@ def determine_contexts( |
369 | 365 | subject = f'<context><zone><location id="{loc_id}" /></zone></context>' |
370 | 366 | subject = etree.fromstring(subject) |
371 | 367 |
|
372 | | - if state == "off": |
| 368 | + if state == STATE_OFF: |
373 | 369 | self._last_active[loc_id] = name |
374 | 370 | contexts.remove(subject) |
375 | | - if state == "on": |
| 371 | + if state == STATE_ON: |
376 | 372 | contexts.append(subject) |
377 | 373 |
|
378 | 374 | return str(etree.tostring(contexts, encoding="unicode").rstrip()) |
|
0 commit comments