HomeAssistantAPI
Python Wrapper for Homeassistant's REST API
Install / Use
/learn @GrandMoff100/HomeAssistantAPIREADME
HomeassistantAPI
<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 and REST API
Note: As of this comment the REST API is not getting any new features or endpoints. However, it is not going to be deprecated according to this comment But it is recommended to use the Websocket API for new integrations.
REST API Examples
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(...)).
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
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
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? 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.
Related Skills
bluebubbles
351.2kUse when you need to send or manage iMessages via BlueBubbles (recommended iMessage integration). Calls go through the generic message tool with channel="bluebubbles".
gh-issues
351.2kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
healthcheck
351.2kHost security hardening and risk-tolerance configuration for OpenClaw deployments
node-connect
351.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
