-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,5 @@ | |
"btsocket>=0.2.0", | ||
"pyric>=0.1.6.3" | ||
], | ||
"version": "12.7.2" | ||
"version": "12.8.0-beta" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters