Skip to content

Conversation

@KavanPrice
Copy link
Contributor

Overview

This adds a Python version of the JavaScript edge driver library to allow easy creation of edge drivers in Python. Python is often used by end users to interact with devices, so is a useful language for people to write their own drivers in as we move more towards a BYOD model.

The source is written as close to the original JS as possible with the addition of type hints from typing.

Building

This project was written using Poetry as a build system but can be used with any build system.

Testing

Simple unit tests have been implemented for this project. They require pytest to run. You can run these tests using pytest tests/.

@KavanPrice KavanPrice self-assigned this Jul 1, 2025
@KavanPrice KavanPrice marked this pull request as ready for review October 30, 2025 17:31
@KavanPrice
Copy link
Contributor Author

I've now made this such that drivers are intended to be run inside asyncio.run(). This simplifies greatly what I was trying to do with the internal async handling but we're now imposing restrictions on the library caller.

Copy link
Contributor

@amrc-benmorrow amrc-benmorrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there, I think. Has this had any real-world-ish testing against an actual Edge Agent?

edge_password: str,
reconnect_delay: int = 500,
serial: bool = False,
):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can handle these superclass arguments more cleanly like this:

def __init__(self, serial: bool = False, **opts):
    super().__init__(**opts)
    self.serial_mode = serial

This way if the arguments to Driver change the subclasses don't need changing.

raise ValueError(f"Invalid MQTT URL: Hostname not found.")

if not parsed.port:
raise ValueError(f"Invalid MQTT URL: Port not found.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to default the ports correctly here. The standard ACS deployment passes mqtt://localhost and expects the driver to understand port 1883. This is an irritating deficiency in urllib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants