Skip to content

Commit

Permalink
simplify swing selection
Browse files Browse the repository at this point in the history
  • Loading branch information
kongo09 committed Dec 8, 2024
1 parent ff9f587 commit ac9aaca
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/philips_airpurifier_coap/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __init__(
config_entry_data: ConfigEntryData,
heater: str,
available_preset_modes: list[str],
available_oscillation: dict[str, dict[str, str]],
available_oscillation: dict[str, dict[str, Any]],
) -> None:
"""Initialize the select."""

Expand Down
2 changes: 1 addition & 1 deletion custom_components/philips_airpurifier_coap/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class PhilipsApi:
SWITCH_OFF: "0",
}
OSCILLATION_MAP2 = {
SWITCH_ON: [17242, 23040],
SWITCH_ON: 17242,
SWITCH_OFF: 0,
}
OSCILLATION_MAP3 = {
Expand Down
6 changes: 2 additions & 4 deletions custom_components/philips_airpurifier_coap/philips.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,12 @@ async def async_oscillate(self, oscillating: bool) -> None:
on = values.get(SWITCH_ON)
off = values.get(SWITCH_OFF)

on_value = on if isinstance(on, int) else on[0]

if oscillating:
await self.coordinator.client.set_control_value(key, on_value)
await self.coordinator.client.set_control_value(key, on)
else:
await self.coordinator.client.set_control_value(key, off)

self._device_status[key] = on_value if oscillating else off
self._device_status[key] = on if oscillating else off
self._handle_coordinator_update()

@property
Expand Down
2 changes: 1 addition & 1 deletion custom_components/philips_airpurifier_coap/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(
@property
def is_on(self) -> bool:
"""Return if switch is on."""
return self._device_status.get(self.kind) == self._on
return self._device_status.get(self.kind) != self._off

async def async_turn_on(self, **kwargs) -> None:
"""Switch the switch on."""
Expand Down

0 comments on commit ac9aaca

Please sign in to comment.