mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add WeHeat Flow sensors for pumps (#139390)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
d44d07ffcf
commit
aeca2842fe
@ -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
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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 = [
|
||||
|
@ -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%]",
|
||||
|
@ -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
|
||||
|
@ -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': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
'sensor': dict({
|
||||
'suggested_display_precision': 1,
|
||||
}),
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.VOLUME_FLOW_RATE: 'volume_flow_rate'>,
|
||||
'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': <UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR: 'm³/h'>,
|
||||
})
|
||||
# ---
|
||||
# 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': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': <UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR: 'm³/h'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.test_model_central_heating_pump_flow',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'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': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
'sensor': dict({
|
||||
'suggested_display_precision': 1,
|
||||
}),
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.VOLUME_FLOW_RATE: 'volume_flow_rate'>,
|
||||
'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': <UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR: 'm³/h'>,
|
||||
})
|
||||
# ---
|
||||
# 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': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': <UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR: 'm³/h'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.test_model_dhw_pump_flow',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '1.12',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_model_dhw_top_temperature-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user