Postpone update in WMSPro after service call (#144836)

* Reduce stress on WMS WebControl pro with higher scan interval

Avoid delays and connection issues due to overloaded hub.
Fixes #133832 and #134413

* Schedule an entity state update after performing an action

Avoid delaying immediate status updates, e.g. on/off changes.

* Replace scheduled state updates with delayed action completion

Suggested-by: joostlek
This commit is contained in:
Marc Hörsken 2025-05-18 17:23:21 +02:00 committed by GitHub
parent 906b3901fb
commit aa4c41abe8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import asyncio
from datetime import timedelta
from typing import Any
@ -17,7 +18,8 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import WebControlProConfigEntry
from .entity import WebControlProGenericEntity
SCAN_INTERVAL = timedelta(seconds=5)
ACTION_DELAY = 0.5
SCAN_INTERVAL = timedelta(seconds=10)
PARALLEL_UPDATES = 1
@ -57,6 +59,7 @@ 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:
@ -67,11 +70,13 @@ 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."""
@ -80,6 +85,7 @@ class WebControlProCover(WebControlProGenericEntity, CoverEntity):
WMS_WebControl_pro_API_actionType.Stop,
)
await action()
await asyncio.sleep(ACTION_DELAY)
class WebControlProAwning(WebControlProCover):

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import asyncio
from datetime import timedelta
from typing import Any
@ -16,7 +17,8 @@ from . import WebControlProConfigEntry
from .const import BRIGHTNESS_SCALE
from .entity import WebControlProGenericEntity
SCAN_INTERVAL = timedelta(seconds=5)
ACTION_DELAY = 0.5
SCAN_INTERVAL = timedelta(seconds=15)
PARALLEL_UPDATES = 1
@ -55,11 +57,13 @@ class WebControlProLight(WebControlProGenericEntity, LightEntity):
"""Turn the light on."""
action = self._dest.action(WMS_WebControl_pro_API_actionDescription.LightSwitch)
await action(onOffState=True)
await asyncio.sleep(ACTION_DELAY)
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)
class WebControlProDimmer(WebControlProLight):
@ -88,3 +92,4 @@ class WebControlProDimmer(WebControlProLight):
await action(
percentage=brightness_to_value(BRIGHTNESS_SCALE, kwargs[ATTR_BRIGHTNESS])
)
await asyncio.sleep(ACTION_DELAY)