Update pywmspro to 0.3.0 to wait for short-lived actions (#147679)

Replace action delays with detailed action responses.
This commit is contained in:
Marc Hörsken 2025-06-29 07:33:44 +02:00 committed by GitHub
parent 8bacab4f9c
commit 617ea1925c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 19 deletions

View File

@ -2,13 +2,13 @@
from __future__ import annotations from __future__ import annotations
import asyncio
from datetime import timedelta from datetime import timedelta
from typing import Any from typing import Any
from wmspro.const import ( from wmspro.const import (
WMS_WebControl_pro_API_actionDescription, WMS_WebControl_pro_API_actionDescription,
WMS_WebControl_pro_API_actionType, WMS_WebControl_pro_API_actionType,
WMS_WebControl_pro_API_responseType,
) )
from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity
@ -18,7 +18,6 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import WebControlProConfigEntry from . import WebControlProConfigEntry
from .entity import WebControlProGenericEntity from .entity import WebControlProGenericEntity
ACTION_DELAY = 0.5
SCAN_INTERVAL = timedelta(seconds=10) SCAN_INTERVAL = timedelta(seconds=10)
PARALLEL_UPDATES = 1 PARALLEL_UPDATES = 1
@ -61,7 +60,6 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
action = self._dest.action(self._drive_action_desc) action = self._dest.action(self._drive_action_desc)
await action(percentage=100 - kwargs[ATTR_POSITION]) await action(percentage=100 - kwargs[ATTR_POSITION])
await asyncio.sleep(ACTION_DELAY)
@property @property
def is_closed(self) -> bool | None: def is_closed(self) -> bool | None:
@ -72,13 +70,11 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
"""Open the cover.""" """Open the cover."""
action = self._dest.action(self._drive_action_desc) action = self._dest.action(self._drive_action_desc)
await action(percentage=0) await action(percentage=0)
await asyncio.sleep(ACTION_DELAY)
async def async_close_cover(self, **kwargs: Any) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
action = self._dest.action(self._drive_action_desc) action = self._dest.action(self._drive_action_desc)
await action(percentage=100) await action(percentage=100)
await asyncio.sleep(ACTION_DELAY)
async def async_stop_cover(self, **kwargs: Any) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the device if in motion.""" """Stop the device if in motion."""
@ -86,8 +82,7 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
WMS_WebControl_pro_API_actionDescription.ManualCommand, WMS_WebControl_pro_API_actionDescription.ManualCommand,
WMS_WebControl_pro_API_actionType.Stop, WMS_WebControl_pro_API_actionType.Stop,
) )
await action() await action(responseType=WMS_WebControl_pro_API_responseType.Detailed)
await asyncio.sleep(ACTION_DELAY)
class WebControlProAwning(WebControlProCover): class WebControlProAwning(WebControlProCover):

View File

@ -2,11 +2,13 @@
from __future__ import annotations from __future__ import annotations
import asyncio
from datetime import timedelta from datetime import timedelta
from typing import Any from typing import Any
from wmspro.const import WMS_WebControl_pro_API_actionDescription from wmspro.const import (
WMS_WebControl_pro_API_actionDescription,
WMS_WebControl_pro_API_responseType,
)
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -17,7 +19,6 @@ from . import WebControlProConfigEntry
from .const import BRIGHTNESS_SCALE from .const import BRIGHTNESS_SCALE
from .entity import WebControlProGenericEntity from .entity import WebControlProGenericEntity
ACTION_DELAY = 0.5
SCAN_INTERVAL = timedelta(seconds=15) SCAN_INTERVAL = timedelta(seconds=15)
PARALLEL_UPDATES = 1 PARALLEL_UPDATES = 1
@ -56,14 +57,16 @@ class WebControlProLight(WebControlProGenericEntity, LightEntity):
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the light on.""" """Turn the light on."""
action = self._dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch) action = self._dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
await action(onOffState=True) await action(
await asyncio.sleep(ACTION_DELAY) onOffState=True, responseType=WMS_WebControl_pro_API_responseType.Detailed
)
async def async_turn_off(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the light off.""" """Turn the light off."""
action = self._dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch) action = self._dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
await action(onOffState=False) await action(
await asyncio.sleep(ACTION_DELAY) onOffState=False, responseType=WMS_WebControl_pro_API_responseType.Detailed
)
class WebControlProDimmer(WebControlProLight): class WebControlProDimmer(WebControlProLight):
@ -90,6 +93,6 @@ class WebControlProDimmer(WebControlProLight):
WMS_WebControl_pro_API_actionDescription.LightDimming WMS_WebControl_pro_API_actionDescription.LightDimming
) )
await action( await action(
percentage=brightness_to_value(BRIGHTNESS_SCALE, kwargs[ATTR_BRIGHTNESS]) percentage=brightness_to_value(BRIGHTNESS_SCALE, kwargs[ATTR_BRIGHTNESS]),
responseType=WMS_WebControl_pro_API_responseType.Detailed,
) )
await asyncio.sleep(ACTION_DELAY)

View File

@ -14,5 +14,5 @@
"documentation": "https://www.home-assistant.io/integrations/wmspro", "documentation": "https://www.home-assistant.io/integrations/wmspro",
"integration_type": "hub", "integration_type": "hub",
"iot_class": "local_polling", "iot_class": "local_polling",
"requirements": ["pywmspro==0.2.2"] "requirements": ["pywmspro==0.3.0"]
} }

2
requirements_all.txt generated
View File

@ -2596,7 +2596,7 @@ pywilight==0.0.74
pywizlight==0.6.3 pywizlight==0.6.3
# homeassistant.components.wmspro # homeassistant.components.wmspro
pywmspro==0.2.2 pywmspro==0.3.0
# homeassistant.components.ws66i # homeassistant.components.ws66i
pyws66i==1.1 pyws66i==1.1

View File

@ -2154,7 +2154,7 @@ pywilight==0.0.74
pywizlight==0.6.3 pywizlight==0.6.3
# homeassistant.components.wmspro # homeassistant.components.wmspro
pywmspro==0.2.2 pywmspro==0.3.0
# homeassistant.components.ws66i # homeassistant.components.ws66i
pyws66i==1.1 pyws66i==1.1