mirror of
https://github.com/home-assistant/core.git
synced 2025-09-12 08:11:38 +02:00
Fix YoLink valve state when device running in class A mode (#150456)
This commit is contained in:
@@ -47,6 +47,9 @@
|
|||||||
"exceptions": {
|
"exceptions": {
|
||||||
"invalid_config_entry": {
|
"invalid_config_entry": {
|
||||||
"message": "Config entry not found or not loaded!"
|
"message": "Config entry not found or not loaded!"
|
||||||
|
},
|
||||||
|
"valve_inoperable_currently": {
|
||||||
|
"message": "The Valve cannot be operated currently."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
|
@@ -21,6 +21,7 @@ from homeassistant.components.valve import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import DEV_MODEL_WATER_METER_YS5007, DOMAIN
|
from .const import DEV_MODEL_WATER_METER_YS5007, DOMAIN
|
||||||
@@ -130,6 +131,13 @@ class YoLinkValveEntity(YoLinkEntity, ValveEntity):
|
|||||||
|
|
||||||
async def _async_invoke_device(self, state: str) -> None:
|
async def _async_invoke_device(self, state: str) -> None:
|
||||||
"""Call setState api to change valve state."""
|
"""Call setState api to change valve state."""
|
||||||
|
if (
|
||||||
|
self.coordinator.device.is_support_mode_switching()
|
||||||
|
and self.coordinator.dev_net_type == ATTR_DEVICE_MODEL_A
|
||||||
|
):
|
||||||
|
raise HomeAssistantError(
|
||||||
|
translation_domain=DOMAIN, translation_key="valve_inoperable_currently"
|
||||||
|
)
|
||||||
if (
|
if (
|
||||||
self.coordinator.device.device_type
|
self.coordinator.device.device_type
|
||||||
== ATTR_DEVICE_MULTI_WATER_METER_CONTROLLER
|
== ATTR_DEVICE_MULTI_WATER_METER_CONTROLLER
|
||||||
@@ -155,10 +163,4 @@ class YoLinkValveEntity(YoLinkEntity, ValveEntity):
|
|||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return true is device is available."""
|
"""Return true is device is available."""
|
||||||
if (
|
|
||||||
self.coordinator.device.is_support_mode_switching()
|
|
||||||
and self.coordinator.dev_net_type is not None
|
|
||||||
):
|
|
||||||
# When the device operates in Class A mode, it cannot be controlled.
|
|
||||||
return self.coordinator.dev_net_type != ATTR_DEVICE_MODEL_A
|
|
||||||
return super().available
|
return super().available
|
||||||
|
Reference in New Issue
Block a user