Skip to main content

YeelightPool

A package to integrate Yeelight Bulbs with MQTT Brokers. This package intends to integrate Bulbs into Lamps within the network and manage it as a pool of devices that can be accessible through the MQTT Broker.

Introduction

The package is intended to establish an MQTT interface with the Yeelight device. The equipment attributes will be readable in the MQTT Broker through a topic in the form /<level0>/<level1>/attribute. The equipment will be located within a hierarchy of levels in the MQTT Broker, being the device located into 2 levels, typically location and equipment, and within the equipment all the attributes of this device.

The special attribute /<level0>/<level1>/<command> is serving as a special attribute to send commands to the device. The commands are those available from the library yeelight and the function behind this package simply wraps a json command with its arguments. This json content is simply passed onto the package yeelight and executes the command onto the equipment. The json document including the execution of a command is in the form:

{
	"action": "name of the method",
	"args": "{
				"arg1": "value 1",
				"arg2": "value 2",
				"argN": "value N"
			}
}

The name of the the method is one of the yeelight methods.

Workflow diagram

The device and the MQTT have the following communication diagram

sequenceDiagram
Device ->> YeelightPool: Device Status
YeelightPool -->> MQTT Broker: Publish Topics
MQTT Broker ->> User Program: Status attributes 
User Program ->> MQTT Broker: { command, args }
MQTT Broker -->> YeelightPool: Subscribe Topics<br/>(command)
YeelightPool ->> Device: Function call<br/> Execution command
Note right of User Program: Async calls to execute<br/>commands on device.

Configuration file

The package gives the possibility to configure parameters through a configuration file. This file can be, as an example, like this:

[yeelight] logfile=yeelightpool.log lamps=[ ["192.168.0.101", "192.168.0.102"], ["192.168.0.103"] ] room=[ "Living Room", "Kids Room" ] device=[ "Ceiling Lamp", "Desk Lamp" ]

[broker] ip=127.0.0.1 port=1883

The configuration file will be splitted into two areas:

  • [yeelight]: this area defines the lamps as a serie of bulb's ip addresses. The room name for the lamps. And the device name of the lamp. It also gives the chance to log data to a logfile.
  • [broker]: this is the broker ip:port to connect to. This broker is to be setup apart from this package.

How to install

To install the library just execute:

pip install YeelightPool

Example

import sys import YeelightPool

def main(): # Configuration of the Shelly device config = YeelightPool.YeelightConfig(sys.argv[1]) params_yeelight = config.read(section="yeelight") params_broker = config.read(section="broker")

print(f"Yeelight Devices Pool Version {YeelightPool.version}") print(f"Creating Pool of Yeelight Devices . . . ", end="") pool = YeelightPool.YeelightPool(params_broker['ip'], int(params_broker['port'])) print(f"[ OK ]")

print(f"Running the pool") pool.start( eval(params_yeelight['lamps']), eval(params_yeelight['room']), eval(params_yeelight['device']) )

print(f"Finalizing Yeelight Pool . . . [ OK ]") > if name == "main": main()

Release Notes

0.1.1 - Initial release

Credits

Metadata

Release files for YeelightPool 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for YeelightPool 0.1.1
File Size Uploaded
yeelightpool-0.1.1.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for YeelightPool 0.1.1
File Interpreter ABI Platform
yeelightpool-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / yeelightpool-0.1.1.tar.gz

Download URL yeelightpool-0.1.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1b84286d2184eadb7b40c415e45a1c61c4b4e7b3fe9f34e01fe641c6d9084af5
BLAKE2b-256 checksum
How to use checksums
b3c5a80d447dc09502f9cadcfa9a7e3757cd0e2549e51e747f122555b4a1300a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.3

Release files / yeelightpool-0.1.1-py3-none-any.whl

Download URL yeelightpool-0.1.1-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
438462d10ed9208338373aff58222ac9ceb6efc00a8cfdcde08a5dd8ed646ae1
BLAKE2b-256 checksum
How to use checksums
3d2d1a22e98fa54adaaafe3ee376443d951d52ce96223050a2f7e64f3105826b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page