mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Clean up buggy Guardian switch
context managers (#107426)
This commit is contained in:
parent
50fbcaf20f
commit
e446857001
@ -49,21 +49,25 @@ class ValveControllerSwitchDescription(
|
|||||||
|
|
||||||
async def _async_disable_ap(client: Client) -> None:
|
async def _async_disable_ap(client: Client) -> None:
|
||||||
"""Disable the onboard AP."""
|
"""Disable the onboard AP."""
|
||||||
|
async with client:
|
||||||
await client.wifi.disable_ap()
|
await client.wifi.disable_ap()
|
||||||
|
|
||||||
|
|
||||||
async def _async_enable_ap(client: Client) -> None:
|
async def _async_enable_ap(client: Client) -> None:
|
||||||
"""Enable the onboard AP."""
|
"""Enable the onboard AP."""
|
||||||
|
async with client:
|
||||||
await client.wifi.enable_ap()
|
await client.wifi.enable_ap()
|
||||||
|
|
||||||
|
|
||||||
async def _async_close_valve(client: Client) -> None:
|
async def _async_close_valve(client: Client) -> None:
|
||||||
"""Close the valve."""
|
"""Close the valve."""
|
||||||
|
async with client:
|
||||||
await client.valve.close()
|
await client.valve.close()
|
||||||
|
|
||||||
|
|
||||||
async def _async_open_valve(client: Client) -> None:
|
async def _async_open_valve(client: Client) -> None:
|
||||||
"""Open the valve."""
|
"""Open the valve."""
|
||||||
|
async with client:
|
||||||
await client.valve.open()
|
await client.valve.open()
|
||||||
|
|
||||||
|
|
||||||
@ -141,13 +145,11 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity):
|
|||||||
@convert_exceptions_to_homeassistant_error
|
@convert_exceptions_to_homeassistant_error
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
async with self._client:
|
|
||||||
await self.entity_description.off_fn(self._client)
|
await self.entity_description.off_fn(self._client)
|
||||||
await self.coordinator.async_request_refresh()
|
await self.coordinator.async_request_refresh()
|
||||||
|
|
||||||
@convert_exceptions_to_homeassistant_error
|
@convert_exceptions_to_homeassistant_error
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
async with self._client:
|
|
||||||
await self.entity_description.on_fn(self._client)
|
await self.entity_description.on_fn(self._client)
|
||||||
await self.coordinator.async_request_refresh()
|
await self.coordinator.async_request_refresh()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user