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 communication with MQTT broker. The interface exposes callback for: publish, subscribe and unsubscribe. 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, True)

  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.3.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

pypglab-0.0.3-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file pypglab-0.0.3.tar.gz.

File metadata

  • Download URL: pypglab-0.0.3.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for pypglab-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7cead3f8ed225ca70717418c115dbc485fe2f153b099e5d46bfd5ed6fc76f7c9
MD5 124b0ed7f47da5a560da7aab61f0bade
BLAKE2b-256 b9152b54f7c225521fcbed6045d381b4af9f45c3745fad883907d068e86a5128

See more details on using hashes here.

File details

Details for the file pypglab-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pypglab-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for pypglab-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 25f7db2b330fbbb0e91ea5a27341abd6b2f6da7aab4ab7d85d6aef374422c21d
MD5 e132ad2b12f7e695dbb5f55cbf71371f
BLAKE2b-256 73f67ee8d4cae5013eeebb359f1b77aa77a38cad3f9f5ddcd260ed8a5076a034

See more details on using hashes here.

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