Hubitat Maker API Client
Project description
hubitat_maker_api_client
This library facilitates access to Hubitat's Maker API. A key innovation is the HubitatCachingClient, which is capable of maintaining a cache of all your devices in a data store of your choice. This can allow you to query device state more efficiently than using the Maker API directly. HubitatCachingClient can be attached to a process that listens to Hubitat's /eventsocket to update the cached device states in real time.
Quick Start
Install
pip install hubitat-maker-api-client
This sample code demonstrates how to configure a HubitatCachingClient using your HOST, APP_ID, ACCESS_TOKEN and HUB_ID along with your custom implementation of DeviceCache.
from hubitat_maker_api_client import DeviceCache, HubitatAPIClient, HubitatCachingClient
class YourDeviceCache(DeviceCache):
# Override methods for reading and writing
# device state to your own datastore
_api_client = HubitatAPIClient(
host=<HOST>,
app_id=<APP_ID>,
access_token=<ACCESS_TOKEN>,
hub_id=<HUB_ID>,
)
client = HubitatCachingClient(
api_client=_api_client,
device_cache=YourDeviceCache(),
)
for switch in client.get_on_switches():
client.turn_off_switch(switch)
print(f'Turned off {switch}')
This sample code demonstrates how to update device state on your HubitatCachingClient by listening to Hubitat's /eventsocket.
import asyncio
import websockets
from hubitat_maker_api_client import HubitatEvent
async def listen(uri: str) -> None:
async with websockets.connect(uri) as websocket:
while True:
message = await websocket.recv()
event = HubitatEvent(json.loads(message))
client.update_from_hubitat_event(event)
asyncio.get_event_loop().run_until_complete(listen('ws://<HOST_IP>/eventsocket'))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hubitat_maker_api_client-2.5.1.tar.gz.
File metadata
- Download URL: hubitat_maker_api_client-2.5.1.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fd98c3d1c43ec1fa2be83dcedcab6a3b02232bd732cf6644fef0c450f41e14d
|
|
| MD5 |
6af86dca59e77f62a799c17d7e04a828
|
|
| BLAKE2b-256 |
e5ecbd7a7d3a2dfc2e606cb3c3c8dcbe163352f6e39dad10b0b0236dccfc5e1a
|
File details
Details for the file hubitat_maker_api_client-2.5.1-py3-none-any.whl.
File metadata
- Download URL: hubitat_maker_api_client-2.5.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
037a004848f3809163141df41064fc7dafe51bfb9329eb8cc81c70c08567e01e
|
|
| MD5 |
e223c3d617d37c27e3145a788728a29f
|
|
| BLAKE2b-256 |
17f41ea40af4bb4c6f40c71d8076a82e4fe2422c8d06bbd3047c7aa0b60438ca
|