mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 16:17:20 +00:00
Raise errors on interactive entity actions when suspended
This commit is contained in:
parent
28f9d46f2e
commit
6f3a1344b3
@ -14,6 +14,7 @@ from homeassistant.components.button import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers import entity_platform
|
||||
|
||||
from .const import DOMAIN
|
||||
@ -50,10 +51,7 @@ class BaseButton(HuaweiLteBaseInteractiveEntity, ButtonEntity):
|
||||
def press(self) -> None:
|
||||
"""Press button."""
|
||||
if self.router.suspended:
|
||||
_LOGGER.debug(
|
||||
"%s: ignored, integration suspended", self.entity_description.key
|
||||
)
|
||||
return
|
||||
raise ServiceValidationError("Integration is suspended")
|
||||
result = self._press()
|
||||
_LOGGER.debug("%s: %s", self.entity_description.key, result)
|
||||
|
||||
|
@ -17,6 +17,7 @@ from homeassistant.components.select import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
from homeassistant.helpers.typing import UNDEFINED
|
||||
@ -102,6 +103,8 @@ class HuaweiLteSelectEntity(HuaweiLteBaseInteractiveEntity, SelectEntity):
|
||||
|
||||
def select_option(self, option: str) -> None:
|
||||
"""Change the selected option."""
|
||||
if self.router.suspended:
|
||||
raise ServiceValidationError("Integration is suspended")
|
||||
self.entity_description.setter_fn(option)
|
||||
|
||||
@property
|
||||
|
@ -12,6 +12,7 @@ from homeassistant.components.switch import (
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
@ -57,10 +58,14 @@ class HuaweiLteBaseSwitch(HuaweiLteBaseInteractiveEntity, SwitchEntity):
|
||||
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn switch on."""
|
||||
if self.router.suspended:
|
||||
raise ServiceValidationError("Integration is suspended")
|
||||
self._turn(state=True)
|
||||
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn switch off."""
|
||||
if self.router.suspended:
|
||||
raise ServiceValidationError("Integration is suspended")
|
||||
self._turn(state=False)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user