Skip to content

Commit

Permalink
Add Chef iQ CG60
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 committed Jan 6, 2024
1 parent a39ffbe commit 3ea4330
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This custom component for [Home Assistant](https://www.home-assistant.io) passiv
- Blustream (Taylor TaylorSense, D'Addario Humiditrak)
- BTHome
- b-parasite
- Chef iQ
- Ela
- Govee
- Grundfos
Expand Down
5 changes: 5 additions & 0 deletions custom_components/ble_monitor/ble_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .blustream import parse_blustream
from .bparasite import parse_bparasite
from .bthome import parse_bthome
from .chefiq import parse_chefiq
from .const import JAALEE_TYPES, TILT_TYPES
from .govee import parse_govee
from .grundfos import parse_grundfos
Expand Down Expand Up @@ -311,6 +312,10 @@ def parse_advertisement(
# Oral-b
sensor_data = parse_oral_b(self, man_spec_data, mac, rssi)
break
elif comp_id == 0x05CD and data_len == 0x15:
# Chef iQ
sensor_data = parse_chefiq(self, man_spec_data, mac, rssi)
break
elif comp_id == 0x0131:
# Oras
sensor_data = parse_oras(self, man_spec_data, mac, rssi)
Expand Down
60 changes: 60 additions & 0 deletions custom_components/ble_monitor/ble_parser/chefiq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""Parser for Chef iQ BLE advertisements."""
import logging
from struct import unpack

from .helpers import to_mac, to_unformatted_mac

_LOGGER = logging.getLogger(__name__)


def parse_chefiq(self, data, source_mac, rssi):
"""Parse Chef iQ advertisement."""
msg_length = len(data)
firmware = "Chef iQ"
chefiq_mac = source_mac
msg = data[6:]
if msg_length == 22:
# Chef iQ CQ60
device_type = "CQ60"
(batt, temp_1, temp_2, temp_3, temp_4, temp_5, temp_6, temp_7, humi) = unpack(
"<BBHHHHHHh", msg
)
log_cnt = "no packet id"
result = {
"battery": batt,
"temperature": temp_1,
"temperature probe 1": temp_2 / 10,
"temperature probe 2": temp_3 / 10,
"temperature probe 3": temp_4 / 10,
"temperature probe 4": temp_5 / 10,
"temperature probe 5": temp_6 / 10,
"temperature probe 6": temp_7 / 10,
"humidity": humi / 100,
}
else:
if self.report_unknown == "Chef iQ":
_LOGGER.info(
"BLE ADV from UNKNOWN Chef iQ DEVICE: RSSI: %s, MAC: %s, ADV: %s",
rssi,
to_mac(source_mac),
data.hex()
)
return None

# check for MAC presence in whitelist, if needed
if self.discovery is False and chefiq_mac not in self.sensor_whitelist:
_LOGGER.debug(
"Discovery is disabled. MAC: %s is not whitelisted!",
to_mac(chefiq_mac)
)
return None

result.update({
"rssi": rssi,
"mac": to_unformatted_mac(chefiq_mac),
"type": device_type,
"packet": log_cnt,
"firmware": firmware,
"data": True
})
return result
7 changes: 7 additions & 0 deletions custom_components/ble_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,7 @@ class BLEMonitorBinarySensorEntityDescription(
'Amazfit Smart Scale' : 'Amazfit',
'Blustream' : 'Blustream',
'BTHome' : 'BTHome',
'CQ60' : 'Chef iQ',
'MI401' : 'Grundfos',
'HHCCJCY10' : 'HHCC',
'HolyIOT BLE tracker' : 'HolyIOT',
Expand Down Expand Up @@ -1999,6 +2000,11 @@ class BLEMonitorBinarySensorEntityDescription(
"rssi",
"temperature",
"temperature probe 1",
"temperature probe 2",
"temperature probe 3",
"temperature probe 4",
"temperature probe 5",
"temperature probe 6",
"text",
"timestamp",
"tvoc",
Expand All @@ -2023,6 +2029,7 @@ class BLEMonitorBinarySensorEntityDescription(
"BlueMaestro",
"Blustream",
"BTHome",
'Chef iQ',
"Govee",
"Grundfos",
"HHCC",
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"btsocket>=0.2.0",
"pyric>=0.1.6.3"
],
"version": "12.7.2"
"version": "12.8.0-beta"
}
30 changes: 30 additions & 0 deletions custom_components/ble_monitor/test/test_chefiq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""The tests for the Chef iQ ble_parser."""
from ble_monitor.ble_parser import BleParser


class TestChefiQ:
"""Tests for the Chef iQ parser"""

def test_chefiq_cq60(self):
"""Test Chef iQ parser for CQ60 Chef iQ wireless meat thermometer"""
data_string = "043E250201000073332e3638d91902010615ffcd0501406313c000c900c900ca00cb00c0008d11CC"
data = bytes(bytearray.fromhex(data_string))
# pylint: disable=unused-variable
ble_parser = BleParser()
sensor_msg, tracker_msg = ble_parser.parse_raw_data(data)

assert sensor_msg["firmware"] == "Chef iQ"
assert sensor_msg["type"] == "CQ60"
assert sensor_msg["mac"] == "D938362E3373"
assert sensor_msg["packet"] == "no packet id"
assert sensor_msg["data"]
assert sensor_msg["temperature"] == 19
assert sensor_msg["temperature probe 1"] == 19.2
assert sensor_msg["temperature probe 2"] == 20.1
assert sensor_msg["temperature probe 3"] == 20.1
assert sensor_msg["temperature probe 4"] == 20.2
assert sensor_msg["temperature probe 5"] == 20.3
assert sensor_msg["temperature probe 6"] == 19.2
assert sensor_msg["humidity"] == 44.93
assert sensor_msg["battery"] == 99
assert sensor_msg["rssi"] == -52
2 changes: 1 addition & 1 deletion docs/config_params.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Data from sensors with other addresses will be ignored. Default value: True

**Report unknown sensors**

(`Off`, `Acconeer`, `Air Mentor`, `Amazfit`, `ATC`, `BlueMaestro`, `Blustream`, `Brifit`, `BTHome`, `Govee`, `Grundfos`, `HolyIOT`, `Hormann`, `HHCC`, `iNode`, `iBeacon`, `Jinou`, `Kegtron`, `Mi Scale`, `Mi Band`,`Mikrotik`, `Oras`, `Qingping`, `Relsib`, `rbaron`, `Ruuvitag`, `Sensirion`, `SensorPush`, `SmartDry`, `Switchbot`, `Teltonika`, `Thermoplus`, `Xiaogui`, `Xiaomi`, `Other` or `False`)(Optional) This option is needed primarily for those who want to request an implementation of device support that is not in the list of [supported sensors](devices). If you set this parameter to one of the sensor brands, then the component will log all messages from unknown devices of the specified brand to the Home Assistant log (`logger` component must be enabled at info level, see for instructions the [FAQ](faq#my-sensor-from-the-xiaomi-ecosystem-is-not-in-the-list-of-supported-ones-how-to-request-implementation)). Using a sensor brand might not catch all BLE advertisements.
(`Off`, `Acconeer`, `Air Mentor`, `Amazfit`, `ATC`, `BlueMaestro`, `Blustream`, `Brifit`, `BTHome`, `Chef iQ`, `Govee`, `Grundfos`, `HolyIOT`, `Hormann`, `HHCC`, `iNode`, `iBeacon`, `Jinou`, `Kegtron`, `Mi Scale`, `Mi Band`,`Mikrotik`, `Oras`, `Qingping`, `Relsib`, `rbaron`, `Ruuvitag`, `Sensirion`, `SensorPush`, `SmartDry`, `Switchbot`, `Teltonika`, `Thermoplus`, `Xiaogui`, `Xiaomi`, `Other` or `False`)(Optional) This option is needed primarily for those who want to request an implementation of device support that is not in the list of [supported sensors](devices). If you set this parameter to one of the sensor brands, then the component will log all messages from unknown devices of the specified brand to the Home Assistant log (`logger` component must be enabled at info level, see for instructions the [FAQ](faq#my-sensor-from-the-xiaomi-ecosystem-is-not-in-the-list-of-supported-ones-how-to-request-implementation)). Using a sensor brand might not catch all BLE advertisements.

If you can't find the advertisements in this way, you can set this option to `Other`, which will result is all BLE advertisements being logged. You can also enable this option at device level. **Attention!** Enabling this option can lead to huge output to the Home Assistant log, especially when set to `Other`, do not enable it if you do not need it! If you know the MAC address of the sensor, its advised to set this option at device level. Details in the [FAQ](faq#my-sensor-from-the-xiaomi-ecosystem-is-not-in-the-list-of-supported-ones-how-to-request-implementation). Default value: `Off`

Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest-homeassistant-custom-component==0.13.83
pytest-homeassistant-custom-component==0.13.87

# BLE montitor requirements
pycryptodomex==3.19.0
Expand Down

0 comments on commit 3ea4330

Please sign in to comment.