Skip to main content

An asynchronous Python library to communicate with PG LAB Electronics devices over MQTT.

Project description

pypglab

About

An asynchronous Python library to communicate with PG LAB Electronics devices over MQTT.

This library was created for Home Assistant integrations of PG LAB Electronics.

Features

  • Discover devices
  • Controll relays (turn on/off)
  • Monitor relays status (on/off)
  • Controll shutters (open/close/pause)
  • Monitor shutters status (open/opening/closed/closing)
  • Receiving device internal sensor update

Devices supported

  • E-Board

Comming soon

  • E-Switch

Installation

pip install pypglab

Usage

A client interface in pypglab/mqtt.py is used for the comunication with MQTT broker. The interface exposes callback for: publish, subscribe and unsusbribe. Who is using pypglab library must manage the MQTT connection and define the MQTT client callback.

The following is a pseudo example that turn on all relays.

from pypglab.device import Device
from pypglab.mqtt import Client

async def setup_pglab_device(config:dict):
  async def mqtt_publish( topic: str, payload: str, qos: int | None = 0, retain: bool | None = False) -> None:
      print("TODO... call the client MQTT publish")

  pglab_mqtt_client = Client(mqtt_publish, None, None)
  pglab_device = Device()
  await pglab_device.config(pglab_mqtt_client, config)

  for relay in pglab_device.relays:
      await relay.turn_on() 

For working example and proper setup of the MQTT connection and callback, see the example.py and the unittest of pypglab python library.

Feedback

Please give us feedback on pglab.electronics@gmail.com

Founder

This plugin is created by PG Lab Electronics.

License

Code is released under [MIT license]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypglab-0.0.2.tar.gz (11.2 kB view hashes)

Uploaded Source

Built Distribution

pypglab-0.0.2-py3-none-any.whl (11.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page