From 02fef3de84c22ebd3daa2ed2ee2cdc182f66f57a Mon Sep 17 00:00:00 2001 From: Icereed Date: Sun, 19 Jul 2026 01:21:58 +0200 Subject: [PATCH] Add tank pressure and water temperature sensors to Gardena Bluetooth (#176798) --- .../components/gardena_bluetooth/sensor.py | 21 ++++ .../components/gardena_bluetooth/strings.json | 6 + .../components/gardena_bluetooth/__init__.py | 12 ++ .../snapshots/test_sensor.ambr | 119 ++++++++++++++++++ .../gardena_bluetooth/test_sensor.py | 16 ++- 5 files changed, 173 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/gardena_bluetooth/sensor.py b/homeassistant/components/gardena_bluetooth/sensor.py index 1a528e460bf4..e6506e6242de 100644 --- a/homeassistant/components/gardena_bluetooth/sensor.py +++ b/homeassistant/components/gardena_bluetooth/sensor.py @@ -11,6 +11,7 @@ from gardena_bluetooth.const import ( Battery, EventHistory, FlowStatistics, + Pump, Sensor, Spray, Valve, @@ -28,6 +29,8 @@ from homeassistant.const import ( DEGREE, PERCENTAGE, EntityCategory, + UnitOfPressure, + UnitOfTemperature, UnitOfVolume, UnitOfVolumeFlowRate, ) @@ -164,6 +167,24 @@ DESCRIPTIONS = ( char=FlowStatistics.last_reset, get=_get_timestamp, ), + GardenaBluetoothSensorEntityDescription( + key=Pump.tank_preassure.unique_id, + translation_key="tank_pressure", + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.PRESSURE, + native_unit_of_measurement=UnitOfPressure.MBAR, + suggested_unit_of_measurement=UnitOfPressure.BAR, + suggested_display_precision=2, + char=Pump.tank_preassure, + ), + GardenaBluetoothSensorEntityDescription( + key=Pump.water_temperature.unique_id, + translation_key="water_temperature", + state_class=SensorStateClass.MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + char=Pump.water_temperature, + ), GardenaBluetoothSensorEntityDescription( key=Spray.current_distance.unique_id, translation_key="spray_current_distance", diff --git a/homeassistant/components/gardena_bluetooth/strings.json b/homeassistant/components/gardena_bluetooth/strings.json index 797197beba8b..2ee29ffc7696 100644 --- a/homeassistant/components/gardena_bluetooth/strings.json +++ b/homeassistant/components/gardena_bluetooth/strings.json @@ -151,6 +151,12 @@ }, "spray_current_sector": { "name": "Current sector" + }, + "tank_pressure": { + "name": "Tank pressure" + }, + "water_temperature": { + "name": "Water temperature" } }, "switch": { diff --git a/tests/components/gardena_bluetooth/__init__.py b/tests/components/gardena_bluetooth/__init__.py index 1fd27b5ca10e..e6bbc42c25a9 100644 --- a/tests/components/gardena_bluetooth/__init__.py +++ b/tests/components/gardena_bluetooth/__init__.py @@ -46,6 +46,18 @@ AQUA_CONTOUR_SERVICE_INFO = BluetoothServiceInfo( source="local", ) +PRESSURE_TANK_SERVICE_INFO = BluetoothServiceInfo( + name="GARDENA PTU", + address="00000000-0000-0000-0000-000000000004", + rssi=-63, + service_data={}, + manufacturer_data={ + 1062: b"\x05\x04\x80\x20\x00\x00\x02\x05\x01\x04\x06\x11\x02\x01" + }, + service_uuids=["98bd0001-0b0e-421a-84e5-ddbf75dc6de4"], + source="local", +) + MISSING_PRODUCT_SERVICE_INFO = BluetoothServiceInfo( name="Missing Product Info", address="00000000-0000-0000-0000-000000000000", diff --git a/tests/components/gardena_bluetooth/snapshots/test_sensor.ambr b/tests/components/gardena_bluetooth/snapshots/test_sensor.ambr index 0da2fb18f9ff..2eecb7e525cf 100644 --- a/tests/components/gardena_bluetooth/snapshots/test_sensor.ambr +++ b/tests/components/gardena_bluetooth/snapshots/test_sensor.ambr @@ -484,6 +484,125 @@ 'state': '2023-01-01T01:01:40+00:00', }) # --- +# name: test_sensors[pressure_tank][sensor.mock_title_tank_pressure-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_tank_pressure', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Tank pressure', + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 2, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Tank pressure', + 'platform': 'gardena_bluetooth', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'tank_pressure', + 'unique_id': '00000000-0000-0000-0000-000000000004-98bd0102-0b0e-421a-84e5-ddbf75dc6de4', + 'unit_of_measurement': , + }) +# --- +# name: test_sensors[pressure_tank][sensor.mock_title_tank_pressure-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'pressure', + : 'Mock Title Tank pressure', + : , + : , + }), + 'context': , + 'entity_id': 'sensor.mock_title_tank_pressure', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '3.312', + }) +# --- +# name: test_sensors[pressure_tank][sensor.mock_title_water_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.mock_title_water_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Water temperature', + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Water temperature', + 'platform': 'gardena_bluetooth', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'water_temperature', + 'unique_id': '00000000-0000-0000-0000-000000000004-98bd010e-0b0e-421a-84e5-ddbf75dc6de4', + 'unit_of_measurement': , + }) +# --- +# name: test_sensors[pressure_tank][sensor.mock_title_water_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'temperature', + : 'Mock Title Water temperature', + : , + : , + }), + 'context': , + 'entity_id': 'sensor.mock_title_water_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '21', + }) +# --- # name: test_sensors[timer][sensor.mock_title_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/gardena_bluetooth/test_sensor.py b/tests/components/gardena_bluetooth/test_sensor.py index 58bc06170546..f6bf6727fd12 100644 --- a/tests/components/gardena_bluetooth/test_sensor.py +++ b/tests/components/gardena_bluetooth/test_sensor.py @@ -10,6 +10,7 @@ from gardena_bluetooth.const import ( Battery, EventHistory, FlowStatistics, + Pump, Sensor, Spray, Valve, @@ -23,7 +24,12 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from . import AQUA_CONTOUR_SERVICE_INFO, WATER_TIMER_SERVICE_INFO, setup_entry +from . import ( + AQUA_CONTOUR_SERVICE_INFO, + PRESSURE_TANK_SERVICE_INFO, + WATER_TIMER_SERVICE_INFO, + setup_entry, +) from tests.common import MockConfigEntry, snapshot_platform @@ -106,6 +112,14 @@ async def test_setup( }, id="aqua_contour", ), + pytest.param( + PRESSURE_TANK_SERVICE_INFO, + { + Pump.tank_preassure.uuid: Pump.tank_preassure.encode(3312), + Pump.water_temperature.uuid: Pump.water_temperature.encode(21), + }, + id="pressure_tank", + ), ], ) async def test_sensors(