瀏覽代碼

PG103/107: restore binary sensors for battery and power

Although previous comment on #1059 suggested that these act more as events,
and do not correctly reset when the power or battery is restored, based
on new information on #3272 they appear to be indicating that the alarm is
sounding for these events, and will correctly reset when the alarm is stopped.

Therefore they are useful as state sensors to check if the alarm is sounding.
Jason Rumney 11 月之前
父節點
當前提交
7fbb725245
共有 1 個文件被更改,包括 26 次插入2 次删除
  1. 26 2
      custom_components/tuya_local/devices/gautone_pg103_alarm.yaml

+ 26 - 2
custom_components/tuya_local/devices/gautone_pg103_alarm.yaml

@@ -112,15 +112,15 @@ entities:
         type: string
         name: sensor
         mapping:
-          - dps_val: normal
-            value: false
           - dps_val: alarm
             value: true
+          - value: false
   - entity: event
     name: Alarm
     dps:
       - id: 26
         type: string
+        optional: true
         name: event
         mapping:
           - dps_val: null
@@ -138,8 +138,32 @@ entities:
         type: string
         optional: true
         name: sub_state
+  - entity: binary_sensor
+    class: battery
+    category: diagnostic
+    dps:
+      - id: 101
+        type: string
+        optional: true
+        name: sensor
+        mapping:
+          - dps_val: low_battery
+            value: true
+          - value: false
+  - entity: binary_sensor
+    class: power
+    category: diagnostic
+    dps:
+      - id: 101
+        type: boolean
+        name: sensor
+        mapping:
+          - dps_val: powerDisconnect
+            value: false
+          - value: true
   - entity: event
     name: Power
+    deprecated: binary_sensors for battery and power
     dps:
       - id: 101
         type: string