Browse Source

Fix Keypad Vision doorbell detection using seq counter instead of transient bit (#468)

Co-authored-by: J. Nick Koston <nick@koston.org>
Retha Runolfsson 4 days ago
parent
commit
efba8b6c39
2 changed files with 6 additions and 0 deletions
  1. 2 0
      switchbot/adv_parsers/keypad_vision.py
  2. 4 0
      tests/test_adv_parser.py

+ 2 - 0
switchbot/adv_parsers/keypad_vision.py

@@ -19,6 +19,7 @@ def process_common_mfr_data(mfr_data: bytes | None) -> dict[str, bool | int]:
     low_temperature = bool(mfr_data[8] & 0b10000000)
     low_temperature = bool(mfr_data[8] & 0b10000000)
     high_temperature = bool(mfr_data[8] & 0b01000000)
     high_temperature = bool(mfr_data[8] & 0b01000000)
     doorbell = bool(mfr_data[12] & 0b00001000)
     doorbell = bool(mfr_data[12] & 0b00001000)
+    doorbell_seq = mfr_data[12] & 0b00000111
 
 
     return {
     return {
         "sequence_number": sequence_number,
         "sequence_number": sequence_number,
@@ -30,6 +31,7 @@ def process_common_mfr_data(mfr_data: bytes | None) -> dict[str, bool | int]:
         "low_temperature": low_temperature,
         "low_temperature": low_temperature,
         "high_temperature": high_temperature,
         "high_temperature": high_temperature,
         "doorbell": doorbell,
         "doorbell": doorbell,
+        "doorbell_seq": doorbell_seq,
     }
     }
 
 
 
 

+ 4 - 0
tests/test_adv_parser.py

@@ -3718,6 +3718,7 @@ def test_humidifer_with_empty_data() -> None:
                 "battery": 95,
                 "battery": 95,
                 "battery_charging": True,
                 "battery_charging": True,
                 "doorbell": False,
                 "doorbell": False,
+                "doorbell_seq": 0,
                 "duress_alarm": False,
                 "duress_alarm": False,
                 "high_temperature": False,
                 "high_temperature": False,
                 "lockout_alarm": False,
                 "lockout_alarm": False,
@@ -3737,6 +3738,7 @@ def test_humidifer_with_empty_data() -> None:
                 "battery": 96,
                 "battery": 96,
                 "battery_charging": False,
                 "battery_charging": False,
                 "doorbell": False,
                 "doorbell": False,
+                "doorbell_seq": 0,
                 "duress_alarm": False,
                 "duress_alarm": False,
                 "high_temperature": False,
                 "high_temperature": False,
                 "lockout_alarm": False,
                 "lockout_alarm": False,
@@ -4057,6 +4059,7 @@ def test_adv_active(test_case: AdvTestCase) -> None:
                 "battery": 95,
                 "battery": 95,
                 "battery_charging": True,
                 "battery_charging": True,
                 "doorbell": False,
                 "doorbell": False,
+                "doorbell_seq": 0,
                 "duress_alarm": False,
                 "duress_alarm": False,
                 "high_temperature": False,
                 "high_temperature": False,
                 "lockout_alarm": False,
                 "lockout_alarm": False,
@@ -4076,6 +4079,7 @@ def test_adv_active(test_case: AdvTestCase) -> None:
                 "battery": 96,
                 "battery": 96,
                 "battery_charging": False,
                 "battery_charging": False,
                 "doorbell": False,
                 "doorbell": False,
+                "doorbell_seq": 0,
                 "duress_alarm": False,
                 "duress_alarm": False,
                 "high_temperature": False,
                 "high_temperature": False,
                 "lockout_alarm": False,
                 "lockout_alarm": False,