forked from Sabesto/pyflexit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·55 lines (44 loc) · 1.77 KB
/
Copy pathexample.py
File metadata and controls
executable file
·55 lines (44 loc) · 1.77 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""Example usage of the async pyflexit library."""
import asyncio
from pyflexit import Flexit
async def main() -> None:
"""Connect to a Flexit unit and print/change some values."""
unit = Flexit(21, serial_port="/dev/ttyUSB0")
await unit.connect()
try:
await unit.update()
print(f"unit.current_temperature {unit.current_temperature}")
print(f"unit.target_temperature {unit.target_temperature}")
print(f"unit.filter_hours {unit.filter_hours}")
print(f"unit.operation {unit.operation}")
print(f"unit.fan_speed {unit.fan_speed}")
print(f"unit.heat_recovery {unit.heat_recovery}")
print(f"unit.heating {unit.heating}")
print(f"unit.heater_enabled {unit.heater_enabled}")
print(f"unit.cooling {unit.cooling}")
print(f"unit.filter_alarm {unit.filter_alarm}")
print("Setting fan to 3")
await unit.set_fan_speed(3)
await asyncio.sleep(3)
await unit.update()
print(f"unit.fan_speed {unit.fan_speed}")
print("Setting fan to 2")
await unit.set_fan_speed(2)
await asyncio.sleep(3)
await unit.update()
print(f"unit.fan_speed {unit.fan_speed}")
print("Setting fan to 3 with set_raw_holding_register()")
await unit.set_raw_holding_register("SetAirSpeed", 3)
await asyncio.sleep(2)
await unit.update()
print(f"unit.fan_speed {unit.fan_speed}")
print("Setting fan to 2 with set_raw_holding_register()")
await unit.set_raw_holding_register("SetAirSpeed", 2)
await asyncio.sleep(2)
await unit.update()
print(f"unit.fan_speed {unit.fan_speed}")
finally:
unit.close()
if __name__ == "__main__":
asyncio.run(main())