diff --git a/homeassistant/components/weheat/const.py b/homeassistant/components/weheat/const.py index ee9b77281e6..cd521afd2ea 100644 --- a/homeassistant/components/weheat/const.py +++ b/homeassistant/components/weheat/const.py @@ -25,3 +25,4 @@ LOGGER: Logger = getLogger(__package__) DISPLAY_PRECISION_WATTS = 0 DISPLAY_PRECISION_COP = 1 DISPLAY_PRECISION_WATER_TEMP = 1 +DISPLAY_PRECISION_FLOW = 1 diff --git a/homeassistant/components/weheat/icons.json b/homeassistant/components/weheat/icons.json index e7f54b478c6..c0955cd051d 100644 --- a/homeassistant/components/weheat/icons.json +++ b/homeassistant/components/weheat/icons.json @@ -42,6 +42,12 @@ "heat_pump_state": { "default": "mdi:state-machine" }, + "dhw_flow_volume": { + "default": "mdi:pump" + }, + "central_heating_flow_volume": { + "default": "mdi:pump" + }, "electricity_used": { "default": "mdi:flash" }, diff --git a/homeassistant/components/weheat/sensor.py b/homeassistant/components/weheat/sensor.py index d3b758e41eb..8ff80aeac08 100644 --- a/homeassistant/components/weheat/sensor.py +++ b/homeassistant/components/weheat/sensor.py @@ -17,6 +17,7 @@ from homeassistant.const import ( UnitOfEnergy, UnitOfPower, UnitOfTemperature, + UnitOfVolumeFlowRate, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback @@ -24,6 +25,7 @@ from homeassistant.helpers.typing import StateType from .const import ( DISPLAY_PRECISION_COP, + DISPLAY_PRECISION_FLOW, DISPLAY_PRECISION_WATER_TEMP, DISPLAY_PRECISION_WATTS, ) @@ -161,6 +163,15 @@ SENSORS = [ native_unit_of_measurement=PERCENTAGE, value_fn=lambda status: status.compressor_percentage, ), + WeHeatSensorEntityDescription( + translation_key="central_heating_flow_volume", + key="central_heating_flow_volume", + device_class=SensorDeviceClass.VOLUME_FLOW_RATE, + state_class=SensorStateClass.MEASUREMENT, + suggested_display_precision=DISPLAY_PRECISION_FLOW, + native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, + value_fn=lambda status: status.central_heating_flow_volume, + ), ] DHW_SENSORS = [ @@ -182,6 +193,15 @@ DHW_SENSORS = [ suggested_display_precision=DISPLAY_PRECISION_WATER_TEMP, value_fn=lambda status: status.dhw_bottom_temperature, ), + WeHeatSensorEntityDescription( + translation_key="dhw_flow_volume", + key="dhw_flow_volume", + device_class=SensorDeviceClass.VOLUME_FLOW_RATE, + state_class=SensorStateClass.MEASUREMENT, + suggested_display_precision=DISPLAY_PRECISION_FLOW, + native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, + value_fn=lambda status: status.dhw_flow_volume, + ), ] ENERGY_SENSORS = [ diff --git a/homeassistant/components/weheat/strings.json b/homeassistant/components/weheat/strings.json index 3959acad053..b02389e7f4f 100644 --- a/homeassistant/components/weheat/strings.json +++ b/homeassistant/components/weheat/strings.json @@ -86,6 +86,12 @@ "dhw_bottom_temperature": { "name": "DHW bottom temperature" }, + "dhw_flow_volume": { + "name": "DHW pump flow" + }, + "central_heating_flow_volume": { + "name": "Central heating pump flow" + }, "heat_pump_state": { "state": { "standby": "[%key:common::state::standby%]", diff --git a/tests/components/weheat/conftest.py b/tests/components/weheat/conftest.py index dbdeb0726dd..692792955fc 100644 --- a/tests/components/weheat/conftest.py +++ b/tests/components/weheat/conftest.py @@ -124,6 +124,8 @@ def mock_weheat_heat_pump_instance() -> MagicMock: mock_heat_pump_instance.energy_output = 56789 mock_heat_pump_instance.compressor_rpm = 4500 mock_heat_pump_instance.compressor_percentage = 100 + mock_heat_pump_instance.dhw_flow_volume = 1.12 + mock_heat_pump_instance.central_heating_flow_volume = 1.23 mock_heat_pump_instance.indoor_unit_water_pump_state = False mock_heat_pump_instance.indoor_unit_auxiliary_pump_state = False mock_heat_pump_instance.indoor_unit_dhw_valve_or_pump_state = None diff --git a/tests/components/weheat/snapshots/test_sensor.ambr b/tests/components/weheat/snapshots/test_sensor.ambr index 77f85224913..b968d925675 100644 --- a/tests/components/weheat/snapshots/test_sensor.ambr +++ b/tests/components/weheat/snapshots/test_sensor.ambr @@ -125,6 +125,61 @@ 'state': '33', }) # --- +# name: test_all_entities[sensor.test_model_central_heating_pump_flow-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.test_model_central_heating_pump_flow', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Central heating pump flow', + 'platform': 'weheat', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'central_heating_flow_volume', + 'unique_id': '0000-1111-2222-3333_central_heating_flow_volume', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities[sensor.test_model_central_heating_pump_flow-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'volume_flow_rate', + 'friendly_name': 'Test Model Central heating pump flow', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.test_model_central_heating_pump_flow', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1.23', + }) +# --- # name: test_all_entities[sensor.test_model_compressor_speed-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -390,6 +445,61 @@ 'state': '88', }) # --- +# name: test_all_entities[sensor.test_model_dhw_pump_flow-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.test_model_dhw_pump_flow', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'DHW pump flow', + 'platform': 'weheat', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'dhw_flow_volume', + 'unique_id': '0000-1111-2222-3333_dhw_flow_volume', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities[sensor.test_model_dhw_pump_flow-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'volume_flow_rate', + 'friendly_name': 'Test Model DHW pump flow', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.test_model_dhw_pump_flow', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1.12', + }) +# --- # name: test_all_entities[sensor.test_model_dhw_top_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/weheat/test_sensor.py b/tests/components/weheat/test_sensor.py index f3eec282704..eab571b09ed 100644 --- a/tests/components/weheat/test_sensor.py +++ b/tests/components/weheat/test_sensor.py @@ -33,7 +33,7 @@ async def test_all_entities( await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) -@pytest.mark.parametrize(("has_dhw", "nr_of_entities"), [(False, 15), (True, 17)]) +@pytest.mark.parametrize(("has_dhw", "nr_of_entities"), [(False, 16), (True, 19)]) async def test_create_entities( hass: HomeAssistant, mock_weheat_discover: AsyncMock,