Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pyhive-integration

CI PyPI Python License

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 pyhiveapi package. 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 in src/)
  • pyhiveapi — sync package (auto-generated from src/ via unasync during 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


License

MIT License — see LICENSE for details.

Metadata

Release files for pyhive-integration 2.0.0b4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhive-integration 2.0.0b4
File Size Uploaded Provenance
pyhive_integration-2.0.0b4.tar.gz 58.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyhive-integration 2.0.0b4
File Interpreter ABI Platform
pyhive_integration-2.0.0b4-py3-none-any.whl Python 3 none any Details

Total release size: 273.4 kB

Release files / pyhive_integration-2.0.0b4.tar.gz

Download URL pyhive_integration-2.0.0b4.tar.gz
Size 58.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5bd5954ec0230187525535cea5bc9a0206e449a941bd4a90783d6b54147a6d94
BLAKE2b-256 checksum
How to use checksums
cc08fae34b3665aaa90c73b41e533091fb737ae93fad6a4f0bcaf5c9deda34c0
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 Oct 15, 2026.

Transparency log

Release files / pyhive_integration-2.0.0b4-py3-none-any.whl

Download URL pyhive_integration-2.0.0b4-py3-none-any.whl
Size 215.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
046d4aa80a545b792dc0acdc0019f26c3b9e733e42f6555d1a20c4647ea2f4e3
BLAKE2b-256 checksum
How to use checksums
bde3adad06d9c9c819b5fea592f044b0b7d3b51f0012c079865fd9b6c4f1ccf0
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 Oct 15, 2026.

Transparency log

Security for pyhive-integration 2.0.0b4

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyhive_integration-2.0.0b4.tar.gz

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 Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page