Skip to content

Commit c427e2e

Browse files
authored
Merge pull request #1464 from custom-components/CGP22C
Add CGP22C Qingping CO2 sensor
2 parents 10be1f3 + 0940422 commit c427e2e

File tree

8 files changed

+45
-4
lines changed

8 files changed

+45
-4
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Custom components for Home Assistant
3+
Copyright (c) 2025 Custom components for Home Assistant
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

custom_components/ble_monitor/ble_parser/qingping.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def parse_qingping(self, data: bytes, mac: bytes):
2727
device_type = "CGD1"
2828
elif device_id in [0x0E, 0x24]:
2929
device_type = "CGDN1"
30+
elif device_id == 0x5D:
31+
device_type = "CGP22C"
3032
else:
3133
device_type = None
3234

custom_components/ble_monitor/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ class BLEMonitorBinarySensorEntityDescription(
22482248
'TG-BT5-IN' : 'Mikrotik',
22492249
'TG-BT5-OUT' : 'Mikrotik',
22502250
'Electra Washbasin Faucet': 'Oras',
2251+
'CGP22C' : 'Qingping',
22512252
'CGP23W' : 'Qingping',
22522253
'EClerk Eco' : 'Relsib',
22532254
'WT51' : 'Relsib',

custom_components/ble_monitor/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"iot_class": "local_polling",
99
"issue_tracker": "https://github.com/custom-components/ble_monitor/issues",
1010
"requirements": [
11-
"pycryptodomex>=3.21.0",
11+
"pycryptodomex>=3.23.0",
1212
"janus>=2.0.0",
1313
"aioblescan>=0.2.14",
1414
"btsocket>=0.3.0",
1515
"pyric>=0.1.6.3"
1616
],
17-
"version": "13.3.0"
17+
"version": "13.4.0"
1818
}

custom_components/ble_monitor/test/test_qingping_parser.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ def test_qingping_CGG1(self):
5959
assert sensor_msg["battery"] == 56
6060
assert sensor_msg["rssi"] == -81
6161

62+
def test_qingping_CGP22C(self):
63+
"""Test Qingping parser for CGP22C."""
64+
data_string = "043E2802010000c11b86342d581C0201061816cdfd0a5dc11b86342d580104ff00af0102016413024702D1"
65+
66+
data = bytes(bytearray.fromhex(data_string))
67+
# pylint: disable=unused-variable
68+
ble_parser = BleParser()
69+
sensor_msg, tracker_msg = ble_parser.parse_raw_data(data)
70+
71+
assert sensor_msg["firmware"] == "Qingping"
72+
assert sensor_msg["type"] == "CGP22C"
73+
assert sensor_msg["mac"] == "582D34861BC1"
74+
assert sensor_msg["packet"] == "no packet id"
75+
assert sensor_msg["data"]
76+
assert sensor_msg["temperature"] == 25.5
77+
assert sensor_msg["humidity"] == 43.1
78+
assert sensor_msg["battery"] == 100
79+
assert sensor_msg["co2"] == 583
80+
assert sensor_msg["rssi"] == -47
81+
6282
def test_qingping_CGP23W(self):
6383
"""Test Qingping parser for CGP23W."""
6484
data_string = "043E2802010000072240342d581C0201061816cdfd8818072240342d5801041701ca0002016107027227D1"

docs/_devices/CGP22C.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
manufacturer: Qingping
3+
name: CO2 detector
4+
model: CGP22C
5+
image: CGP22C.png
6+
physical_description: Rounded square body, LCD display
7+
broadcasted_properties:
8+
- temperature
9+
- humidity
10+
- battery
11+
- co2
12+
- rssi
13+
broadcasted_property_notes:
14+
broadcast_rate:
15+
active_scan:
16+
encryption_key:
17+
custom_firmware:
18+
---

docs/assets/images/CGP22C.png

366 KB
Loading

requirements_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pytest-homeassistant-custom-component==0.13.193
22

33
# BLE monitor requirements
4-
pycryptodomex==3.21.0
4+
pycryptodomex==3.23.0
55
janus==2.0.0
66
aioblescan==0.2.14
77
btsocket==0.3.0

0 commit comments

Comments
 (0)