Add the HomematicIP water supply stop valve and water alarm sensor (#186498)

Co-authored-by: Joostlek <joostlek@outlook.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Christian Lackas
2026-10-27 17:11:37 +01:00
committed by GitHub
co-authored by Joostlek Claude Opus 5.5
parent 0146777576
commit bb770c7048
13 changed files with 565 additions and 3 deletions
@@ -32,6 +32,7 @@ from homematicip.device import (
TiltVibrationSensor,
WallMountedThermostatPro,
WaterSensor,
WaterSupplyStop,
WeatherSensor,
WeatherSensorPlus,
WeatherSensorPro,
@@ -230,6 +231,20 @@ WALL_THERMOSTAT_DESCRIPTIONS: tuple[
),
)
WATER_SUPPLY_STOP_DESCRIPTIONS: tuple[
HmipBinarySensorDescription[WaterSupplyStop],
...,
] = (
HmipBinarySensorDescription(
key="water_alarm",
translation_key="water_alarm",
device_class=BinarySensorDeviceClass.SAFETY,
channel_value_fn=lambda channel: channel.waterAlarmActive,
channel=1,
channel_type=FunctionalChannelType.WATER_SUPPLY_STOP_CHANNEL,
),
)
BATTERY_SENSOR_DESCRIPTION = HmipBinarySensorDescription[Device](
key="battery",
device_class=BinarySensorDeviceClass.BATTERY,
@@ -252,6 +267,7 @@ SIMPLE_BINARY_SENSOR_DESCRIPTIONS: dict[
(RainSensor, WeatherSensorPlus, WeatherSensorPro): RAIN_SENSOR_DESCRIPTIONS,
(PluggableMainsFailureSurveillance,): MAINS_FAILURE_SENSOR_DESCRIPTIONS,
(WallMountedThermostatPro,): WALL_THERMOSTAT_DESCRIPTIONS,
(WaterSupplyStop,): WATER_SUPPLY_STOP_DESCRIPTIONS,
}
@@ -38,6 +38,7 @@ from homematicip.device import (
TiltVibrationSensor,
UltrasonicDistanceSensor,
WateringActuator,
WaterSupplyStop,
WeatherSensor,
WeatherSensorPlus,
WeatherSensorPro,
@@ -448,6 +449,19 @@ HEIGHT_DESC = HmipSensorDescription[Device](
)
WATER_FLOW_DESC = HmipSensorDescription[Device](
key="water_flow",
translation_key="water_flow",
device_class=SensorDeviceClass.VOLUME_FLOW_RATE,
native_unit_of_measurement=UnitOfVolumeFlowRate.LITERS_PER_MINUTE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
channel_value_fn=lambda channel: channel.waterFlow,
channel=1,
channel_type=FunctionalChannelType.WATER_SUPPLY_STOP_CHANNEL,
)
# Keys must not subclass each other so each device matches one key; the setup
# loop breaks after the first match (enforced by
# test_simple_sensor_descriptions_no_overlap).
@@ -488,6 +502,7 @@ SENSOR_DESCRIPTIONS_BY_DEVICE: dict[
),
TiltVibrationSensor: (TILT_ANGLE_DESC, TILT_TEMPERATURE_DESC),
UltrasonicDistanceSensor: (DISTANCE_DESC, HEIGHT_DESC),
WaterSupplyStop: (WATER_FLOW_DESC,),
WeatherSensor: (
TEMPERATURE_DESC,
HUMIDITY_DESC,
@@ -48,6 +48,9 @@
},
"raining": {
"name": "Raining"
},
"water_alarm": {
"name": "Water alarm"
}
},
"event": {
@@ -125,6 +128,9 @@
"today_rain": {
"name": "Today rain"
},
"water_flow": {
"name": "Water flow"
},
"window_state": {
"name": "Window state",
"state": {
@@ -2,6 +2,7 @@
from typing import override
from homematicip.base.enums import WaterSupplyState
from homematicip.base.functionalChannels import FunctionalChannelType
from homematicip.device import Device
@@ -24,12 +25,18 @@ async def async_setup_entry(
) -> None:
"""Set up the HomematicIP valves from a config entry."""
hap = config_entry.runtime_data
entities = [
entities: list[ValveEntity] = [
HomematicipWateringValve(hap, device, ch.index)
for device in hap.home.devices
for ch in device.functionalChannels
if ch.functionalChannelType == FunctionalChannelType.WATERING_ACTUATOR_CHANNEL
]
entities.extend(
HomematicipWaterSupplyValve(hap, device, ch.index)
for device in hap.home.devices
for ch in device.functionalChannels
if ch.functionalChannelType == FunctionalChannelType.WATER_SUPPLY_STOP_CHANNEL
)
async_add_entities(entities)
@@ -70,3 +77,42 @@ class HomematicipWateringValve(HomematicipGenericEntity, ValveEntity):
"""Return if the valve is closed."""
channel = self.get_channel_or_raise()
return channel.wateringActive is False
class HomematicipWaterSupplyValve(HomematicipGenericEntity, ValveEntity):
"""Representation of a HomematicIP water supply stop valve."""
_attr_reports_position = False
_attr_supported_features = ValveEntityFeature.OPEN | ValveEntityFeature.CLOSE
_attr_device_class = ValveDeviceClass.WATER
def __init__(self, hap: HomematicipHAP, device: Device, channel: int) -> None:
"""Initialize the valve."""
super().__init__(
hap,
device=device,
channel=channel,
channel_real_index=channel,
feature_id="water_supply",
)
@override
async def async_open_valve(self) -> None:
"""Open the valve."""
channel = self.get_channel_or_raise()
await channel.set_water_supply_state_async(WaterSupplyState.FULL_OPENED)
@override
async def async_close_valve(self) -> None:
"""Close the valve."""
channel = self.get_channel_or_raise()
await channel.set_water_supply_state_async(WaterSupplyState.NO_WATERFLOW)
@property
@override
def is_closed(self) -> bool | None:
"""Return if the valve is closed."""
state = self.get_channel_or_raise().waterSupplyState
if state in (None, WaterSupplyState.UNKNOWN):
return None
return state == WaterSupplyState.NO_WATERFLOW
@@ -9890,6 +9890,95 @@
"type": "ULTRASONIC_DISTANCE_SENSOR",
"updateState": "UP_TO_DATE"
},
"3014F7110000000000000WSS": {
"availableFirmwareVersion": "0.0.0",
"connectionType": "HMIP_RF",
"deviceArchetype": "HMIP",
"firmwareVersion": "1.0.14",
"firmwareVersionInteger": 65550,
"functionalChannels": {
"0": {
"coProFaulty": false,
"coProRestartNeeded": false,
"coProUpdateFailure": false,
"configPending": false,
"deviceCanBusError": false,
"deviceId": "3014F7110000000000000WSS",
"deviceOverheated": false,
"deviceOverloaded": false,
"deviceUndervoltage": false,
"dutyCycle": false,
"functionalChannelType": "DEVICE_OPERATIONLOCK",
"groupIndex": 0,
"groups": [],
"index": 0,
"label": "",
"lowBat": false,
"operationLockActive": false,
"routerModuleEnabled": false,
"routerModuleSupported": false,
"rssiDeviceValue": -45,
"rssiPeerValue": -54,
"supportedOptionalFeatures": {
"IFeatureDevicePowerFailure": true,
"IFeatureRssiValue": true,
"IOptionalFeatureDeviceCanBusError": true,
"IOptionalFeatureDeviceValveError": true,
"IOptionalFeatureDutyCycle": true,
"IOptionalFeatureLowBat": true,
"IOptionalFeatureNotRechargeableBattery": true
},
"temperatureOutOfRange": false,
"unreach": false,
"valveFlowError": false,
"valveWaterError": null
},
"1": {
"canbusSensorUsages": ["WATER_FLOW"],
"channelRole": "WATER_SUPPLY",
"deviceId": "3014F7110000000000000WSS",
"externalSensorMode": "INACTIVE",
"flushReminderInterval": 0,
"functionalChannelType": "WATER_SUPPLY_STOP_CHANNEL",
"groupIndex": 1,
"groups": [],
"index": 1,
"label": "",
"lastFlushReminderTimestamp": 1785676204873,
"lastFlushTimestamp": 1785676204873,
"processing": false,
"vacationEndTime": null,
"vacationStartTime": null,
"waterAlarmActive": false,
"waterAlarmGroupId": "00000000-0000-0000-0000-0000000000WA",
"waterFlow": 0,
"waterFlowDurationExceeded": false,
"waterFlowErrorDuration": 60,
"waterFlowErrorDurationAction": "NOTIFICATION_AND_CLOSE_VALVE",
"waterFlowErrorThreshold": 37,
"waterFlowErrorThresholdAction": "NOTIFICATION_AND_CLOSE_VALVE",
"waterFlowThresholdExceeded": true,
"waterPressure": null,
"waterSupplyState": "FULL_OPENED",
"waterSupplyVacationModeActive": false
}
},
"homeId": "00000000-0000-0000-0000-000000000001",
"id": "3014F7110000000000000WSS",
"label": "Wasserstopp",
"lastStatusUpdate": 1790082161197,
"liveUpdateState": "LIVE_UPDATE_NOT_SUPPORTED",
"manuallyUpdateForced": false,
"manufacturerCode": 11,
"measuredAttributes": {},
"modelId": 609,
"modelType": "HmIP-WSS-GB",
"oem": "eQ-3",
"permanentlyReachable": true,
"serializedGlobalTradeItemNumber": "3014F7110000000000000WSS",
"type": "WATER_SUPPLY_STOP",
"updateState": "UP_TO_DATE"
},
"3014F71100000000000DRBL4": {
"availableFirmwareVersion": "1.8.2",
"connectionType": "HMIP_WIRED",
@@ -214,3 +214,164 @@
'state': 'on',
})
# ---
# name: test_hmip_water_alarm_sensor[binary_sensor.home_cloud_connection-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': None,
'device_class': None,
'device_id': <DeviceEntry identifiers=[('homematicip_cloud', '00000000-0000-0000-0000-000000000001')]>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.home_cloud_connection',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Cloud connection',
'options': dict({
}),
'original_device_class': None,
'original_icon': 'mdi:access-point-network',
'original_name': 'Cloud connection',
'platform': 'homematicip_cloud',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'cloud_connection',
'unique_id': '00000000-0000-0000-0000-000000000001_cloud_connection',
'unit_of_measurement': None,
})
# ---
# name: test_hmip_water_alarm_sensor[binary_sensor.home_cloud_connection-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Home Cloud connection',
<EntityStateAttribute.ICON: 'icon'>: 'mdi:access-point-network',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.home_cloud_connection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_hmip_water_alarm_sensor[binary_sensor.wasserstopp_battery-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': None,
'device_class': None,
'device_id': <DeviceEntry identifiers=[('homematicip_cloud', '3014F7110000000000000WSS')]>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.wasserstopp_battery',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Battery',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.BATTERY: 'battery'>,
'original_icon': None,
'original_name': 'Battery',
'platform': 'homematicip_cloud',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': '3014F7110000000000000WSS_0_battery',
'unit_of_measurement': None,
})
# ---
# name: test_hmip_water_alarm_sensor[binary_sensor.wasserstopp_battery-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'connection_type': <ConnectionType.HMIP_RF: 'HMIP_RF'>,
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'battery',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Wasserstopp Battery',
'id': '3014F7110000000000000WSS',
'is_group': False,
'model_type': 'HmIP-WSS-GB',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.wasserstopp_battery',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_hmip_water_alarm_sensor[binary_sensor.wasserstopp_water_alarm-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': None,
'device_class': None,
'device_id': <DeviceEntry identifiers=[('homematicip_cloud', '3014F7110000000000000WSS')]>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.wasserstopp_water_alarm',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Water alarm',
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.SAFETY: 'safety'>,
'original_icon': None,
'original_name': 'Water alarm',
'platform': 'homematicip_cloud',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'water_alarm',
'unique_id': '3014F7110000000000000WSS_1_water_alarm',
'unit_of_measurement': None,
})
# ---
# name: test_hmip_water_alarm_sensor[binary_sensor.wasserstopp_water_alarm-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'connection_type': <ConnectionType.HMIP_RF: 'HMIP_RF'>,
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'safety',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Wasserstopp Water alarm',
'id': '3014F7110000000000000WSS',
'is_group': False,
'model_type': 'HmIP-WSS-GB',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.wasserstopp_water_alarm',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
@@ -7,7 +7,7 @@
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'config_subentry_id': None,
'device_class': None,
'device_id': <DeviceEntry identifiers=[('homematicip_cloud', '3014F711000000000000BSL2')]>,
'disabled_by': None,
@@ -60,3 +60,65 @@
'state': '3158.0',
})
# ---
# name: test_hmip_water_supply_stop_water_flow[sensor.wasserstopp_water_flow-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': dict({
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
}),
'config_entry_id': <ANY>,
'config_subentry_id': None,
'device_class': None,
'device_id': <DeviceEntry identifiers=[('homematicip_cloud', '3014F7110000000000000WSS')]>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.wasserstopp_water_flow',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Water flow',
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.VOLUME_FLOW_RATE: 'volume_flow_rate'>,
'original_icon': None,
'original_name': 'Water flow',
'platform': 'homematicip_cloud',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': 'water_flow',
'unique_id': '3014F7110000000000000WSS_1_water_flow',
'unit_of_measurement': <UnitOfVolumeFlowRate.LITERS_PER_MINUTE: 'L/min'>,
})
# ---
# name: test_hmip_water_supply_stop_water_flow[sensor.wasserstopp_water_flow-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'connection_type': <ConnectionType.HMIP_RF: 'HMIP_RF'>,
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'volume_flow_rate',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Wasserstopp Water flow',
'id': '3014F7110000000000000WSS',
'is_group': False,
'model_type': 'HmIP-WSS-GB',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfVolumeFlowRate.LITERS_PER_MINUTE: 'L/min'>,
}),
'context': <ANY>,
'entity_id': 'sensor.wasserstopp_water_flow',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0',
})
# ---
@@ -0,0 +1,58 @@
# serializer version: 1
# name: test_water_supply_valve[valve.wasserstopp-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
None,
]),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': None,
'device_class': None,
'device_id': <DeviceEntry identifiers=[('homematicip_cloud', '3014F7110000000000000WSS')]>,
'disabled_by': None,
'domain': 'valve',
'entity_category': None,
'entity_id': 'valve.wasserstopp',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': None,
'options': dict({
}),
'original_device_class': <ValveDeviceClass.WATER: 'water'>,
'original_icon': None,
'original_name': None,
'platform': 'homematicip_cloud',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': <ValveEntityFeature: 3>,
'translation_key': None,
'unique_id': '3014F7110000000000000WSS_1_water_supply',
'unit_of_measurement': None,
})
# ---
# name: test_water_supply_valve[valve.wasserstopp-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'connection_type': <ConnectionType.HMIP_RF: 'HMIP_RF'>,
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'water',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Wasserstopp',
'id': '3014F7110000000000000WSS',
<ValveEntityStateAttribute.IS_CLOSED: 'is_closed'>: False,
'is_group': False,
'model_type': 'HmIP-WSS-GB',
<EntityStateAttribute.SUPPORTED_FEATURES: 'supported_features'>: <ValveEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'valve.wasserstopp',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
@@ -626,6 +626,31 @@ async def test_hmip_motion_detector_switch_outdoor(
assert hass.states.get(entity_id).state == STATE_ON
async def test_hmip_water_alarm_sensor(
hass: HomeAssistant,
default_mock_hap_factory: HomeFactory,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test the water alarm of a water supply stop."""
entity_id = "binary_sensor.wasserstopp_water_alarm"
with patch(
"homeassistant.components.homematicip_cloud.hap.PLATFORMS",
[Platform.BINARY_SENSOR],
):
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wasserstopp"], test_groups=[]
)
await snapshot_platform(
hass, entity_registry, snapshot, mock_hap.config_entry.entry_id
)
hmip_device = mock_hap.hmip_device_by_entity_id[entity_id]
await async_manipulate_test_data(hass, hmip_device, "waterAlarmActive", True)
assert hass.states.get(entity_id).state == STATE_ON
async def test_hmip_rain_sensor(
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
) -> None:
@@ -24,7 +24,7 @@ async def test_hmip_load_all_supported_devices(
test_devices=None, test_groups=None
)
assert len(mock_hap.hmip_device_by_entity_id) == 411
assert len(mock_hap.hmip_device_by_entity_id) == 415
async def test_hmip_remove_device(
@@ -962,6 +962,31 @@ async def test_hmip_water_valve_current_water_flow(
assert ha_state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT
async def test_hmip_water_supply_stop_water_flow(
hass: HomeAssistant,
default_mock_hap_factory: HomeFactory,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test the water flow of a water supply stop."""
entity_id = "sensor.wasserstopp_water_flow"
with patch(
"homeassistant.components.homematicip_cloud.hap.PLATFORMS",
[Platform.SENSOR],
):
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wasserstopp"], test_groups=[]
)
await snapshot_platform(
hass, entity_registry, snapshot, mock_hap.config_entry.entry_id
)
hmip_device = mock_hap.hmip_device_by_entity_id[entity_id]
await async_manipulate_test_data(hass, hmip_device, "waterFlow", 11.55)
assert hass.states.get(entity_id).state == "11.55"
async def test_hmip_water_valve_water_volume(
hass: HomeAssistant, default_mock_hap_factory: HomeFactory
) -> None:
@@ -1,11 +1,20 @@
"""Test HomematicIP Cloud valve entities."""
from unittest.mock import patch
from homematicip.base.enums import WaterSupplyState
from pytest_homeassistant.common import snapshot_platform
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.valve import (
DOMAIN as VALVE_DOMAIN,
SERVICE_CLOSE_VALVE,
SERVICE_OPEN_VALVE,
ValveState,
)
from homeassistant.const import STATE_UNKNOWN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .helper import HomeFactory, async_manipulate_test_data, get_and_check_entity_basics
@@ -36,3 +45,53 @@ async def test_watering_valve(
)
ha_state = hass.states.get(entity_id)
assert ha_state.state == ValveState.OPEN
async def test_water_supply_valve(
hass: HomeAssistant,
default_mock_hap_factory: HomeFactory,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test HomematicIP water supply stop valve."""
entity_id = "valve.wasserstopp"
with patch(
"homeassistant.components.homematicip_cloud.hap.PLATFORMS",
[Platform.VALVE],
):
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Wasserstopp"], test_groups=[]
)
await snapshot_platform(
hass, entity_registry, snapshot, mock_hap.config_entry.entry_id
)
hmip_device = mock_hap.hmip_device_by_entity_id[entity_id]
channel = hmip_device.functionalChannels[1]
await hass.services.async_call(
VALVE_DOMAIN, SERVICE_CLOSE_VALVE, {"entity_id": entity_id}, blocking=True
)
assert channel.mock_calls[-1][0] == "set_water_supply_state_async"
assert channel.mock_calls[-1][1] == (WaterSupplyState.NO_WATERFLOW,)
await async_manipulate_test_data(
hass, hmip_device, "waterSupplyState", WaterSupplyState.NO_WATERFLOW
)
assert hass.states.get(entity_id).state == ValveState.CLOSED
await hass.services.async_call(
VALVE_DOMAIN, SERVICE_OPEN_VALVE, {"entity_id": entity_id}, blocking=True
)
assert channel.mock_calls[-1][0] == "set_water_supply_state_async"
assert channel.mock_calls[-1][1] == (WaterSupplyState.FULL_OPENED,)
await async_manipulate_test_data(
hass, hmip_device, "waterSupplyState", WaterSupplyState.REDUCED_WATERFLOW
)
assert hass.states.get(entity_id).state == ValveState.OPEN
await async_manipulate_test_data(
hass, hmip_device, "waterSupplyState", WaterSupplyState.UNKNOWN
)
assert hass.states.get(entity_id).state == STATE_UNKNOWN