Skip to content

Commit

Permalink
feat: add support for temp rh pro e (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Oct 16, 2022
1 parent fad2d2a commit 7c7c9af
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/qingping_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class QingpingDevice:
0x04: QingpingDevice("CGH1", "Door/Window Sensor"), # Door/Window Sensor
0x07: QingpingDevice("CGG1", ""),
0x09: QingpingDevice("CGP1W", ""),
0x16: QingpingDevice("CGG1", "Qingping Temp RH M"),
0x15: QingpingDevice("CGF1W", "Temp RH Pro E"),
0x16: QingpingDevice("CGG1", "Temp RH M"),
0x12: QingpingDevice("CGPR1", "Motion & Light"),
0x1E: QingpingDevice("CGC1", "BT Clock Lite"),
0x0C: QingpingDevice("CGD1", "Alarm Clock"),
Expand All @@ -56,6 +57,9 @@ def _start_update(self, service_info: BluetoothServiceInfo) -> None:
unpadded_data = service_info.service_data[SERVICE_DATA_UUID]
data = b"\x00\x00\x00\x00" + unpadded_data
device_id = data[5]
import pprint

pprint.pprint(["device_id", device_id])
if not (device := DEVICE_TYPES.get(device_id)):
_LOGGER.debug("Device type %s is not supported", device_id)
return
Expand Down
79 changes: 77 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ def test_can_create():
source="local",
)

QINGPING_TEMP_RH_PRO_E = BluetoothServiceInfo(
name="Qingping Temp RH Pro E",
manufacturer_data={},
service_uuids=[],
address="aa:bb:cc:dd:ee:ff",
rssi=-60,
service_data={
"0000fdcd-0000-1000-8000-00805f9b34fb": b"\x08\x15\x01'@4-X\x01\x04\xde\x00\xe9\x01\x02\x01d"
},
source="local",
)


def test_supported_motion_and_light():
parser = QingpingBluetoothDeviceData()
Expand Down Expand Up @@ -780,10 +792,10 @@ def test_temp_rh_m():
parser = QingpingBluetoothDeviceData()
parsed = parser.update(QINGPING_TEMP_RH_M)
assert parsed == SensorUpdate(
title="Qingping Temp RH M EEFF",
title="Temp RH M EEFF",
devices={
None: SensorDeviceInfo(
name="Qingping Temp RH M EEFF",
name="Temp RH M EEFF",
model="CGG1",
manufacturer="Qingping",
sw_version=None,
Expand Down Expand Up @@ -837,3 +849,66 @@ def test_temp_rh_m():
binary_entity_descriptions={},
binary_entity_values={},
)


def test_temp_rh_pro_e():
parser = QingpingBluetoothDeviceData()
parsed = parser.update(QINGPING_TEMP_RH_PRO_E)
assert parsed == SensorUpdate(
title="Temp RH Pro E EEFF",
devices={
None: SensorDeviceInfo(
name="Temp RH Pro E EEFF",
model="CGF1W",
manufacturer="Qingping",
sw_version=None,
hw_version=None,
)
},
entity_descriptions={
DeviceKey(key="humidity", device_id=None): SensorDescription(
device_key=DeviceKey(key="humidity", device_id=None),
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=Units.PERCENTAGE,
),
DeviceKey(key="temperature", device_id=None): SensorDescription(
device_key=DeviceKey(key="temperature", device_id=None),
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=Units.TEMP_CELSIUS,
),
DeviceKey(key="signal_strength", device_id=None): SensorDescription(
device_key=DeviceKey(key="signal_strength", device_id=None),
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
native_unit_of_measurement=Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
),
DeviceKey(key="battery", device_id=None): SensorDescription(
device_key=DeviceKey(key="battery", device_id=None),
device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=Units.PERCENTAGE,
),
},
entity_values={
DeviceKey(key="humidity", device_id=None): SensorValue(
device_key=DeviceKey(key="humidity", device_id=None),
name="Humidity",
native_value=48.9,
),
DeviceKey(key="temperature", device_id=None): SensorValue(
device_key=DeviceKey(key="temperature", device_id=None),
name="Temperature",
native_value=22.2,
),
DeviceKey(key="signal_strength", device_id=None): SensorValue(
device_key=DeviceKey(key="signal_strength", device_id=None),
name="Signal " "Strength",
native_value=-60,
),
DeviceKey(key="battery", device_id=None): SensorValue(
device_key=DeviceKey(key="battery", device_id=None),
name="Battery",
native_value=100,
),
},
binary_entity_descriptions={},
binary_entity_values={},
)

0 comments on commit 7c7c9af

Please sign in to comment.