diff --git a/homeassistant/components/tuya/diagnostics.py b/homeassistant/components/tuya/diagnostics.py index b71a17f68a6..85fce1f9ba8 100644 --- a/homeassistant/components/tuya/diagnostics.py +++ b/homeassistant/components/tuya/diagnostics.py @@ -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 diff --git a/tests/components/tuya/snapshots/test_diagnostics.ambr b/tests/components/tuya/snapshots/test_diagnostics.ambr index 33248655d31..18e80a2eff1 100644 --- a/tests/components/tuya/snapshots/test_diagnostics.ambr +++ b/tests/components/tuya/snapshots/test_diagnostics.ambr @@ -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,