pyElectra


NamepyElectra JSON
Version 1.2.3 PyPI version JSON
download
home_pageNone
SummaryElectra Smart Python Integration.
upload_time2024-06-10 10:48:34
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords home automation electra smart electra smart air condition
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyElectra

![PyPI](https://img.shields.io/pypi/v/pyelectra?label=pypi%20package)
![PyPI - Downloads](https://img.shields.io/pypi/dm/pyelectra)

Python library to control Electra Smart Air Condtioiner devices


Usage:

```python
import asyncio

import aiohttp

from electrasmart import *


async def main():
    session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False), timeout=aiohttp.ClientTimeout(total=10))
    api = ElectraAPI(session)

    # User phone number
    phone_number = "0521234567"
    # Generate token
    imei = generate_imei()
    try:
        resp = await api.generate_new_token(phone_number=phone_number, imei=imei)
    except ElectraApiError as e:
        # handle error
        pass

    otp = input("Enter the OTP you recieved via SMS")
    # more error handling
    if resp[electra.ATTR_STATUS] == electra.STATUS_SUCCESS:
        if resp[electra.ATTR_DATA][electra.ATTR_RES] != electra.STATUS_SUCCESS:
            # Wrong phone number or unregistered user
            sys.exit(1)
     
        resp = await api.validate_one_time_password(otp=otp, imei=imei, phone_number=phone_number)
        if resp[electra.ATTR_DATA][electra.ATTR_RES] == electra.STATUS_SUCCESS:
            token = resp[electra.ATTR_DATA][electra.ATTR_TOKEN]
        else:
            # wrong OTP
            sys.exit(1)
    
    ac_devices = api.get_devices()
    for ac in ac_devices:
        assert(ac, ElectraAirConditioner)
        if ac.name == "Saloon AC":
            ac.turn_on()
            ac.set_mode(OPER_MODE_COOL)
            ac.set_temperature(17)
            ac.set_fan_speed(OPER_FAN_SPEED_HIGH)
            ac.set_vertical_swing(OPER_ON)
            api.set_state(ac)  # This will send the conf to the AC


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyElectra",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "home, automation, Electra, smart, Electra Smart, Air Condition",
    "author": null,
    "author_email": "Jafar Atili <at.jafar@outlook.com>",
    "download_url": null,
    "platform": null,
    "description": "# pyElectra\n\n![PyPI](https://img.shields.io/pypi/v/pyelectra?label=pypi%20package)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pyelectra)\n\nPython library to control Electra Smart Air Condtioiner devices\n\n\nUsage:\n\n```python\nimport asyncio\n\nimport aiohttp\n\nfrom electrasmart import *\n\n\nasync def main():\n    session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False), timeout=aiohttp.ClientTimeout(total=10))\n    api = ElectraAPI(session)\n\n    # User phone number\n    phone_number = \"0521234567\"\n    # Generate token\n    imei = generate_imei()\n    try:\n        resp = await api.generate_new_token(phone_number=phone_number, imei=imei)\n    except ElectraApiError as e:\n        # handle error\n        pass\n\n    otp = input(\"Enter the OTP you recieved via SMS\")\n    # more error handling\n    if resp[electra.ATTR_STATUS] == electra.STATUS_SUCCESS:\n        if resp[electra.ATTR_DATA][electra.ATTR_RES] != electra.STATUS_SUCCESS:\n            # Wrong phone number or unregistered user\n            sys.exit(1)\n     \n        resp = await api.validate_one_time_password(otp=otp, imei=imei, phone_number=phone_number)\n        if resp[electra.ATTR_DATA][electra.ATTR_RES] == electra.STATUS_SUCCESS:\n            token = resp[electra.ATTR_DATA][electra.ATTR_TOKEN]\n        else:\n            # wrong OTP\n            sys.exit(1)\n    \n    ac_devices = api.get_devices()\n    for ac in ac_devices:\n        assert(ac, ElectraAirConditioner)\n        if ac.name == \"Saloon AC\":\n            ac.turn_on()\n            ac.set_mode(OPER_MODE_COOL)\n            ac.set_temperature(17)\n            ac.set_fan_speed(OPER_FAN_SPEED_HIGH)\n            ac.set_vertical_swing(OPER_ON)\n            api.set_state(ac)  # This will send the conf to the AC\n\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(main())\n\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Electra Smart Python Integration.",
    "version": "1.2.3",
    "project_urls": {
        "homepage": "https://pypi.org/project/pyelectra/",
        "repository": "https://github.com/jafar-atili/pyelectra/"
    },
    "split_keywords": [
        "home",
        " automation",
        " electra",
        " smart",
        " electra smart",
        " air condition"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52fdefad5b708419dda738651f3e825ed4c2ac7df10ec041085d641fa86e0c59",
                "md5": "98ad01d4c1f567e14e52fe065d4d3568",
                "sha256": "d3393b51dc7cf78a7d649a5c8042b15cba34fdd4e098189b57cff33b2f1d9611"
            },
            "downloads": -1,
            "filename": "pyElectra-1.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "98ad01d4c1f567e14e52fe065d4d3568",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6970,
            "upload_time": "2024-06-10T10:48:34",
            "upload_time_iso_8601": "2024-06-10T10:48:34.329427Z",
            "url": "https://files.pythonhosted.org/packages/52/fd/efad5b708419dda738651f3e825ed4c2ac7df10ec041085d641fa86e0c59/pyElectra-1.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-10 10:48:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jafar-atili",
    "github_project": "pyelectra",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyelectra"
}
        
Elapsed time: 0.25967s