Skip to content

Commit fed6f19

Browse files
matrixd2frenck
authored andcommitted
Fix YoLink valve state when device running in class A mode (home-assistant#150456)
1 parent 2725abf commit fed6f19

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

homeassistant/components/yolink/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
"exceptions": {
4848
"invalid_config_entry": {
4949
"message": "Config entry not found or not loaded!"
50+
},
51+
"valve_inoperable_currently": {
52+
"message": "The Valve cannot be operated currently."
5053
}
5154
},
5255
"entity": {

homeassistant/components/yolink/valve.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
)
2222
from homeassistant.config_entries import ConfigEntry
2323
from homeassistant.core import HomeAssistant, callback
24+
from homeassistant.exceptions import HomeAssistantError
2425
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
2526

2627
from .const import DEV_MODEL_WATER_METER_YS5007, DOMAIN
@@ -130,6 +131,13 @@ def update_entity_state(self, state: dict[str, str | list[str]]) -> None:
130131

131132
async def _async_invoke_device(self, state: str) -> None:
132133
"""Call setState api to change valve state."""
134+
if (
135+
self.coordinator.device.is_support_mode_switching()
136+
and self.coordinator.dev_net_type == ATTR_DEVICE_MODEL_A
137+
):
138+
raise HomeAssistantError(
139+
translation_domain=DOMAIN, translation_key="valve_inoperable_currently"
140+
)
133141
if (
134142
self.coordinator.device.device_type
135143
== ATTR_DEVICE_MULTI_WATER_METER_CONTROLLER
@@ -155,10 +163,4 @@ async def async_close_valve(self) -> None:
155163
@property
156164
def available(self) -> bool:
157165
"""Return true is device is available."""
158-
if (
159-
self.coordinator.device.is_support_mode_switching()
160-
and self.coordinator.dev_net_type is not None
161-
):
162-
# When the device operates in Class A mode, it cannot be controlled.
163-
return self.coordinator.dev_net_type != ATTR_DEVICE_MODEL_A
164166
return super().available

0 commit comments

Comments
 (0)