SengledWifiPy
Python package for controlling Sengled Wifi devices.
NOTE: This has no relation with Sengled. There's no official API.
Features:
- Simulates the behavior of the Android App.
- Create a websocket connection to the MQTT broker to receive updates (Cloud Push).
- Alternative method to publish an update without creating a websocket connection.
Documentation
TL;DR The package is based on 3 classes:
SengledWifiLogin- Takes care of the login (requires credentials), reduces the API calls to a minimum by saving a session cookie locally.SengledWifiMqtt- Requires a login (SengledWifiLogin), creates the connection to the MQTT server, subscribe to topics and publish updates. Is a wrapper for paho-mqtt.SengledWifiApi- Uses the other two classes to get/set devices state
Usage example
Simple example that will subscribe to all the topics related to the devices in the Sengled account. SengledWifiMqtt can also receive callbacks for new messages (will be executed when an update is received).
import logging
import asyncio
from sengledwifipy import SengledLogin, SengledWifiAPI, SengledWifiMQTT
#set this for testing only
logging.basicConfig(level=logging.DEBUG)
def testing():
async def testmqtt():
login = SengledLogin(email = "email@domain.com",password = "verysecure")
await login.login()
devices = await SengledWifiAPI.get_devices(login)
MqttClient = SengledWifiMQTT(login)
await MqttClient.async_connect(devices)
while True:
await asyncio.sleep(60)
return asyncio.run(testmqtt())
testing()
This is a way to update the device state:
SengledWifiAPI.set_device_state(MqttClient,"deviceId",power_on=True, brightness=100)
Contributing
- Check for open features/bugs.
- Fork the repository.
- (Recommended) Use the latest version of Python supported >= 3.12.
- (Recommended) Install poetry (recommended installation method: pipx):
pipx install poetry
- Install the development environment:
poetry install --with devpre-commit install
- Code your new feature or bug fix on a new branch.
- Make sure to update the docstring as required.
- Submit a pull request!
Credits
Inspired by:
- alexapy (design ideas)
- ha-sengledapi
Metadata
Release files for SengledWifiPy 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sengledwifipy-0.0.9.tar.gz | 17.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sengledwifipy-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.8 kB
Release files / sengledwifipy-0.0.9.tar.gz
| Download URL | sengledwifipy-0.0.9.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0487815e002887c8f55f10e9ced1b363e8b7094e9a5cf3f800ff33ce062fb9e4
|
|
BLAKE2b-256 checksum How to use checksums |
cf8714ccf3e3035447fad3a29f841cbe765c02b2a3d223f834596ad08b7ad5f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1018-azure
|
Release files / sengledwifipy-0.0.9-py3-none-any.whl
| Download URL | sengledwifipy-0.0.9-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0158bfd7cabdcd4903aee6a34eeb41bf1921cfe009d7f0405735bebe854fef4
|
|
BLAKE2b-256 checksum How to use checksums |
1c94b6b6f36653d26250840c9359bee2ec977a5f5ef19d768216981ef12c2053
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1018-azure
|