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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user