This release is a pre-release and may not be stable for production use.
pyhive-integration
A Python library for interfacing with the Hive smart home platform. Provides both async (apyhiveapi) and sync (pyhiveapi) APIs, and is designed primarily for use with Home Assistant — though it works standalone too.
Package rename notice: This package replaces the legacy
pyhiveapipackage. The module names, API, and functionality are identical — only the PyPI distribution name changed.
Features
- Async-first design with a generated sync wrapper (no asyncio boilerplate needed in sync contexts)
- AWS Cognito SRP authentication with SMS two-factor authentication support
- Automatic token refresh at 90% of token lifetime with silent retry on expiry
- Polling-based device state with a smart cache to avoid stale reads during in-progress polls
- Full device discovery — returns a ready-to-use device list for Home Assistant entity creation
- File-based offline mode for development and testing without live credentials
Supported Devices
| Device Type | Capabilities |
|---|---|
| Heating (thermostat, TRV) | Current / target temperature, mode (schedule / manual / off), boost on/off, heat-on-demand, min/max range, schedule now/next/later |
| Hot Water | Mode (schedule / on / off), boost on/off, state |
| Lights | On/off, brightness, colour temperature, full RGB colour, colour mode |
| Smart Plugs | On/off, power usage |
| Sensors | Motion, contact (open/close), battery level, online status |
| Hub / Sense | Smoke, CO, dog bark, glass break detection |
Installation
pip install pyhive-integration
Requires Python 3.10+.
Quick Start
Async
import asyncio
from apyhiveapi import Auth, Hive
async def main():
auth = Auth(username="user@example.com", password="yourpassword")
tokens = await auth.login()
# If SMS 2FA is required:
# tokens = await auth.sms_2fa("123456", tokens)
hive = Hive(username="user@example.com", password="yourpassword")
await hive.startSession({"tokens": tokens})
for device in hive.session.data.devices.values():
print(device)
asyncio.run(main())
Sync
from pyhiveapi import Auth, Hive
auth = Auth(username="user@example.com", password="yourpassword")
tokens = auth.login()
hive = Hive(username="user@example.com", password="yourpassword")
hive.startSession({"tokens": tokens})
for device in hive.session.data.devices.values():
print(device)
Authentication
Authentication uses the AWS Cognito SRP flow. If your account has SMS two-factor authentication enabled, login() will raise HiveSmsRequired — call sms_2fa(code, tokens) with the code sent to your phone.
from apyhiveapi import Auth
from apyhiveapi.helper.hive_exceptions import HiveSmsRequired
auth = Auth(username="user@example.com", password="yourpassword")
try:
tokens = await auth.login()
except HiveSmsRequired:
code = input("SMS code: ")
tokens = await auth.sms_2fa(code, tokens)
Note: Only the Hive account owner is supported. Guest accounts cannot be used.
Controlling Devices
After startSession, device modules are available directly on the Hive instance:
# Heating
await hive.heating.set_target_temperature(device, 21.0)
await hive.heating.set_mode(device, "SCHEDULE")
await hive.heating.set_boost_on(device, mins=30, temp=22.0)
await hive.heating.set_boost_off(device)
# Hot water
await hive.hotwater.set_mode(device, "ON")
await hive.hotwater.set_boost_on(device, mins=60)
# Lights
await hive.light.set_status_on(device)
await hive.light.set_brightness(device, 80)
await hive.light.set_color_temp(device, 4000)
await hive.light.set_color(device, [255, 100, 0])
# Smart plug
await hive.switch.turn_on(device)
await hive.switch.turn_off(device)
# Force a data refresh
await hive.force_update()
Offline / File-Based Testing
Set username="use@file.com" to load device state from bundled JSON fixtures in src/data/ instead of making live API calls. Useful for development without real Hive credentials.
hive = Hive(username="use@file.com", password="")
await hive.startSession({})
Architecture
The library exposes two packages built from the same source:
apyhiveapi— async package (source insrc/)pyhiveapi— sync package (auto-generated fromsrc/viaunasyncduring build)
Never edit the generated sync files — edit the async source in src/ only.
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run linters
pre-commit run --all-files
# Run tests
pytest tests/
# Regenerate sync package
python setup.py build_py
Links
License
MIT License — see LICENSE for details.
Metadata
Release files for pyhive-integration 2.0.0b2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyhive_integration-2.0.0b2.tar.gz | 56.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyhive_integration-2.0.0b2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 265.0 kB
Release files / pyhive_integration-2.0.0b2.tar.gz
| Download URL | pyhive_integration-2.0.0b2.tar.gz |
|---|---|
| Size | 56.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
477b1ff5195c10f0d33f1f7abb07613a5efd97c8ce1af356e35e4ed9fa61c754
|
|
BLAKE2b-256 checksum How to use checksums |
53bf7d0d46baeb93f6eac5477f225845d0c443c7357d1ebf53ed0588c77dda8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / pyhive_integration-2.0.0b2-py3-none-any.whl
| Download URL | pyhive_integration-2.0.0b2-py3-none-any.whl |
|---|---|
| Size | 208.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d639c6f461ec973053ca9e01fceeabb52ab0e3558cc69c35ac29a19a8b46c2b
|
|
BLAKE2b-256 checksum How to use checksums |
3295f5b1af3712d43deec93eab7fd06b02e3bc014b76dc71e4c7345d8ce289a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency log