HomeAssistant-API


NameHomeAssistant-API JSON
Version 5.0.0 PyPI version JSON
download
home_pageNone
SummaryPython Wrapper for Homeassistant's REST API
upload_time2025-01-22 02:11:53
maintainerNone
docs_urlNone
authorGrandMoff100
requires_python<4.0,>=3.9
licenseGPL-3.0-or-later
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HomeassistantAPI

[![Code Coverage](https://img.shields.io/codecov/c/github/GrandMoff100/HomeAssistantAPI/dev?style=for-the-badge&token=SJFC3HX5R1)](https://codecov.io/gh/GrandMoff100/HomeAssistantAPI)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/HomeAssistant-API?style=for-the-badge)](https://pypistats.org/packages/homeassistant-api)
![GitHub commits since latest release (by date including pre-releases)](https://img.shields.io/github/commits-since/GrandMoff100/HomeassistantAPI/latest/dev?include_prereleases&style=for-the-badge)
[![Read the Docs (version)](https://img.shields.io/readthedocs/homeassistantapi?style=for-the-badge)](https://homeassistantapi.readthedocs.io/en/latest/?badge=latest)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/GrandMoff100/HomeassistantAPI?style=for-the-badge)](https://github.com/GrandMoff100/HomeassistantAPI/releases)

<a href="https://home-assistant.io">
    <img src="https://github.com/GrandMoff100/HomeAssistantAPI/blob/7edb4e6298d37bda19c08b807613c6d351788491/docs/images/homeassistant-logo.png?raw=true" width="80%">
</a>

## Python wrapper for Homeassistant's [Websocket API](https://developers.home-assistant.io/docs/api/websocket/) and [REST API](https://developers.home-assistant.io/docs/api/rest/)

> Note: As of [this comment](https://github.com/home-assistant/architecture/discussions/1074#discussioncomment-9196867) the REST API is not getting any new features or endpoints.
> However, it is not going to be deprecated according to [this comment](https://github.com/home-assistant/developers.home-assistant/pull/2150#pullrequestreview-2017433583)
> But it is recommended to use the Websocket API for new integrations.

### REST API Examples

```py
from homeassistant_api import Client

with Client(
    '<API Server URL>', # i.e. 'http://homeassistant.local:8123/api/'
    '<Your Long Lived Access-Token>'
) as client:
    light = client.trigger_service('light', 'turn_on', entity_id="light.living_room")
```

All the methods also support async/await!
Just prefix the method with `async_` and pass the `use_async=True` argument to the `Client` constructor.
Then you can use the methods as coroutines
(i.e. `await light.async_turn_on(...)`).

```py
import asyncio
from homeassistant_api import Client

async def main():
    with Client(
        '<REST API Server URL>', # i.e. 'http://homeassistant.local:8123/api/'
        '<Your Long Lived Access-Token>',
        use_async=True
    ) as client:
    light = await client.async_trigger_service('light', 'turn_on', entity_id="light.living_room")

asyncio.run(main())
```

### Websocket API Example

```py
from homeassistant_api import WebsocketClient

with WebsocketClient(
    '<WS API Server URL>', # i.e. 'ws://homeassistant.local:8123/api/websocket'
    '<Your Long Lived Access-Token>'
) as ws_client:
    light = ws_client.trigger_service('light', 'turn_on', entity_id="light.living_room")
```

> Note: The Websocket API is not yet supported in async/await mode.

## Documentation

All documentation, API reference, contribution guidelines and pretty much everything else
you'd want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)

If there is something missing, open an issue and let us know! Thanks!

Go make some cool stuff! Maybe come back and tell us about it in a
[discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)?
We'd love to hear about how you use our library!!

## License

This project is under the GNU GPLv3 license, as defined by the Free Software Foundation.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "HomeAssistant-API",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "GrandMoff100",
    "author_email": "minecraftcrusher100@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/88/e9/576ab6d080e4d29a38b3ce6b5fc8cf64801a1bc8d62a19e946fcb9a702c1/homeassistant_api-5.0.0.tar.gz",
    "platform": null,
    "description": "# HomeassistantAPI\n\n[![Code Coverage](https://img.shields.io/codecov/c/github/GrandMoff100/HomeAssistantAPI/dev?style=for-the-badge&token=SJFC3HX5R1)](https://codecov.io/gh/GrandMoff100/HomeAssistantAPI)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/HomeAssistant-API?style=for-the-badge)](https://pypistats.org/packages/homeassistant-api)\n![GitHub commits since latest release (by date including pre-releases)](https://img.shields.io/github/commits-since/GrandMoff100/HomeassistantAPI/latest/dev?include_prereleases&style=for-the-badge)\n[![Read the Docs (version)](https://img.shields.io/readthedocs/homeassistantapi?style=for-the-badge)](https://homeassistantapi.readthedocs.io/en/latest/?badge=latest)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/GrandMoff100/HomeassistantAPI?style=for-the-badge)](https://github.com/GrandMoff100/HomeassistantAPI/releases)\n\n<a href=\"https://home-assistant.io\">\n    <img src=\"https://github.com/GrandMoff100/HomeAssistantAPI/blob/7edb4e6298d37bda19c08b807613c6d351788491/docs/images/homeassistant-logo.png?raw=true\" width=\"80%\">\n</a>\n\n## Python wrapper for Homeassistant's [Websocket API](https://developers.home-assistant.io/docs/api/websocket/) and [REST API](https://developers.home-assistant.io/docs/api/rest/)\n\n> Note: As of [this comment](https://github.com/home-assistant/architecture/discussions/1074#discussioncomment-9196867) the REST API is not getting any new features or endpoints.\n> However, it is not going to be deprecated according to [this comment](https://github.com/home-assistant/developers.home-assistant/pull/2150#pullrequestreview-2017433583)\n> But it is recommended to use the Websocket API for new integrations.\n\n### REST API Examples\n\n```py\nfrom homeassistant_api import Client\n\nwith Client(\n    '<API Server URL>', # i.e. 'http://homeassistant.local:8123/api/'\n    '<Your Long Lived Access-Token>'\n) as client:\n    light = client.trigger_service('light', 'turn_on', entity_id=\"light.living_room\")\n```\n\nAll the methods also support async/await!\nJust prefix the method with `async_` and pass the `use_async=True` argument to the `Client` constructor.\nThen you can use the methods as coroutines\n(i.e. `await light.async_turn_on(...)`).\n\n```py\nimport asyncio\nfrom homeassistant_api import Client\n\nasync def main():\n    with Client(\n        '<REST API Server URL>', # i.e. 'http://homeassistant.local:8123/api/'\n        '<Your Long Lived Access-Token>',\n        use_async=True\n    ) as client:\n    light = await client.async_trigger_service('light', 'turn_on', entity_id=\"light.living_room\")\n\nasyncio.run(main())\n```\n\n### Websocket API Example\n\n```py\nfrom homeassistant_api import WebsocketClient\n\nwith WebsocketClient(\n    '<WS API Server URL>', # i.e. 'ws://homeassistant.local:8123/api/websocket'\n    '<Your Long Lived Access-Token>'\n) as ws_client:\n    light = ws_client.trigger_service('light', 'turn_on', entity_id=\"light.living_room\")\n```\n\n> Note: The Websocket API is not yet supported in async/await mode.\n\n## Documentation\n\nAll documentation, API reference, contribution guidelines and pretty much everything else\nyou'd want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)\n\nIf there is something missing, open an issue and let us know! Thanks!\n\nGo make some cool stuff! Maybe come back and tell us about it in a\n[discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)?\nWe'd love to hear about how you use our library!!\n\n## License\n\nThis project is under the GNU GPLv3 license, as defined by the Free Software Foundation.\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "Python Wrapper for Homeassistant's REST API",
    "version": "5.0.0",
    "project_urls": {
        "Documentation": "https://homeassistantapi.readthedocs.io",
        "Homepage": "https://github.com/GrandMoff100/HomeAssistantAPI",
        "Repository": "https://github.com/GrandMoff100/HomeAssistantAPI"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1cd90ff4b551ca41f082313bcab6b0ba44340247eab5dc42f2024d73de9e22ba",
                "md5": "8f34842e86227bc442cee4f650dc7979",
                "sha256": "d5bde1f1a8da19ca7450208cd171be74f248481f83fd7a9326b18b41e0945466"
            },
            "downloads": -1,
            "filename": "homeassistant_api-5.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f34842e86227bc442cee4f650dc7979",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 41857,
            "upload_time": "2025-01-22T02:11:51",
            "upload_time_iso_8601": "2025-01-22T02:11:51.911126Z",
            "url": "https://files.pythonhosted.org/packages/1c/d9/0ff4b551ca41f082313bcab6b0ba44340247eab5dc42f2024d73de9e22ba/homeassistant_api-5.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "88e9576ab6d080e4d29a38b3ce6b5fc8cf64801a1bc8d62a19e946fcb9a702c1",
                "md5": "faba8153c04414894312dda506d098ec",
                "sha256": "50d293b60227ad526d8c76f55959546dc6e18c13ad4d7d347879a6e78c30d2b6"
            },
            "downloads": -1,
            "filename": "homeassistant_api-5.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "faba8153c04414894312dda506d098ec",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 31695,
            "upload_time": "2025-01-22T02:11:53",
            "upload_time_iso_8601": "2025-01-22T02:11:53.988959Z",
            "url": "https://files.pythonhosted.org/packages/88/e9/576ab6d080e4d29a38b3ce6b5fc8cf64801a1bc8d62a19e946fcb9a702c1/homeassistant_api-5.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-22 02:11:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "GrandMoff100",
    "github_project": "HomeAssistantAPI",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "homeassistant-api"
}
        
Elapsed time: 1.46029s