Client API
flow_it_api.client
Main client for interacting with the FlowIt VMC machine.
Classes
FlowItVMCMachine
Primary API client for FlowIt VMC devices.
Source code in src/flow_it_api/client.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
Attributes
is_connected
property
Return True if the client has successfully fetched the state.
:return: Connection status boolean.
machine_state
property
Return the current machine data if available.
:return: MachineData or None.
state
property
Return the full current machine state including metadata.
:return: MachineStatusResponse or None.
websocket
property
Return the websocket client for real-time updates.
:return: FlowItWebSocket instance.
Methods:
__aenter__()
async
__aexit__(exc_type, exc_val, exc_tb)
async
__init__(host, password, username=DEFAULT_USERNAME, session=None)
Initialize the VMC machine client.
:param host: Base URL of the VMC machine. :param password: API password. :param username: API username. :param session: Optional existing HTTPX async client (session).
Source code in src/flow_it_api/client.py
close()
async
Close the underlying HTTP client (if owned) and stop websocket listener.
get_info()
async
Fetch basic machine information (Model, FW, HW versions).
Does not require authentication.
:return: MachineInfoResponse instance. :raises FlowItConnectionError: If connection fails.
Source code in src/flow_it_api/client.py
refresh_state(token)
async
Fetch the full machine state via REST API.
:param token: JWT token (provided by @authenticated). :return: MachineData instance. :raises FlowItConnectionError: If connection fails. :raises FlowItResponseError: If parsing fails.
Source code in src/flow_it_api/client.py
register_websocket_callback(callback)
Register a callback to be invoked when new data is received via the websocket.
:param callback: Async function taking MachineData as parameter. :return: A function that can be called to unregister the callback.
Source code in src/flow_it_api/client.py
send_command(token, speed, flow_in, flow_out)
async
Send a command to update speed and flow settings.
:param token: JWT token (provided by @authenticated). :param speed: Target fan speed level. :param flow_in: Enable/disable inflow. :param flow_out: Enable/disable outflow. :return: CommandResponse instance. :raises FlowItCommandError: If the command fails.
Source code in src/flow_it_api/client.py
Functions:
authenticated(func)
Decorator to ensure the client is authenticated before calling a method.
Automatically handles token refresh if a 401 Unauthorized is received.