1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Remove JSON parsing from tuya diagnostics (#156451)

This commit is contained in:
epenet
2025-11-12 19:32:40 +01:00
committed by GitHub
parent 35a4b685b3
commit 006fc5b10a
2 changed files with 7 additions and 23 deletions
+3 -15
View File
@@ -2,9 +2,7 @@
from __future__ import annotations
from contextlib import suppress
import json
from typing import Any, cast
from typing import Any
from tuya_sharing import CustomerDevice
@@ -101,30 +99,20 @@ def _async_device_as_dict(
data["status"][dpcode] = REDACTED
continue
with suppress(ValueError, TypeError):
value = json.loads(value)
data["status"][dpcode] = value
# Gather Tuya functions
for function in device.function.values():
value = function.values
with suppress(ValueError, TypeError, AttributeError):
value = json.loads(cast(str, function.values))
data["function"][function.code] = {
"type": function.type,
"value": value,
"value": function.values,
}
# Gather Tuya status ranges
for status_range in device.status_range.values():
value = status_range.values
with suppress(ValueError, TypeError, AttributeError):
value = json.loads(status_range.values)
data["status_range"][status_range.code] = {
"type": status_range.type,
"value": value,
"value": status_range.values,
}
# Gather information how this Tuya device is represented in Home Assistant
@@ -10,8 +10,7 @@
'function': dict({
'null': dict({
'type': 'Boolean',
'value': dict({
}),
'value': '{}',
}),
}),
'home_assistant': dict({
@@ -77,8 +76,7 @@
'status_range': dict({
'null': dict({
'type': 'Boolean',
'value': dict({
}),
'value': '{}',
}),
}),
'sub': False,
@@ -98,8 +96,7 @@
'function': dict({
'null': dict({
'type': 'Boolean',
'value': dict({
}),
'value': '{}',
}),
}),
'home_assistant': dict({
@@ -164,8 +161,7 @@
'status_range': dict({
'null': dict({
'type': 'Boolean',
'value': dict({
}),
'value': '{}',
}),
}),
'sub': False,