From 00d9581bfb766f9ab95d3034afc45e4f9dcaf58f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 31 Jan 2024 08:43:18 -1000 Subject: [PATCH] feat: add support for h5100 (#81) --- src/govee_ble/parser.py | 3 ++ tests/test_parser.py | 72 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/src/govee_ble/parser.py b/src/govee_ble/parser.py index 75d6261..5396875 100644 --- a/src/govee_ble/parser.py +++ b/src/govee_ble/parser.py @@ -170,6 +170,7 @@ def _process_mfr_data( if msg_length in (6, 8) and ( (is_5108 := "H5108" in local_name) + or (is_5100 := "H5100" in local_name) or (is_5101 := "H5101" in local_name) or (is_5102 := "H5102" in local_name) or (is_5103 := "H5103" in local_name) @@ -181,6 +182,8 @@ def _process_mfr_data( ): if is_5108 or msg_length == 8: self.set_device_type("H5108") + elif is_5100: + self.set_device_type("H5100") elif is_5101: self.set_device_type("H5101") elif is_5102: diff --git a/tests/test_parser.py b/tests/test_parser.py index 608f2a5..71bf54d 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -500,6 +500,16 @@ rssi=-45, ) +GVH5100_SERVICE_INFO = BluetoothServiceInfo( + name="GVH5100_7738", + address="C4:35:33:33:77:38", + manufacturer_data={1: b"\x01\x01\x03FTd"}, + service_uuids=["0000ec88-0000-1000-8000-00805f9b34fb"], + service_data={}, + source="local", + rssi=-45, +) + def test_can_create(): GoveeBluetoothDeviceData() @@ -1125,6 +1135,68 @@ def test_gvh5105(): ) +def test_gvh5100(): + parser = GoveeBluetoothDeviceData() + service_info = GVH5100_SERVICE_INFO + result = parser.update(service_info) + assert result == SensorUpdate( + title=None, + devices={ + None: SensorDeviceInfo( + name="H5100 7738", + model="H5100", + manufacturer="Govee", + sw_version=None, + hw_version=None, + ) + }, + entity_descriptions={ + DeviceKey(key="temperature", device_id=None): SensorDescription( + device_key=DeviceKey(key="temperature", device_id=None), + device_class=DeviceClass.TEMPERATURE, + native_unit_of_measurement=Units.TEMP_CELSIUS, + ), + DeviceKey(key="humidity", device_id=None): SensorDescription( + device_key=DeviceKey(key="humidity", device_id=None), + device_class=DeviceClass.HUMIDITY, + native_unit_of_measurement=Units.PERCENTAGE, + ), + DeviceKey(key="battery", device_id=None): SensorDescription( + device_key=DeviceKey(key="battery", device_id=None), + device_class=DeviceClass.BATTERY, + native_unit_of_measurement=Units.PERCENTAGE, + ), + DeviceKey(key="signal_strength", device_id=None): SensorDescription( + device_key=DeviceKey(key="signal_strength", device_id=None), + device_class=DeviceClass.SIGNAL_STRENGTH, + native_unit_of_measurement=Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT, + ), + }, + entity_values={ + DeviceKey(key="temperature", device_id=None): SensorValue( + device_key=DeviceKey(key="temperature", device_id=None), + name="Temperature", + native_value=21.4, + ), + DeviceKey(key="humidity", device_id=None): SensorValue( + device_key=DeviceKey(key="humidity", device_id=None), + name="Humidity", + native_value=61.2, + ), + DeviceKey(key="battery", device_id=None): SensorValue( + device_key=DeviceKey(key="battery", device_id=None), + name="Battery", + native_value=100, + ), + DeviceKey(key="signal_strength", device_id=None): SensorValue( + device_key=DeviceKey(key="signal_strength", device_id=None), + name="Signal Strength", + native_value=-45, + ), + }, + ) + + def test_gvh5184_packet_type_1(): parser = GoveeBluetoothDeviceData() result = parser.update(GVH5184_SERVICE_INFO_1)