Răsfoiți Sursa

Doorbells: convert to event, deprecate binary_sensor workarounds.

- event: add ability to filter out dp values by mapping them to null
- ble_hu06_lock
- bstuokey_access_keypad
- lucking_hs6_lock
- rl_video_lock
- smardeer_lock33
- smart_siren_alarm

Issue #1068
Jason Rumney 2 ani în urmă
părinte
comite
5f697ac237

+ 14 - 0
custom_components/tuya_local/devices/ble_hu06_lock.yaml

@@ -137,8 +137,22 @@ secondary_entities:
         mapping:
           - dps_val: null
             value: false
+  - entity: event
+    class: doorbell
+    category: diagnostic
+    dps:
+      - id: 24
+        type: boolean
+        name: event
+        optional: true
+        mapping:
+          - dps_val: true
+            value: ring
+          - dps_val: false
+            value: null
   - entity: binary_sensor
     name: Doorbell
+    deprecated: event_doorbell
     class: sound
     category: diagnostic
     dps:

+ 12 - 0
custom_components/tuya_local/devices/bstuokey_access_keypad.yaml

@@ -106,8 +106,20 @@ secondary_entities:
           max: 180
         mapping:
           - step: 10
+  - entity: event
+    class: doorbell
+    dps:
+      - id: 101
+        type: boolean
+        name: event
+        mapping:
+          - dps_val: true
+            value: ring
+          - dps_val: false
+            value: null
   - entity: binary_sensor
     name: Doorbell
+    deprecated: event_doorbell
     class: sound
     dps:
       - id: 101

+ 14 - 0
custom_components/tuya_local/devices/lucking_hs6_lock.yaml

@@ -204,8 +204,22 @@ secondary_entities:
         type: string
         name: doorbell_song_kit
         optional: true
+  - entity: event
+    class: doorbell
+    category: diagnostic
+    dps:
+      - id: 101
+        type: boolean
+        optional: true
+        name: event
+        mapping:
+          - dps_val: true
+            value: ring
+          - dps_val: false
+            value: null
   - entity: binary_sensor
     name: Doorbell
+    deprecated: event_doorbell
     class: sound
     category: diagnostic
     dps:

+ 13 - 0
custom_components/tuya_local/devices/rl_video_lock.yaml

@@ -30,8 +30,21 @@ secondary_entities:
       - id: 232
         type: boolean
         name: lock
+  - entity: event
+    class: doorbell
+    category: diagnostic
+    dps:
+      - id: 136
+        type: string
+        name: event
+        optional: true
+        mapping:
+          - dps_val: ""
+            value: null
+          - value: ring
   - entity: binary_sensor
     name: Doorbell
+    deprecated: event_doorbell
     class: sound
     category: diagnostic
     dps:

+ 14 - 0
custom_components/tuya_local/devices/smardeer_lock33.yaml

@@ -84,8 +84,22 @@ secondary_entities:
         type: boolean
         name: sensor
         optional: true
+  - entity: event
+    class: doorbell
+    category: diagnostic
+    dps:
+      - id: 19
+        type: boolean
+        optional: true
+        name: event
+        mapping:
+          - dps_val: true
+            value: ring
+          - dps_val: false
+            value: null
   - entity: binary_sensor
     name: Doorbell
+    deprecated: event_doorbell
     class: sound
     category: diagnostic
     dps:

+ 14 - 2
custom_components/tuya_local/devices/smart_siren_alarm.yaml

@@ -225,9 +225,22 @@ secondary_entities:
       - id: 127
         type: boolean
         name: switch
-        optional: true          
+        optional: true
+  - entity: event
+    class: doorbell
+    category: diagnostic
+    dps:
+      - id: 128
+        type: string
+        name: event
+        optional: true
+        mapping:
+          - dps_val: "ACA="
+            value: ring
+          - value: null
   - entity: binary_sensor
     name: Doorbell push
+    deprecated: event_doorbell
     category: diagnostic
     icon: "mdi:crosshairs-question"
     dps:
@@ -235,7 +248,6 @@ secondary_entities:
         type: string
         name: sensor
         optional: true
-        readonly: true
         mapping:
           - dps_val: "ACA="
             value: true

+ 6 - 4
custom_components/tuya_local/event.py

@@ -52,7 +52,9 @@ class TuyaLocalEvent(TuyaLocalEntity, EventEntity):
     def on_receive(self, dps):
         """Trigger the event when dp is received"""
         if self._event_dp.id in dps:
-            self._trigger_event(
-                self._event_dp.get_value(self._device),
-                self.extra_state_attributes(),
-            )
+            value = self._event_dp.get_value(self._device)
+            if value is not None:
+                self._trigger_event(
+                    value,
+                    self.extra_state_attributes(),
+                )

+ 4 - 0
tests/const.py

@@ -1633,3 +1633,7 @@ IR_REMOTE_SENSORS_PAYLOAD = {
     "101": 200,
     "102": 80,
 }
+
+LORATAP_CURTAINSWITCH_PAYLOAD = {
+    "1": "3",
+}