Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use volume storage instead of water storage #102

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/bthome_ble/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
)

Expand Down Expand Up @@ -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,
),
Expand Down
18 changes: 9 additions & 9 deletions tests/test_parser_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand All @@ -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(
Expand All @@ -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(
Expand Down