Skip to content

Commit 187cdc2

Browse files
authored
fix climate panel adv parse (#409)
1 parent b414b90 commit 187cdc2

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

switchbot/adv_parsers/climate_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def process_climate_panel(
2626
humidity = mfr_data[10] & 0x7F
2727

2828
pir_state = bool(mfr_data[15] & 0x80)
29-
is_light = ((mfr_data[15] >> 2) & 0x03) == 0x10
29+
is_light = ((mfr_data[15] >> 1) & 0x03) == 0x02
3030

3131
result = {
3232
"sequence_number": seq_number,

tests/test_adv_parser.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3431,18 +3431,36 @@ def test_humidifer_with_empty_data() -> None:
34313431
SwitchbotModel.K11_VACUUM,
34323432
),
34333433
AdvTestCase(
3434-
b"\xb0\xe9\xfe\x8e\x98Oi_\x06\x9a,\x00\x00\x00\x00\xe4\x00\x08\x04\x00\x01\x00\x00",
3434+
b"\xb0\xe9\xfe\x848\x05\x06\x14\x05\x99-\x00\x00\x00\x00\xd4\x00\x0c\x04\x00",
34353435
b"\x00 _\x00\x10\xf3\xd8@",
34363436
{
3437-
"battery": 95,
3438-
"humidity": 44,
3439-
"sequence_number": 105,
3437+
"battery": 20,
3438+
"humidity": 45,
3439+
"sequence_number": 6,
3440+
"humidity_alarm": 0,
3441+
"isOn": False,
3442+
"is_light": True,
3443+
"motion_detected": True,
3444+
"temp_alarm": 0,
3445+
"temperature": 25.5,
3446+
},
3447+
b"\x00\x10\xf3\xd8",
3448+
"Climate Panel",
3449+
SwitchbotModel.CLIMATE_PANEL,
3450+
),
3451+
AdvTestCase(
3452+
b"\xb0\xe9\xfe\x848\x05\x13\x14\t\x99-\x00\x00\x00\x00\xd2\x01\x14\x04\x00",
3453+
b"\x00 _\x00\x10\xf3\xd8@",
3454+
{
3455+
"battery": 20,
3456+
"humidity": 45,
3457+
"sequence_number": 19,
34403458
"humidity_alarm": 0,
34413459
"isOn": False,
34423460
"is_light": False,
34433461
"motion_detected": True,
34443462
"temp_alarm": 0,
3445-
"temperature": 26.6,
3463+
"temperature": 25.9,
34463464
},
34473465
b"\x00\x10\xf3\xd8",
34483466
"Climate Panel",
@@ -3691,7 +3709,7 @@ def test_adv_active(test_case: AdvTestCase) -> None:
36913709
"sequence_number": 105,
36923710
"humidity_alarm": 0,
36933711
"isOn": False,
3694-
"is_light": False,
3712+
"is_light": True,
36953713
"motion_detected": True,
36963714
"temp_alarm": 0,
36973715
"temperature": 26.6,

0 commit comments

Comments
 (0)