diff --git a/homeassistant/components/huawei_lte/__init__.py b/homeassistant/components/huawei_lte/__init__.py index 1f037e5ac00..1c9023f169b 100644 --- a/homeassistant/components/huawei_lte/__init__.py +++ b/homeassistant/components/huawei_lte/__init__.py @@ -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( diff --git a/homeassistant/components/huawei_lte/button.py b/homeassistant/components/huawei_lte/button.py index 44b35d51dd4..1d9507a2865 100644 --- a/homeassistant/components/huawei_lte/button.py +++ b/homeassistant/components/huawei_lte/button.py @@ -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 diff --git a/homeassistant/components/huawei_lte/entity.py b/homeassistant/components/huawei_lte/entity.py index b69d2e79fb6..06fa820592c 100644 --- a/homeassistant/components/huawei_lte/entity.py +++ b/homeassistant/components/huawei_lte/entity.py @@ -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 diff --git a/homeassistant/components/huawei_lte/select.py b/homeassistant/components/huawei_lte/select.py index 3df6fa53320..cacbb5c88a2 100644 --- a/homeassistant/components/huawei_lte/select.py +++ b/homeassistant/components/huawei_lte/select.py @@ -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 diff --git a/homeassistant/components/huawei_lte/switch.py b/homeassistant/components/huawei_lte/switch.py index ac8bca4234c..944cf63eb05 100644 --- a/homeassistant/components/huawei_lte/switch.py +++ b/homeassistant/components/huawei_lte/switch.py @@ -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