From d7ca8fa6722f4fc63b1a322a93f3a72a44afaad2 Mon Sep 17 00:00:00 2001 From: Ernst79 Date: Wed, 10 Jan 2024 21:54:55 +0100 Subject: [PATCH] fix: use volume storage instead of water storage --- src/bthome_ble/const.py | 10 +++++----- tests/test_parser_v2.py | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bthome_ble/const.py b/src/bthome_ble/const.py index b46615a..4803993 100644 --- a/src/bthome_ble/const.py +++ b/src/bthome_ble/const.py @@ -34,8 +34,8 @@ class ExtendedSensorDeviceClass(BaseDeviceClass): # Text TEXT = "text" - # Water storage - WATER_STORAGE = "water_storage" + # Volume storage + VOLUME_STORAGE = "volume_storage" class ExtendedSensorLibrary(SensorLibrary): @@ -51,8 +51,8 @@ class ExtendedSensorLibrary(SensorLibrary): native_unit_of_measurement=None, ) - WATER_STORAGE__VOLUME_LITERS = description.BaseSensorDescription( - device_class=ExtendedSensorDeviceClass.WATER_STORAGE, + VOLUME_STORAGE__VOLUME_LITERS = description.BaseSensorDescription( + device_class=ExtendedSensorDeviceClass.VOLUME_STORAGE, native_unit_of_measurement=Units.VOLUME_LITERS, ) @@ -404,7 +404,7 @@ class ExtendedSensorLibrary(SensorLibrary): data_format="raw", ), 0x55: MeasTypes( - meas_format=ExtendedSensorLibrary.WATER_STORAGE__VOLUME_LITERS, + meas_format=ExtendedSensorLibrary.VOLUME_STORAGE__VOLUME_LITERS, data_length=4, factor=0.001, ), diff --git a/tests/test_parser_v2.py b/tests/test_parser_v2.py index dfa8884..13e8f82 100644 --- a/tests/test_parser_v2.py +++ b/tests/test_parser_v2.py @@ -59,8 +59,8 @@ KEY_VOLTAGE = DeviceKey(key="voltage", device_id=None) KEY_VOLUME = DeviceKey(key="volume", device_id=None) KEY_VOLUME_FLOW_RATE = DeviceKey(key="volume_flow_rate", device_id=None) +KEY_VOLUME_STORAGE = DeviceKey(key="volume_storage", device_id=None) KEY_WATER = DeviceKey(key="water", device_id=None) -KEY_WATER_STORAGE = DeviceKey(key="water_storage", device_id=None) @pytest.fixture(autouse=True) @@ -2700,8 +2700,8 @@ def test_bthome_text_invalid(caplog): ) -def test_bthome_water_storage(caplog): - """Test BTHome parser for water storage in Liters.""" +def test_bthome_volume_storage(caplog): + """Test BTHome parser for volume storage in Liters.""" data_string = b"\x40\x55\x87\x56\x2a\x01" advertisement = bytes_to_service_info( data_string, local_name="TEST DEVICE", address="A4:C1:38:8D:18:B2" @@ -2721,9 +2721,9 @@ def test_bthome_water_storage(caplog): ) }, entity_descriptions={ - KEY_WATER_STORAGE: SensorDescription( - device_key=KEY_WATER_STORAGE, - device_class=ExtendedSensorDeviceClass.WATER_STORAGE, + KEY_VOLUME_STORAGE: SensorDescription( + device_key=KEY_VOLUME_STORAGE, + device_class=ExtendedSensorDeviceClass.VOLUME_STORAGE, native_unit_of_measurement=Units.VOLUME_LITERS, ), KEY_SIGNAL_STRENGTH: SensorDescription( @@ -2733,9 +2733,9 @@ def test_bthome_water_storage(caplog): ), }, entity_values={ - KEY_WATER_STORAGE: SensorValue( - device_key=KEY_WATER_STORAGE, - name="Water Storage", + KEY_VOLUME_STORAGE: SensorValue( + device_key=KEY_VOLUME_STORAGE, + name="Volume Storage", native_value=19551.879, ), KEY_SIGNAL_STRENGTH: SensorValue(