From a7d591fb65ecb55a03eae7c071841f68504fab74 Mon Sep 17 00:00:00 2001 From: azerty9971 Date: Sun, 1 Sep 2024 21:08:47 +0200 Subject: [PATCH] Update base.py --- homeassistant/components/tuya/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/tuya/base.py b/homeassistant/components/tuya/base.py index 007df968a70c94..caa618cbe14780 100644 --- a/homeassistant/components/tuya/base.py +++ b/homeassistant/components/tuya/base.py @@ -122,6 +122,9 @@ def from_json(cls, data: str) -> Self: def from_raw(cls, data: str) -> Self: """Decode base64 string and return a ElectricityTypeData object.""" raw = base64.b64decode(data) + voltage = 0.0 + electriccurrent = 0.0 + power = 0.0 try: voltage = struct.unpack(">H", raw[0:2])[0] / 10.0 electriccurrent = struct.unpack(">L", b"\x00" + raw[2:5])[0] / 1000.0