Przeglądaj źródła

Motion detection: convert to event where dps were optional.

binary_sensor has a motion class, and some devices seem to always
return a value, so should remain as binary_sensors.

Only the following devices had the motion dp marked as optional, so
would be better represented as a stateless event:
- ble_solar_light
- pir_spotlight

In the case of the latter, the forced dp would create spurious events,
so removed the `force: true` and instead default the value to false
when no value has been reported yet.

Issue #1068
Jason Rumney 2 lat temu
rodzic
commit
4f40989294

+ 15 - 0
custom_components/tuya_local/devices/ble_solar_light.yaml

@@ -110,8 +110,23 @@ secondary_entities:
             value: Auto
           - dps_val: manual
             value: Manual
+  - entity: event
+    class: motion
+    category: diagnostic
+    dps:
+      - id: 52
+        type: string
+        name: event
+        optional: true
+        mapping:
+          - dps_val: pir
+            value: detected
+          - dps_val: none
+            value: clear
+          - value: null
   - entity: binary_sensor
     class: motion
+    deprecated: event_motion
     category: diagnostic
     dps:
       - id: 52

+ 13 - 3
custom_components/tuya_local/devices/pir_spotlight.yaml

@@ -73,8 +73,20 @@ secondary_entities:
         name: switch
         optional: true
         force: true
+  - entity: event
+    class: motion
+    dps:
+      - id: 52
+        type: string
+        name: event
+        mapping:
+          - dps_val: pir
+            value: detected
+          - dps_val: none
+            value: clear
   - entity: binary_sensor
     class: motion
+    deprecated: event_motion
     dps:
       - id: 52
         type: string
@@ -82,10 +94,8 @@ secondary_entities:
         mapping:
           - dps_val: "pir"
             value: true
-          - dps_val: "none"
-            value: false
+          - value: false
         optional: true
-        force: true
   - entity: select
     name: Motion distance
     category: config