Просмотр исходного кода

EV chargers and others: expose real time update switch/refresh button

- many devices have a dp that indicates "online" or
"offline". Originally this was implemented in many devices as a binary
sensor with class connectivity. This is not particularly useful, as if
a device is offline, it will not be able to communicate so it always
seemed strange to put such a dp on a device.

Over time, it has been discovered that these dps are actually
writable, and control the frequency of updates from the device.

- on devices where the dp was always reported, implement it as a
  "Real time updates" switch
- on devices that do not always report it, implement it as a
  "Refresh" button.

Usually, sending "online" will take effect for a limited period, and
need to be resent after a while.

Issue #4396
Jason Rumney 3 дней назад
Родитель
Сommit
e487399378

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

@@ -158,8 +158,21 @@ entities:
         mapping:
           - scale: 100
 
+  - entity: switch
+    name: Real time updates
+    category: config
+    dps:
+      - id: 27
+        type: string
+        name: switch
+        mapping:
+          - dps_val: online
+            value: true
+          - dps_val: offline
+            value: false
   - entity: binary_sensor  # online_state -27-
     class: connectivity
+    deprecated: switch.real_time_updates  # 2026-06-29
     category: diagnostic
     dps:
       - id: 27

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

@@ -222,8 +222,21 @@ entities:
         optional: true
         mapping:
           - scale: 100
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 27
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
+    deprecated: button_refresh  # 2026-06-29
     category: diagnostic
     dps:
       - id: 27

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

@@ -184,9 +184,22 @@ entities:
         optional: true
         mapping:
           - scale: 100
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 27
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 27
         type: string

+ 12 - 0
custom_components/tuya_local/devices/dowell_dchs-k7_32_7kw_ev_charger.yaml

@@ -451,10 +451,22 @@ entities:
       - id: 16    # clear_energy
         type: boolean
         optional: true
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 27
+        type: string
+        optional: true
         name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 27    # online_state
         type: string

+ 23 - 5
custom_components/tuya_local/devices/evsun_evcharger.yaml

@@ -1,6 +1,6 @@
 name: EV charger
 products:
-  - id: e1kw2auo
+  - id: cxriym8xwbnj4xdl
     manufacturer: Andalung
     model: "Portable EV Charger"
 entities:
@@ -235,10 +235,6 @@ entities:
             value: scheduled_charge
           - dps_val: charge_delay
             value: delayed_charge
-      - id: 33
-        optional: true
-        type: base64
-        name: mode_set
   - entity: sensor
     name: Remaining
     class: energy_storage
@@ -311,8 +307,21 @@ entities:
         unit: kWh
         mapping:
           - scale: 100
+  - entity: switch
+    name: Real time updates
+    category: config
+    dps:
+      - id: 27
+        type: string
+        name: switch
+        mapping:
+          - dps_val: online
+            value: true
+          - dps_val: offline
+            value: false
   - entity: binary_sensor
     class: connectivity
+    deprecated: switch_real_time_updates  # 2026-06-29
     category: diagnostic
     dps:
       - id: 27
@@ -337,3 +346,12 @@ entities:
         range:
           min: 0
           max: 12
+  - entity: text
+    name: Mode set
+    category: config
+    hidden: true
+    dps:
+      - id: 33
+        type: base64
+        optional: true
+        name: value

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

@@ -55,9 +55,22 @@ entities:
         mapping:
           - scale: 100
 
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 35
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 35
         type: string

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

@@ -173,9 +173,22 @@ entities:
         optional: true
         mapping:
           - scale: 100
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 27
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 27
         type: string

+ 21 - 0
custom_components/tuya_local/devices/smartplugv2_energyv2.yaml

@@ -204,11 +204,32 @@ entities:
         mapping:
           - dps_val: online
             value: true
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 66
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
+      - id: 66
+        type: string
+        optional: true
+        name: available
+        mapping:
+          - dps_val: null
+            value: false
+          - value: true
   - entity: binary_sensor
     name: Online
     class: connectivity
     hidden: unavailable
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 66
         type: string

+ 1 - 0
custom_components/tuya_local/devices/tongou_toqsyswt_breaker.yaml

@@ -206,6 +206,7 @@ entities:
             value: trip_breaker
   - entity: binary_sensor
     class: connectivity
+    deprecated: button_live_updates  # 2026-06-29
     category: diagnostic
     dps:
       - id: 109

+ 13 - 0
custom_components/tuya_local/devices/tongou_towsmr1-20_rcbo_breaker.yaml

@@ -170,9 +170,22 @@ entities:
             value: alarm
           - dps_val: Trip
             value: trip_breaker
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 109
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 109
         type: string

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

@@ -188,9 +188,22 @@ entities:
         unit: kWh
         mapping:
           - scale: 100
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 27
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 27
         type: string

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

@@ -94,9 +94,22 @@ entities:
       - id: 18
         type: boolean
         name: switch
+  - entity: switch
+    name: Real time updates
+    category: config
+    dps:
+      - id: 27
+        type: string
+        name: switch
+        mapping:
+          - dps_val: online
+            value: true
+          - dps_val: offline
+            value: false
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: switch_real_time_updates  # 2026-06-29
     dps:
       - id: 27
         type: string

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

@@ -105,9 +105,22 @@ entities:
         class: measurement
         mapping:
           - scale: 100
+  - entity: button
+    name: Refresh
+    icon: "mdi:sync"
+    category: config
+    dps:
+      - id: 35
+        type: string
+        optional: true
+        name: button
+        mapping:
+          - dps_val: online
+            value: true
   - entity: binary_sensor
     class: connectivity
     category: diagnostic
+    deprecated: button_refresh  # 2026-06-29
     dps:
       - id: 35
         type: string