Skip to content

Commit

Permalink
Update base.py
Browse files Browse the repository at this point in the history
  • Loading branch information
azerty9971 committed Sep 1, 2024
1 parent c83cd1c commit a7d591f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions homeassistant/components/tuya/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7d591f

Please sign in to comment.