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

feat: add support for h5100 #81

Merged
merged 2 commits into from
Jan 31, 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
3 changes: 3 additions & 0 deletions src/govee_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
72 changes: 72 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Loading