2121)
2222from homeassistant .config_entries import ConfigEntry
2323from homeassistant .core import HomeAssistant , callback
24+ from homeassistant .exceptions import HomeAssistantError
2425from homeassistant .helpers .entity_platform import AddConfigEntryEntitiesCallback
2526
2627from .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