diff --git a/homeassistant/components/tuya/base.py b/homeassistant/components/tuya/base.py index 007df968a70c9..caa618cbe1478 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