diff --git a/homeassistant/components/pooldose/const.py b/homeassistant/components/pooldose/const.py index b486a18d6de..7e205d418ea 100644 --- a/homeassistant/components/pooldose/const.py +++ b/homeassistant/components/pooldose/const.py @@ -2,17 +2,20 @@ from __future__ import annotations -from homeassistant.const import UnitOfTemperature, UnitOfVolumeFlowRate +from homeassistant.const import UnitOfTemperature, UnitOfVolume, UnitOfVolumeFlowRate DOMAIN = "pooldose" MANUFACTURER = "SEKO" -# Mapping of device units to Home Assistant units +# Mapping of device units (upper case) to Home Assistant units UNIT_MAPPING: dict[str, str] = { # Temperature units "°C": UnitOfTemperature.CELSIUS, "°F": UnitOfTemperature.FAHRENHEIT, # Volume flow rate units - "m3/h": UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, - "L/s": UnitOfVolumeFlowRate.LITERS_PER_SECOND, + "M3/H": UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, + "L/S": UnitOfVolumeFlowRate.LITERS_PER_SECOND, + # Volume units + "L": UnitOfVolume.LITERS, + "M3": UnitOfVolume.CUBIC_METERS, } diff --git a/homeassistant/components/pooldose/icons.json b/homeassistant/components/pooldose/icons.json index 456a184259d..533a34a2e07 100644 --- a/homeassistant/components/pooldose/icons.json +++ b/homeassistant/components/pooldose/icons.json @@ -119,6 +119,9 @@ }, "ph_type_dosing": { "default": "mdi:beaker" + }, + "water_meter_total_permanent": { + "default": "mdi:counter" } }, "switch": { diff --git a/homeassistant/components/pooldose/sensor.py b/homeassistant/components/pooldose/sensor.py index ca196e2f83b..a18e200cd5a 100644 --- a/homeassistant/components/pooldose/sensor.py +++ b/homeassistant/components/pooldose/sensor.py @@ -10,6 +10,7 @@ from homeassistant.components.sensor import ( SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, @@ -58,6 +59,13 @@ SENSOR_DESCRIPTIONS: tuple[PooldoseSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.VOLUME_FLOW_RATE, use_dynamic_unit=True, ), + PooldoseSensorEntityDescription( + key="water_meter_total_permanent", + translation_key="water_meter_total_permanent", + device_class=SensorDeviceClass.VOLUME, + state_class=SensorStateClass.TOTAL_INCREASING, + use_dynamic_unit=True, + ), PooldoseSensorEntityDescription( key="ph_type_dosing", translation_key="ph_type_dosing", @@ -223,8 +231,8 @@ class PooldoseSensor(PooldoseEntity, SensorEntity): and (data := self.get_data()) is not None and (device_unit := data.get("unit")) ): - # Map device unit to Home Assistant unit, return None if unknown - return UNIT_MAPPING.get(device_unit) + # Map device unit (upper case) to Home Assistant unit, return None if unknown + return UNIT_MAPPING.get(device_unit.upper()) # Fall back to static unit from entity description return super().native_unit_of_measurement diff --git a/homeassistant/components/pooldose/strings.json b/homeassistant/components/pooldose/strings.json index bdddd6383f0..fb6334f0637 100644 --- a/homeassistant/components/pooldose/strings.json +++ b/homeassistant/components/pooldose/strings.json @@ -160,6 +160,9 @@ "acid": "pH-", "alcalyne": "pH+" } + }, + "water_meter_total_permanent": { + "name": "Totalizer" } }, "switch": { diff --git a/tests/components/pooldose/fixtures/instantvalues.json b/tests/components/pooldose/fixtures/instantvalues.json index 85849410a39..7be433dfe95 100644 --- a/tests/components/pooldose/fixtures/instantvalues.json +++ b/tests/components/pooldose/fixtures/instantvalues.json @@ -18,7 +18,7 @@ }, "flow_rate": { "value": 150, - "unit": "L/s" + "unit": "l/s" }, "ph_type_dosing": { "value": "alcalyne", @@ -75,6 +75,14 @@ "orp_calibration_slope": { "value": 0.96, "unit": "mV" + }, + "water_meter_total_permanent": { + "value": 12345.67, + "unit": "m3" + }, + "water_meter_total_resettable": { + "value": 123.45, + "unit": "m3" } }, "binary_sensor": { diff --git a/tests/components/pooldose/snapshots/test_sensor.ambr b/tests/components/pooldose/snapshots/test_sensor.ambr index bd899aa5b2f..f07064abcc0 100644 --- a/tests/components/pooldose/snapshots/test_sensor.ambr +++ b/tests/components/pooldose/snapshots/test_sensor.ambr @@ -1054,3 +1054,59 @@ 'state': '25', }) # --- +# name: test_all_sensors[sensor.pool_device_totalizer-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.pool_device_totalizer', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Totalizer', + 'platform': 'pooldose', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'water_meter_total_permanent', + 'unique_id': 'TEST123456789_water_meter_total_permanent', + 'unit_of_measurement': , + }) +# --- +# name: test_all_sensors[sensor.pool_device_totalizer-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'volume', + 'friendly_name': 'Pool Device Totalizer', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.pool_device_totalizer', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '12345.67', + }) +# ---