mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
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:
parent
8bacab4f9c
commit
617ea1925c
@ -2,13 +2,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
from wmspro.const import (
|
||||
WMS_WebControl_pro_API_actionDescription,
|
||||
WMS_WebControl_pro_API_actionType,
|
||||
WMS_WebControl_pro_API_responseType,
|
||||
)
|
||||
|
||||
from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity
|
||||
@ -18,7 +18,6 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from . import WebControlProConfigEntry
|
||||
from .entity import WebControlProGenericEntity
|
||||
|
||||
ACTION_DELAY = 0.5
|
||||
SCAN_INTERVAL = timedelta(seconds=10)
|
||||
PARALLEL_UPDATES = 1
|
||||
|
||||
@ -61,7 +60,6 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
|
||||
"""Move the cover to a specific position."""
|
||||
action = self._dest.action(self._drive_action_desc)
|
||||
await action(percentage=100 - kwargs[ATTR_POSITION])
|
||||
await asyncio.sleep(ACTION_DELAY)
|
||||
|
||||
@property
|
||||
def is_closed(self) -> bool | None:
|
||||
@ -72,13 +70,11 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
|
||||
"""Open the cover."""
|
||||
action = self._dest.action(self._drive_action_desc)
|
||||
await action(percentage=0)
|
||||
await asyncio.sleep(ACTION_DELAY)
|
||||
|
||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||
"""Close the cover."""
|
||||
action = self._dest.action(self._drive_action_desc)
|
||||
await action(percentage=100)
|
||||
await asyncio.sleep(ACTION_DELAY)
|
||||
|
||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||
"""Stop the device if in motion."""
|
||||
@ -86,8 +82,7 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
|
||||
WMS_WebControl_pro_API_actionDescription.ManualCommand,
|
||||
WMS_WebControl_pro_API_actionType.Stop,
|
||||
)
|
||||
await action()
|
||||
await asyncio.sleep(ACTION_DELAY)
|
||||
await action(responseType=WMS_WebControl_pro_API_responseType.Detailed)
|
||||
|
||||
|
||||
class WebControlProAwning(WebControlProCover):
|
||||
|
@ -2,11 +2,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
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.core import HomeAssistant
|
||||
@ -17,7 +19,6 @@ from . import WebControlProConfigEntry
|
||||
from .const import BRIGHTNESS_SCALE
|
||||
from .entity import WebControlProGenericEntity
|
||||
|
||||
ACTION_DELAY = 0.5
|
||||
SCAN_INTERVAL = timedelta(seconds=15)
|
||||
PARALLEL_UPDATES = 1
|
||||
|
||||
@ -56,14 +57,16 @@ class WebControlProLight(WebControlProGenericEntity, LightEntity):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on."""
|
||||
action = self._dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
|
||||
await action(onOffState=True)
|
||||
await asyncio.sleep(ACTION_DELAY)
|
||||
await action(
|
||||
onOffState=True, responseType=WMS_WebControl_pro_API_responseType.Detailed
|
||||
)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the light off."""
|
||||
action = self._dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
|
||||
await action(onOffState=False)
|
||||
await asyncio.sleep(ACTION_DELAY)
|
||||
await action(
|
||||
onOffState=False, responseType=WMS_WebControl_pro_API_responseType.Detailed
|
||||
)
|
||||
|
||||
|
||||
class WebControlProDimmer(WebControlProLight):
|
||||
@ -90,6 +93,6 @@ class WebControlProDimmer(WebControlProLight):
|
||||
WMS_WebControl_pro_API_actionDescription.LightDimming
|
||||
)
|
||||
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)
|
||||
|
@ -14,5 +14,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/wmspro",
|
||||
"integration_type": "hub",
|
||||
"iot_class": "local_polling",
|
||||
"requirements": ["pywmspro==0.2.2"]
|
||||
"requirements": ["pywmspro==0.3.0"]
|
||||
}
|
||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -2596,7 +2596,7 @@ pywilight==0.0.74
|
||||
pywizlight==0.6.3
|
||||
|
||||
# homeassistant.components.wmspro
|
||||
pywmspro==0.2.2
|
||||
pywmspro==0.3.0
|
||||
|
||||
# homeassistant.components.ws66i
|
||||
pyws66i==1.1
|
||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -2154,7 +2154,7 @@ pywilight==0.0.74
|
||||
pywizlight==0.6.3
|
||||
|
||||
# homeassistant.components.wmspro
|
||||
pywmspro==0.2.2
|
||||
pywmspro==0.3.0
|
||||
|
||||
# homeassistant.components.ws66i
|
||||
pyws66i==1.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user