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

Covers: duplicate position as current_position for some devices.

Some cover devices let position be set via the position dp, but leave
it showing the last manually set position even when the cover has
moved subsequently.  For this reason, the cover was modified not to
trust position when determining if the cover is open or closed, since
reporting either of those incorrectly results in the corresponding
control being disabled in the UI when it shouldn't be.

However some devices do report the current position reliably using the
same position dp used to set position, and with the new code those
devices have regressed in functionality.  In order to get that
functionality back, we need to mirror the same dp as current_position
as well as position.

Issue #715, #794

As devices using simple_blind.yaml are more generic, they may be of
either of the above types, so a second config was made, allowing the
user to try both.
Jason Rumney 2 лет назад
Родитель
Сommit
8c918f6a82

+ 1 - 1
DEVICES.md

@@ -320,7 +320,7 @@ of device.
 ### Covers
 
 - Simple garage door
-- Simple blind controller
+- Simple blind controller (two variants - `simple_blinds` lets the position be set, but does not trust it to accurately reflect the current position always, `position_blinds` does trust the position to accurately reflect the current position)
 - Abalon BCM700D curtain motor (likely to work with other brands)
 - Avatto curtain and light switch
 - Avatto curtain switch

+ 8 - 0
custom_components/tuya_local/devices/benexmart_blind_motor.yaml

@@ -21,6 +21,14 @@ primary_entity:
         max: 100
       mapping:
         - invert: true
+    - id: 2
+      name: current_position
+      type: integer
+      range:
+        min: 0
+        max: 100
+      mapping:
+        - invert: true
 secondary_entities:
     - entity: switch
       category: config

+ 39 - 0
custom_components/tuya_local/devices/position_blinds.yaml

@@ -0,0 +1,39 @@
+name: Blind controller with set and read position
+primary_entity:
+  entity: cover
+  class: blind
+  dps:
+    - id: 1
+      name: control
+      type: string
+      mapping:
+        - dps_val: open
+          value: open
+        - dps_val: close
+          value: close
+        - dps_val: stop
+          value: stop
+    - id: 2
+      name: position
+      type: integer
+      range:
+        min: 0
+        max: 100
+      mapping:
+        - invert: true
+    - id: 2
+      name: current_position
+      type: integer
+      range:
+        min: 0
+        max: 100
+      mapping:
+        - invert: true
+    - id: 5
+      name: control_back_mode
+      type: boolean
+    - id: 7
+      name: work_state
+      type: string
+      # seems intended to match action, but doesn't change in observation
+

+ 1 - 1
custom_components/tuya_local/devices/simple_blinds.yaml

@@ -1,4 +1,4 @@
-name: Blind controller
+name: Blind controller with set position
 primary_entity:
   entity: cover
   class: blind

+ 0 - 4
custom_components/tuya_local/devices/wistar_roller_blind.yaml

@@ -21,8 +21,6 @@ primary_entity:
       range:
         min: 0
         max: 100
-      mapping:
-        - invert: true
     - id: 105
       type: boolean
       name: curtain_hand
@@ -80,8 +78,6 @@ primary_entity:
       range:
         min: 0
         max: 100
-      mapping:
-        - invert: true
 secondary_entities:
   - entity: select
     name: Border setting

+ 6 - 2
custom_components/tuya_local/devices/wistar_roller_blind_nopos.yaml

@@ -21,8 +21,12 @@ primary_entity:
       range:
         min: 0
         max: 100
-      mapping:
-        - invert: true
+    - id: 102
+      type: integer
+      name: current_position
+      range:
+        min: 0
+        max: 100
     - id: 105
       type: boolean
       name: curtain_hand