Asynchronous Python API for mFi mPower devices
Project description
Asynchronous Python API for mFi mPower devices
Reference
The "REST" API for mFi mPower devices are briefly explained here.
Usage example
import asyncio
import aiohttp
from mfi_mpower import MPowerDevice
async def main():
data = {
"host": "name_or_ip",
"username": "ubnt",
"password": "ubnt",
"use_ssl": True,
"verify_ssl": False,
}
async with aiohttp.ClientSession() as session:
async with MPowerDevice(**data, session=session) as device:
# Print device info
print(device)
# Print all sensors and their data
sensors = await device.create_sensors()
for sensor in sensors:
print(sensor)
# Print all switches and their state
switches = await device.create_switches()
for switch in switches:
print(switch)
# Turn port 1 off and toggle it afterwards back on
switch1 = await device.create_switch(1)
await switch1.set(False)
await asyncio.sleep(5)
await switch1.toggle()
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mfi-mpower-1.0.0.tar.gz
(9.1 kB
view hashes)
Built Distribution
Close
Hashes for mfi_mpower-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dfd176e8fdd7c6658296c7b93cf548382d814aefeeb3c3ca896c2424ffbe305 |
|
MD5 | 0b7a7843f5030027cd32bc417caacf6b |
|
BLAKE2b-256 | ce1a8708d9ce7e242b3a62edda88000843612f72720807270b5fddddf9c67b7f |