-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
35 lines (29 loc) · 1.55 KB
/
example.py
File metadata and controls
35 lines (29 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
from mhoh411 import MHOH411
import asyncio
async def main():
# Search for some MHOH411 in your surroundings. Will return a list of compatible MAC addresses.
# Sometimes device is not reachable in sleep mode. Try to press the button to trigger a C02 reading.
out = await MHOH411.findMHOH411()
if len(out) > 0:
print(f"Found {len(out)} devices. Using {out[0]}. Doing something with it")
# Connect to it
async with MHOH411(out[0]) as m: # Or use a mac directly such as A4:C1:38:B7:12:BA
print(f"Readings: {await m.getReadings()}")
print(f"Battery: {await m.getBatteryLevel()}%")
print(f"Light status: {await m.getIndicatorLightSetting()}")
# await m.setIndicatorLightSetting(False)
# print(f"Light status: {await m.getIndicatorLightSetting()}")
print(f"Time settings: {await m.getTimeSettings()}")
# out = await m.setTimeSettings(datetime.datetime(2025, 6, 9, 12, 34, 00), -3, 24)
# await m.setTimeSettings(datetime.datetime.now(), -3, 24)
# print(f"Time settings: {await m.getTimeSettings()}")
print(f"Temp settings: {await m.getCelsiusFahrenheitSetting()}")
# await m.setCelsiusFahrenheitSetting("c")
# print(f"Temp settings: {await m.getCelsiusFahrenheitSetting()}")
print(f"Device Info: {await m.getDeviceInfo()}")
await m.experimentalRebot()
else:
print("No compatible devices found :P")
if __name__ == "__main__":
asyncio.run(main())