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.0b3

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.0b3
File Size Uploaded Provenance
pyhive_integration-2.0.0b3.tar.gz 57.2 kB With provenance Details

Built distribution (wheel)

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

Total release size: 269.4 kB

Release files / pyhive_integration-2.0.0b3.tar.gz

Download URL pyhive_integration-2.0.0b3.tar.gz
Size 57.2 kB
Tags Source
SHA-256 checksum
How to use checksums
25533d3a04cdfc030d465396791f00d28586eb6d959e80487d8ab999116b4327
BLAKE2b-256 checksum
How to use checksums
fa337cb24e0e598a48ae55f69d0d78c1d0946f3dec915fc1736b4a8372c3733c
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.0b3-py3-none-any.whl

Download URL pyhive_integration-2.0.0b3-py3-none-any.whl
Size 212.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d22612300bf943001d58c22238b999e2a063b1e892655c069e534e2e3e0e38e
BLAKE2b-256 checksum
How to use checksums
59d53bd06f33d5c220f1abd06d8dec2d9e74197251a574997a58aa1343cd60d8
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.0b3

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.0b3.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