Add tank pressure and water temperature sensors to Gardena Bluetooth (#176798)

This commit is contained in:
Icereed
2026-07-19 01:21:58 +02:00
committed by GitHub
parent afc0ceabd1
commit 02fef3de84
5 changed files with 173 additions and 1 deletions
@@ -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",
@@ -151,6 +151,12 @@
},
"spray_current_sector": {
"name": "Current sector"
},
"tank_pressure": {
"name": "Tank pressure"
},
"water_temperature": {
"name": "Water temperature"
}
},
"switch": {
@@ -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",
@@ -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({
<SensorEntityCapabilityAttribute.STATE_CLASS: '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.mock_title_tank_pressure',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Tank pressure',
'options': dict({
'sensor': dict({
'suggested_display_precision': 2,
}),
'sensor.private': dict({
'suggested_unit_of_measurement': <UnitOfPressure.BAR: 'bar'>,
}),
}),
'original_device_class': <SensorDeviceClass.PRESSURE: 'pressure'>,
'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': <UnitOfPressure.BAR: 'bar'>,
})
# ---
# name: test_sensors[pressure_tank][sensor.mock_title_tank_pressure-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'pressure',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Mock Title Tank pressure',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfPressure.BAR: 'bar'>,
}),
'context': <ANY>,
'entity_id': 'sensor.mock_title_tank_pressure',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '3.312',
})
# ---
# name: test_sensors[pressure_tank][sensor.mock_title_water_temperature-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': <ANY>,
'device_class': None,
'device_id': <ANY>,
'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': <ANY>,
'labels': set({
}),
'name': None,
'object_id_base': 'Water temperature',
'options': dict({
'sensor': dict({
'suggested_display_precision': 1,
}),
}),
'original_device_class': <SensorDeviceClass.TEMPERATURE: 'temperature'>,
'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': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_sensors[pressure_tank][sensor.mock_title_water_temperature-state]
StateSnapshot({
'attributes': ReadOnlyDict({
<EntityStateAttribute.DEVICE_CLASS: 'device_class'>: 'temperature',
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Mock Title Water temperature',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.MEASUREMENT: 'measurement'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.mock_title_water_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '21',
})
# ---
# name: test_sensors[timer][sensor.mock_title_battery-entry]
EntityRegistryEntrySnapshot({
'aliases': list([
@@ -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(