Skip to content

Commit a0b64db

Browse files
committed
Raise errors on interactive entity actions when suspended
1 parent 84d3b02 commit a0b64db

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

homeassistant/components/huawei_lte/button.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from homeassistant.config_entries import ConfigEntry
1515
from homeassistant.const import EntityCategory
1616
from homeassistant.core import HomeAssistant
17+
from homeassistant.exceptions import ServiceValidationError
1718
from homeassistant.helpers import entity_platform
1819

1920
from .const import DOMAIN
@@ -50,10 +51,7 @@ async def async_update(self) -> None:
5051
def press(self) -> None:
5152
"""Press button."""
5253
if self.router.suspended:
53-
_LOGGER.debug(
54-
"%s: ignored, integration suspended", self.entity_description.key
55-
)
56-
return
54+
raise ServiceValidationError("Integration is suspended")
5755
result = self._press()
5856
_LOGGER.debug("%s: %s", self.entity_description.key, result)
5957

homeassistant/components/huawei_lte/select.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from homeassistant.config_entries import ConfigEntry
1818
from homeassistant.const import EntityCategory
1919
from homeassistant.core import HomeAssistant
20+
from homeassistant.exceptions import ServiceValidationError
2021
from homeassistant.helpers.entity import Entity
2122
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
2223

@@ -95,6 +96,8 @@ def __init__(
9596

9697
def select_option(self, option: str) -> None:
9798
"""Change the selected option."""
99+
if self.router.suspended:
100+
raise ServiceValidationError("Integration is suspended")
98101
self.entity_description.setter_fn(option)
99102

100103
@property

homeassistant/components/huawei_lte/switch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
)
1313
from homeassistant.config_entries import ConfigEntry
1414
from homeassistant.core import HomeAssistant
15+
from homeassistant.exceptions import ServiceValidationError
1516
from homeassistant.helpers.entity import Entity
1617
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
1718

@@ -57,10 +58,14 @@ def _turn(self, state: bool) -> None:
5758

5859
def turn_on(self, **kwargs: Any) -> None:
5960
"""Turn switch on."""
61+
if self.router.suspended:
62+
raise ServiceValidationError("Integration is suspended")
6063
self._turn(state=True)
6164

6265
def turn_off(self, **kwargs: Any) -> None:
6366
"""Turn switch off."""
67+
if self.router.suspended:
68+
raise ServiceValidationError("Integration is suspended")
6469
self._turn(state=False)
6570

6671
async def async_added_to_hass(self) -> None:

0 commit comments

Comments
 (0)