Asynchronous Python API for mFi mPower devices
Notes
This package provides a direct asynchronous API for Ubiquiti mFi mPower devices based on AsyncSSH. The mFi product line which are is sadly EOL since 2015 and the latest available mFi firmware is version 2.1.11, which can be found here.
Please note that even with the latest available mFi firmware, Ubiquiti mFi mPower Devices use OpenSSL 1.0.0g (18 Jan 2012) and Dropbear SSH 0.51 (27 Mar 2008).
To extract information and control the devices via SSH, only the ssh-rsa host key algorithm in combination with the diffie-hellman-group1-sha1 key exchange is supported. The latter is available as legacy option. There is also a known bug in older Dropbear versions which truncates the list of offered key algorithms. The mFi mPower package therefore limits the offered key algorithms to ssh-rsa and the encryption algorithm to aes128-cbc. Known host checks will be disabled as this would require user interaction.
Basic example
import asyncio
from mfi_mpower.device import MPowerDevice
async def main():
data = {
"host": "name_or_ip",
"username": "ubnt",
"password": "ubnt",
}
async with MPowerDevice(**data) as device:
# Test LED control
await device.set_led(MPowerLED.YELLOW)
await asyncio.sleep(5)
await device.set_led(MPowerLED.LOCKED_OFF)
# Create switch for port 1
switch = await device.create_switch(1)
# Test lock control
await switch.lock()
await asyncio.sleep(5)
await switch.unlock()
# Test output control
await switch.turn_off()
await asyncio.sleep(5)
await switch.toggle()
asyncio.run(main())
Better example
import asyncio
from mfi_mpower.device import MPowerDevice
async def query(host: str) -> None:
"""Async query"""
data = {
"host": host,
"username": "ubnt",
"password": "ubnt",
}
async with MPowerDevice(**data) as device:
# Print device info
print(device)
# Print all switches and their state
switches = await device.create_switches()
for switch in switches:
print(switch)
# Print all sensors and their data
sensors = await device.create_sensors()
for sensor in sensors:
print(sensor)
async def main() -> None:
"""Async main"""
hosts = [
"host1", "host2", "host3",
"host4", "host5", "host6",
]
await asyncio.gather(*[query(host) for host in hosts])
asyncio.run(main())
Metadata
Release files for mfi-mpower 3.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mfi_mpower-3.2.2.tar.gz | 13.4 kB | Without provenance | Details for mfi_mpower-3.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mfi_mpower-3.2.2-py3-none-any.whl | Python 3 | none | any | Details for mfi_mpower-3.2.2-py3-none-any.whl |
Total release size: 27.2 kB
Release files / mfi_mpower-3.2.2.tar.gz
| Download URL | mfi_mpower-3.2.2.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5f6b5e7d4a518f402e78f50e446871b4602100963f5139973222842ac2a85c6
|
|
BLAKE2b-256 checksum How to use checksums |
734ccf1318446f5d04a3481bb0ccfc868924d8ca206545c65411196a4743025d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / mfi_mpower-3.2.2-py3-none-any.whl
| Download URL | mfi_mpower-3.2.2-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf658acbf5ed12c51cd5ba03cf4f4b68b073069303caac327d95795b770c5dc3
|
|
BLAKE2b-256 checksum How to use checksums |
8bb031743ecefb7288c7951e276d26f862fe53f94ef9d6539b007362cff242e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for mfi-mpower 3.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.