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'))
Release files for hubitat-maker-api-client 2.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hubitat_maker_api_client-2.6.0.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hubitat_maker_api_client-2.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / hubitat_maker_api_client-2.6.0.tar.gz
| Download URL | hubitat_maker_api_client-2.6.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d7867656f85295ff6184c7d11f852f1490d98dd6cb013da6f7ee36b09ff5d42
|
|
BLAKE2b-256 checksum How to use checksums |
30187f91c346fc61a21eecad67c6e6c2162431fad73b9bc0fbb3926a65345761
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.11.4 Linux/6.5.0-25-generic
|
Release files / hubitat_maker_api_client-2.6.0-py3-none-any.whl
| Download URL | hubitat_maker_api_client-2.6.0-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd993e70ac430902462a6ef533a29f6c6e776f13543361b91cec277f58ca7bce
|
|
BLAKE2b-256 checksum How to use checksums |
fb626921867410538b4a44a2304d3577819702f0661f3842f0bf75fea8b172d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.11.4 Linux/6.5.0-25-generic
|