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

Uploaded Source

Built Distribution

pypglab-0.0.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypglab-0.0.1.tar.gz
  • Upload date:
  • Size: 11.2 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.1.tar.gz
Algorithm Hash digest
SHA256 e00098553914327bfc1b1da00d198c3d08cd903e30f5c18e24c35b6f91bdeb10
MD5 ee3533a5ae417a0337efa2dc1d8fa8d8
BLAKE2b-256 976e94333b9f4e716b0a62405a8319e1cd0cb243dfdda381493ce3efcd93996e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypglab-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1438c26e15f372b096af30dbb6d45aac35c813eb508db7325f7f4cebaca30ee5
MD5 940f1d166f24debdcc2e72a3483cbcc3
BLAKE2b-256 0ce9b56f50ec6fbf245d04d554ebfb21451be2c1c90f3ec782bf4ba437098312

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