flow-it-api 0.0.1.0b4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flow_it_api/__init__.py +13 -0
- flow_it_api/auth.py +98 -0
- flow_it_api/client.py +221 -0
- flow_it_api/const.py +48 -0
- flow_it_api/exceptions.py +21 -0
- flow_it_api/models.py +182 -0
- flow_it_api/websocket.py +92 -0
- flow_it_api-0.0.1.0b4.dist-info/METADATA +143 -0
- flow_it_api-0.0.1.0b4.dist-info/RECORD +11 -0
- flow_it_api-0.0.1.0b4.dist-info/WHEEL +4 -0
- flow_it_api-0.0.1.0b4.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flow-it-api
|
|
3
|
+
Version: 0.0.1.0b4
|
|
4
|
+
Summary: Python API library client for the FlowIt VMC machine
|
|
5
|
+
Author-email: Alberto Geniola <albertogeniola@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Requires-Dist: httpx>=0.27.0
|
|
10
|
+
Requires-Dist: pydantic>=2.0.0
|
|
11
|
+
Requires-Dist: websockets>=12.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: black>=24.0.0; extra == 'dev'
|
|
14
|
+
Requires-Dist: hatch-vcs; extra == 'dev'
|
|
15
|
+
Requires-Dist: isort>=5.13.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: mkdocs; extra == 'dev'
|
|
17
|
+
Requires-Dist: mkdocs-material; extra == 'dev'
|
|
18
|
+
Requires-Dist: mkdocstrings[python]; extra == 'dev'
|
|
19
|
+
Requires-Dist: mypy>=1.9.0; extra == 'dev'
|
|
20
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest-cov>=6.0.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# FLOW-IT-API
|
|
28
|
+
|
|
29
|
+
A Python API library client for FlowIt VMC (Ventilazione Meccanica Controllata) machines.
|
|
30
|
+
|
|
31
|
+
This library provides a simple, asynchronous interface to interact with FlowIt VMC devices over a local network, supporting both REST API for commands/status and WebSockets for real-time updates.
|
|
32
|
+
|
|
33
|
+
## Context
|
|
34
|
+
|
|
35
|
+
FlowIt VMC devices use two fans to control airflow (Inflow and Outflow) and are equipped with multiple sensors (Temperature, Humidity, Pressure, IAQ). While these devices connect to FlowIt cloud services, they also expose a local LAN API for direct control.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Prerequisites
|
|
40
|
+
- Python 3.11 or higher
|
|
41
|
+
|
|
42
|
+
### Setup Virtual Environment
|
|
43
|
+
```bash
|
|
44
|
+
python -m venv .venv
|
|
45
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
46
|
+
pip install -e .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For development:
|
|
50
|
+
```bash
|
|
51
|
+
pip install -e .[dev]
|
|
52
|
+
# Install pre-commit hooks
|
|
53
|
+
pre-commit install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
The library uses `httpx` for asynchronous HTTP requests and `websockets` for real-time updates.
|
|
59
|
+
|
|
60
|
+
### Basic Example
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import asyncio
|
|
64
|
+
import logging
|
|
65
|
+
from flow_it_api.client import FlowItVMCMachine
|
|
66
|
+
from flow_it_api.const import Speed
|
|
67
|
+
|
|
68
|
+
# Setup logging to see the library version and actions
|
|
69
|
+
logging.basicConfig(level=logging.INFO)
|
|
70
|
+
|
|
71
|
+
async def main():
|
|
72
|
+
host = "http://192.168.1.50"
|
|
73
|
+
# You can retrieve your API password from the device's menu using the on-board display
|
|
74
|
+
password = "your_api_password"
|
|
75
|
+
|
|
76
|
+
async with FlowItVMCMachine(host, password) as vmc:
|
|
77
|
+
# Get device info (Model, FW version, etc.)
|
|
78
|
+
info = await vmc.get_info()
|
|
79
|
+
print(f"Device: {info.model}, FW: {info.fw_ver}")
|
|
80
|
+
|
|
81
|
+
# Fetch initial state
|
|
82
|
+
state = await vmc.refresh_state()
|
|
83
|
+
print(f"Current Speed: {state.mode.speed}")
|
|
84
|
+
print(f"Temperature: {state.mode.temperatureIn_celsius}°C")
|
|
85
|
+
|
|
86
|
+
# Send a command
|
|
87
|
+
await vmc.send_command(Speed.LEVEL_3, flow_in=True, flow_out=True)
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
asyncio.run(main())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Real-time Updates (WebSocket)
|
|
94
|
+
|
|
95
|
+
The library can listen for real-time updates pushed by the device:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
async def on_data(data):
|
|
99
|
+
print(f"Update received! New IAQ: {data.mode.iaq}")
|
|
100
|
+
|
|
101
|
+
# Initialize machine and websocket
|
|
102
|
+
async with FlowItVMCMachine(host, password) as vmc:
|
|
103
|
+
vmc.websocket._on_data = on_data
|
|
104
|
+
vmc.websocket.start()
|
|
105
|
+
# Keep the loop running to receive events
|
|
106
|
+
await asyncio.sleep(60)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Library Architecture
|
|
110
|
+
|
|
111
|
+
### Key Components
|
|
112
|
+
|
|
113
|
+
- **`FlowItVMCMachine`**: The primary entry point. Manages authentication, connection state, and coordination between REST and WebSocket clients.
|
|
114
|
+
- **`Authenticator`**: Handles JWT token acquisition and automatic renewal.
|
|
115
|
+
- **`FlowItWebSocket`**: Manages the persistent WebSocket connection and reconnection logic.
|
|
116
|
+
- **`Models`**: Pydantic models providing type-safe access to machine data, including automatic Kelvin-to-Celsius conversions.
|
|
117
|
+
|
|
118
|
+
### Features
|
|
119
|
+
- **Asynchronous**: Built on `asyncio`.
|
|
120
|
+
- **Automatic Auth**: Handles login and token refreshing transparently via decorators.
|
|
121
|
+
- **Type Safety**: Full Pydantic v2 model support.
|
|
122
|
+
- **Temperature Conversion**: Access temperatures in both Kelvin (raw) and Celsius (processed).
|
|
123
|
+
- **Comprehensive Logging**: Detailed internal logging for debugging, including version tracking at load time.
|
|
124
|
+
- **Dynamic Versioning**: Versioning is automatically managed via Git tags (VCS).
|
|
125
|
+
|
|
126
|
+
## Development
|
|
127
|
+
|
|
128
|
+
The project structure:
|
|
129
|
+
- `src/flow_it_api/`: Library source code (src layout).
|
|
130
|
+
- `tests/`: Unit tests (using `pytest`).
|
|
131
|
+
- `specs/`: OpenAPI/YAML specifications for the device API.
|
|
132
|
+
- `example.py`: A comprehensive CLI test client.
|
|
133
|
+
|
|
134
|
+
### Quality Control
|
|
135
|
+
This project uses several tools to ensure code quality:
|
|
136
|
+
- **Linting & Formatting**: `black`, `isort`, and `mypy` for type checking.
|
|
137
|
+
- **Git Hooks**: `pre-commit` is used to run all checks locally before every commit.
|
|
138
|
+
- **CI/CD**: GitHub Actions runs the full test suite across multiple Python versions and handles automated releases to PyPI.
|
|
139
|
+
|
|
140
|
+
To run tests locally:
|
|
141
|
+
```bash
|
|
142
|
+
pytest --cov=src --cov-report=term-missing
|
|
143
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
flow_it_api/__init__.py,sha256=PeKhUR0BSOA4B5VVQ6O-RCdW8E4shpHHYsBCnzZgmag,369
|
|
2
|
+
flow_it_api/auth.py,sha256=U7kTajeD-alzcUmh5rYIGffi3JEbqD8PwabbsL5suOE,2965
|
|
3
|
+
flow_it_api/client.py,sha256=OYF5YfRpCua0aXl9hprlTMiu3VckTDnPZT0-1QWFEZ0,7475
|
|
4
|
+
flow_it_api/const.py,sha256=A1ywNBayJVjgzWdY-282ef8ARPpnTL8kObkFCvfyWIQ,769
|
|
5
|
+
flow_it_api/exceptions.py,sha256=LEgS4ambYIsxVbLfPMsXRMhrjhmYA82pV0qZ3fln5YQ,508
|
|
6
|
+
flow_it_api/models.py,sha256=7gC7n5PExwmrQoVVNqY2ZEoTyG-3puIwz9VtDAYB_fk,4422
|
|
7
|
+
flow_it_api/websocket.py,sha256=1StgbIhEs8azSe4Is2IpQ0OOe_mrPQ-rsHHeXpdqY2A,3188
|
|
8
|
+
flow_it_api-0.0.1.0b4.dist-info/METADATA,sha256=Jp2I4EwUoNPBQ13rZp7hFnWaaZS7Qmu70v9K5swuFoQ,4978
|
|
9
|
+
flow_it_api-0.0.1.0b4.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
10
|
+
flow_it_api-0.0.1.0b4.dist-info/licenses/LICENSE,sha256=-BeIbua7Ze0wmKeYex6XgWU9FccfhVic4NKvZjxm03M,34888
|
|
11
|
+
flow_it_api-0.0.1.0b4.dist-info/RECORD,,
|