Skip to content

Commit

Permalink
chore: update parser to match core pr
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanSchalton committed Mar 16, 2024
1 parent 3212864 commit 02eb7f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/tuya_openapi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ def from_raw(cls, data: str) -> Self:
if data[0] == "C":
temperature_unit = UnitOfTemperature.CELSIUS
decoded_bytes = base64.b64decode(data)
_temperature, _humidity = struct.Struct("<hH").unpack(
decoded_bytes[1:5]
# TODO: Identify what the skipped bytes are in the base station data
_temperature, _humidity, _, battery = struct.Struct("<hHIb").unpack(
decoded_bytes[1:11]
)
(temperature, humidity) = _temperature / 10.0, _humidity / 10.0
battery = int.from_bytes(decoded_bytes[9:10], "little")
except Exception as e:
LOGGER.error("InkbirdB64TypeData.from_raw: %s", e)
raise ValueError(f"Invalid data: {data}") from e
Expand Down

0 comments on commit 02eb7f2

Please sign in to comment.