Bladeren bron

fix(inkbird_ibs_m1s): binary constraints are scaled

Due to requirements to use post masking values in binary conditions
(used by owon_pc341_energymeter), the resolved value of hex and base64
dps are used in conditions instead of the raw values.

For the special treatment of FFFF as "unavailable" in this config's
packed binary sensors, the integer values need to be scaled since
it is using the `sensor` dp for the condition to correctly match.

Comment on PR #6082
Jason Rumney 6 uur geleden
bovenliggende
commit
213b8f6047

+ 3 - 1
custom_components/tuya_local/devices/README.md

@@ -496,10 +496,12 @@ can be used to specify the element that `conditions` applies to. `constraint` ca
 
 ### `conditions`
 
-*Optional, usually paired with `constraint.`*
+*Optional, usually paired with `constraint`.*
 
 Conditions defines a list of rules that are applied based on the `constraint` attribute. The contents are the same as Mapping Rules, but `dps_val` applies to the attribute specified by `constraint`, and also can be a list of values to match as well rather than a single value. All others act on the current attribute as they would in the mapping. Although conditions are specified within a mapping, they can also contain a `mapping` of their own to override that mapping. These nested mappings are limited to simple `dps_val` to `value` substitutions, as more complex rules would quickly become too complex to manage.
 
+Note that when dealing with `hex` and `base64` constraints, the resolved HA value is compared with the `dps_val` in the condition, as it is usually desirable to apply masks etc on binary packed values. For other types, the raw dps value received from the device is compared.
+
 When setting a dp which has conditions attached, the behaviour is slightly different depending on whether the constraint dp is readonly or not.
 
 For non-readonly constraints that specify a single dps_val, the constraint dp will be set along with the target dp so that the first condition with a value matching the target value is met.

+ 6 - 6
custom_components/tuya_local/devices/inkbird_ibs_m1s.yaml

@@ -62,7 +62,7 @@ entities:
           - value: true
             constraint: sensor
             conditions:
-              - dps_val: 65535
+              - dps_val: 6553.5
                 value: false
   - entity: sensor
     name: Battery 1
@@ -139,7 +139,7 @@ entities:
           - value: true
             constraint: sensor
             conditions:
-              - dps_val: 65535
+              - dps_val: 6553.5
                 value: false
   - entity: sensor
     name: Battery 2
@@ -216,7 +216,7 @@ entities:
           - value: true
             constraint: sensor
             conditions:
-              - dps_val: 65535
+              - dps_val: 6553.5
                 value: false
   - entity: sensor
     name: Battery 3
@@ -295,7 +295,7 @@ entities:
           - value: true
             constraint: sensor
             conditions:
-              - dps_val: 65535
+              - dps_val: 6553.5
                 value: false
   - entity: sensor
     name: Battery 4
@@ -377,7 +377,7 @@ entities:
           - value: true
             constraint: sensor
             conditions:
-              - dps_val: 65535
+              - dps_val: 6553.5
                 value: false
   - entity: sensor
     name: Battery 5
@@ -461,7 +461,7 @@ entities:
           - value: true
             constraint: sensor
             conditions:
-              - dps_val: 65535
+              - dps_val: 6553.5
                 value: false
   - entity: sensor
     name: Battery 6