MartinHjelmare / aiomysensors

Python asyncio package to connect to MySensors gateways
Apache License 2.0
1 stars 0 forks source link

aiomysensors

CI Status Test coverage percentage

Poetry black pre-commit

PyPI Version Supported Python versions License

Python asyncio package to connect to MySensors gateways.

Installation

Install this via pip (or your favourite package manager):

pip install aiomysensors

Example

"""Show a minimal example using aiomysensors."""
import asyncio

from aiomysensors import AIOMySensorsError, Gateway, SerialTransport

async def run_gateway() -> None:
    """Run a serial gateway."""
    port = "/dev/ttyACM0"
    baud = 115200
    transport = SerialTransport(port, baud)

    try:
        async with Gateway(transport) as gateway:
            async for message in gateway.listen():
                print("Message received:", message)
    except AIOMySensorsError as err:
        print("Error:", err)

if __name__ == "__main__":
    try:
        asyncio.run(run_gateway())
    except KeyboardInterrupt:
        pass

Command Line Interface

There's a CLI for testing purposes.

aiomysensors --debug serial-gateway -p /dev/ttyACM0

Credits

This package was created with Cookiecutter and the browniebroke/cookiecutter-pypackage project template.