mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 00:27:19 +00:00
Mark interactive entities unavailable when suspended
This commit is contained in:
parent
5156dd9c89
commit
28f9d46f2e
@ -527,6 +527,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
if not router:
|
||||
raise ServiceValidationError(f"Router {url} not available")
|
||||
|
||||
was_suspended = router.suspended
|
||||
if service.service == SERVICE_RESUME_INTEGRATION:
|
||||
# Login will be handled automatically on demand
|
||||
router.suspended = False
|
||||
@ -537,6 +538,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
_LOGGER.debug("%s: %s", service.service, "done")
|
||||
else:
|
||||
raise ServiceValidationError(f"Unsupported service {service.service}")
|
||||
if was_suspended != router.suspended:
|
||||
# Make interactive entities' availability update
|
||||
dispatcher_send(hass, UPDATE_SIGNAL, router.config_entry.unique_id)
|
||||
|
||||
for service in ADMIN_SERVICES:
|
||||
async_register_admin_service(
|
||||
|
@ -17,7 +17,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_platform
|
||||
|
||||
from .const import DOMAIN
|
||||
from .entity import HuaweiLteBaseEntityWithDevice
|
||||
from .entity import HuaweiLteBaseInteractiveEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -36,7 +36,7 @@ async def async_setup_entry(
|
||||
async_add_entities(buttons)
|
||||
|
||||
|
||||
class BaseButton(HuaweiLteBaseEntityWithDevice, ButtonEntity):
|
||||
class BaseButton(HuaweiLteBaseInteractiveEntity, ButtonEntity):
|
||||
"""Huawei LTE button base class."""
|
||||
|
||||
@property
|
||||
|
@ -66,3 +66,12 @@ class HuaweiLteBaseEntityWithDevice(HuaweiLteBaseEntity):
|
||||
connections=self.router.device_connections,
|
||||
identifiers=self.router.device_identifiers,
|
||||
)
|
||||
|
||||
|
||||
class HuaweiLteBaseInteractiveEntity(HuaweiLteBaseEntityWithDevice):
|
||||
"""Base interactive entity."""
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return if entity is available."""
|
||||
return super().available and not self.router.suspended
|
||||
|
@ -23,7 +23,7 @@ from homeassistant.helpers.typing import UNDEFINED
|
||||
|
||||
from . import Router
|
||||
from .const import DOMAIN, KEY_NET_NET_MODE
|
||||
from .entity import HuaweiLteBaseEntityWithDevice
|
||||
from .entity import HuaweiLteBaseInteractiveEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -76,7 +76,7 @@ async def async_setup_entry(
|
||||
async_add_entities(selects, True)
|
||||
|
||||
|
||||
class HuaweiLteSelectEntity(HuaweiLteBaseEntityWithDevice, SelectEntity):
|
||||
class HuaweiLteSelectEntity(HuaweiLteBaseInteractiveEntity, SelectEntity):
|
||||
"""Huawei LTE select entity."""
|
||||
|
||||
entity_description: HuaweiSelectEntityDescription
|
||||
|
@ -20,7 +20,7 @@ from .const import (
|
||||
KEY_DIALUP_MOBILE_DATASWITCH,
|
||||
KEY_WLAN_WIFI_GUEST_NETWORK_SWITCH,
|
||||
)
|
||||
from .entity import HuaweiLteBaseEntityWithDevice
|
||||
from .entity import HuaweiLteBaseInteractiveEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -43,7 +43,7 @@ async def async_setup_entry(
|
||||
async_add_entities(switches, True)
|
||||
|
||||
|
||||
class HuaweiLteBaseSwitch(HuaweiLteBaseEntityWithDevice, SwitchEntity):
|
||||
class HuaweiLteBaseSwitch(HuaweiLteBaseInteractiveEntity, SwitchEntity):
|
||||
"""Huawei LTE switch device base class."""
|
||||
|
||||
key: str
|
||||
|
Loading…
x
Reference in New Issue
Block a user