SengledWifiPy


NameSengledWifiPy JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/cpadil/sengledwifipy
SummaryPython package to control Sengled Wifi Devices Programmatically.
upload_time2024-05-08 22:20:48
maintainerNone
docs_urlNone
authorCesar
requires_python<4,>=3.11
licenseApache-2.0
keywords sengled wifi homeassistant
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SengledWifiPy

[![License][license-badge]][license]
[![Python version compatibility][python-badge]][python]
[![Version on PyPi][pypi-badge]][pypi]


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

[Code Documentation][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][paho-mqtt-link].
* `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

1. [Check for open features/bugs][issues].
2. [Fork the repository][fork].
3. (Recommended) Use the latest version of Python supported >= 3.12.
4. (Recommended) Install [poetry][poetry-link] (recommended installation method: [pipx][pipx-link]):
    - ```pipx install poetry```
5. Install the development environment:
    - ```poetry install --with dev```
    - ```pre-commit install```
6. Code your new feature or bug fix on a new branch.
7. Make sure to update the docstring as required.
8. Submit a pull request!

## Credits

Inspired by:
- [alexapy](https://gitlab.com/keatontaylor/alexapy) (design ideas)
- [ha-sengledapi](https://github.com/jfarmer08/ha-sengledapi)

[pypi]: https://pypi.org/project/sengledwifipy
[pypi-badge]: https://img.shields.io/pypi/v/sengledwifipy
[python]: https://pypi.org/project/sengledwifipy
[python-badge]: https://img.shields.io/pypi/pyversions/sengledwifipy
[license]: https://github.com/cpadil/sengledwifipy?tab=Apache-2.0-1-ov-file
[license-badge]: https://img.shields.io/badge/License-Apache%202.0-blue.svg
[issues]: https://github.com/cpadil/sengledwifipy/issues
[fork]: https://github.com/cpadil/sengledwifipy/fork
[documentation]: https://cpadil.github.io/sengledwifipy
[paho-mqtt-link]: https://pypi.org/project/paho-mqtt/
[poetry-link]: https://python-poetry.org/docs/#installation
[pipx-link]: https://pipx.pypa.io/stable/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cpadil/sengledwifipy",
    "name": "SengledWifiPy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.11",
    "maintainer_email": null,
    "keywords": "Sengled, Wifi, homeassistant",
    "author": "Cesar",
    "author_email": "gv4plolxe@mozmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cf/87/14ccf3e3035447fad3a29f841cbe765c02b2a3d223f834596ad08b7ad5f6/sengledwifipy-0.0.9.tar.gz",
    "platform": null,
    "description": "# SengledWifiPy\n\n[![License][license-badge]][license]\n[![Python version compatibility][python-badge]][python]\n[![Version on PyPi][pypi-badge]][pypi]\n\n\nPython package for controlling Sengled Wifi devices. \n\n`NOTE`: This has no relation with Sengled. There's no official API. \n\nFeatures:\n* Simulates the behavior of the Android App.\n* Create a websocket connection to the MQTT broker to receive updates (Cloud Push).\n* Alternative method to publish an update without creating a websocket connection.\n\n## Documentation\n\n[Code Documentation][documentation]\n\nTL;DR The package is based on 3 classes:\n* `SengledWifiLogin` - Takes care of the login (requires credentials), reduces the API calls to a minimum by saving a session cookie locally.\n* `SengledWifiMqtt` - Requires a login (SengledWifiLogin), creates the connection to the MQTT server, subscribe to topics and publish updates. Is a wrapper for [paho-mqtt][paho-mqtt-link].\n* `SengledWifiApi` - Uses the other two classes to get/set devices state\n\n\n## Usage example\n\nSimple 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).\n\n```\nimport logging\nimport asyncio\nfrom sengledwifipy import SengledLogin, SengledWifiAPI, SengledWifiMQTT\n\n#set this for testing only\nlogging.basicConfig(level=logging.DEBUG)\n\ndef testing():\n    async def testmqtt():\n        login = SengledLogin(email = \"email@domain.com\",password  = \"verysecure\")\n        await login.login()\n        devices = await SengledWifiAPI.get_devices(login)\n        MqttClient = SengledWifiMQTT(login)\n        await MqttClient.async_connect(devices)\n        while True:\n            await asyncio.sleep(60)\n    return asyncio.run(testmqtt())\n\ntesting()\n```\nThis is a way to update the device state:\n\n```\nSengledWifiAPI.set_device_state(MqttClient,\"deviceId\",power_on=True, brightness=100)\n```\n\n## Contributing\n\n1. [Check for open features/bugs][issues].\n2. [Fork the repository][fork].\n3. (Recommended) Use the latest version of Python supported >= 3.12.\n4. (Recommended) Install [poetry][poetry-link] (recommended installation method: [pipx][pipx-link]):\n    - ```pipx install poetry```\n5. Install the development environment:\n    - ```poetry install --with dev```\n    - ```pre-commit install```\n6. Code your new feature or bug fix on a new branch.\n7. Make sure to update the docstring as required.\n8. Submit a pull request!\n\n## Credits\n\nInspired by:\n- [alexapy](https://gitlab.com/keatontaylor/alexapy) (design ideas)\n- [ha-sengledapi](https://github.com/jfarmer08/ha-sengledapi)\n\n[pypi]: https://pypi.org/project/sengledwifipy\n[pypi-badge]: https://img.shields.io/pypi/v/sengledwifipy\n[python]: https://pypi.org/project/sengledwifipy\n[python-badge]: https://img.shields.io/pypi/pyversions/sengledwifipy\n[license]: https://github.com/cpadil/sengledwifipy?tab=Apache-2.0-1-ov-file\n[license-badge]: https://img.shields.io/badge/License-Apache%202.0-blue.svg\n[issues]: https://github.com/cpadil/sengledwifipy/issues\n[fork]: https://github.com/cpadil/sengledwifipy/fork\n[documentation]: https://cpadil.github.io/sengledwifipy\n[paho-mqtt-link]: https://pypi.org/project/paho-mqtt/\n[poetry-link]: https://python-poetry.org/docs/#installation\n[pipx-link]: https://pipx.pypa.io/stable/\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Python package to control Sengled Wifi Devices Programmatically.",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/cpadil/sengledwifipy",
        "Repository": "https://github.com/cpadil/sengledwifipy"
    },
    "split_keywords": [
        "sengled",
        " wifi",
        " homeassistant"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c94b6b6f36653d26250840c9359bee2ec977a5f5ef19d768216981ef12c2053",
                "md5": "f311b8bb1df6eb016a329420976a8dc2",
                "sha256": "e0158bfd7cabdcd4903aee6a34eeb41bf1921cfe009d7f0405735bebe854fef4"
            },
            "downloads": -1,
            "filename": "sengledwifipy-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f311b8bb1df6eb016a329420976a8dc2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.11",
            "size": 22597,
            "upload_time": "2024-05-08T22:20:47",
            "upload_time_iso_8601": "2024-05-08T22:20:47.468612Z",
            "url": "https://files.pythonhosted.org/packages/1c/94/b6b6f36653d26250840c9359bee2ec977a5f5ef19d768216981ef12c2053/sengledwifipy-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cf8714ccf3e3035447fad3a29f841cbe765c02b2a3d223f834596ad08b7ad5f6",
                "md5": "a414c58d44fcefa79f12f7a363cba299",
                "sha256": "0487815e002887c8f55f10e9ced1b363e8b7094e9a5cf3f800ff33ce062fb9e4"
            },
            "downloads": -1,
            "filename": "sengledwifipy-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "a414c58d44fcefa79f12f7a363cba299",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.11",
            "size": 17168,
            "upload_time": "2024-05-08T22:20:48",
            "upload_time_iso_8601": "2024-05-08T22:20:48.486547Z",
            "url": "https://files.pythonhosted.org/packages/cf/87/14ccf3e3035447fad3a29f841cbe765c02b2a3d223f834596ad08b7ad5f6/sengledwifipy-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-08 22:20:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cpadil",
    "github_project": "sengledwifipy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sengledwifipy"
}
        
Elapsed time: 0.24799s