Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/switchbotmeter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Device:
- date: Date of the current scan
- temp: Temperature as reported by the meter
- humidity: Humidity, percentage.
- battery: Battery, percentage.
- data: Complete dict with all the data minus the mac.

Arguments:
Expand Down Expand Up @@ -132,7 +133,8 @@ def __repr__(self: "Device") -> str:
return (
f'<{self.data["model"]} ({self.data["mode"]}) '
f'temp: {self.data["temp"]:.2f} '
f'humidity: {self.data["humidity"]}%> ({self.mac})'
f'humidity: {self.data["humidity"]}%'
f'battery: {self.data["battery"]}%> ({self.mac})'
)
return "Unknown device"

Expand All @@ -149,6 +151,7 @@ def set_service_data(self: Device, value: bytes) -> None:
self.data = {
"model": hexv[2:3].decode(),
"mode": hexv[3:4].hex(),
"battery": hexv[4] & 0b01111111,
"date": datetime.datetime.now(tz=datetime.timezone.utc),
"temp": int(hexv[6:7].hex(), 16) - 128 + (hexv[5] / 10),
"humidity": hexv[7],
Expand Down