Browse Source

Diagnostics: use append to append strings to list.

Because strings are lists of characters, the += operator appends
the characters individually to the list, so different dps than are
expected (if any) end up redacted.

Using append ensures that the strings stay intact.

Discussion #2547
Jason Rumney 1 year ago
parent
commit
abb0212e0d
1 changed files with 2 additions and 2 deletions
  1. 2 2
      custom_components/tuya_local/diagnostics.py

+ 2 - 2
custom_components/tuya_local/diagnostics.py

@@ -76,7 +76,7 @@ def redact_dps(device: TuyaLocalDevice, dps: dict[str, Any]) -> dict[str, Any]:
     for entity in device._children:
         for dp in entity._config.dps():
             if dp.sensitive:
-                sensitive += dp.id
+                sensitive.append(dp.id)
     return {k: (REDACTED if k in sensitive else v) for (k, v) in dps.items()}
 
 
@@ -90,7 +90,7 @@ def redact_entity(
         if entity._config.config_id == entity_id:
             for dp in entity._config.dps():
                 if dp.sensitive:
-                    sensitive += dp.name
+                    sensitive.append(dp.name)
     return {k: (REDACTED if k in sensitive else v) for (k, v) in state_dict.items()}