Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

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, temperature history
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.

Standalone login example

examples/example_login.py is a complete runnable script. The first run asks for your email, password and SMS code, registers the machine as a trusted device and saves the device credentials to hive_device.json. Later runs log in with that file and skip the SMS. Both runs list every discovered device.

pip install pyhive-integration
python examples/example_login.py

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)

# Weekly schedule (heating and hot water). Hive only accepts the whole
# week, so edit the dict from get_schedule and pass it back.
schedule = await hive.heating.get_schedule(device)
schedule["monday"][0]["value"]["target"] = 19.5   # heating slots: {"target": °C}
await hive.heating.set_schedule(device, schedule)  # hot water slots: {"status": "ON"|"OFF"}
# Temperature history for a heating zone (ms since epoch; HOURS/DAYS/...).
# Returns [{"date": <ms>, "temperature": <°C>}, ...], averaged per bucket.
history = await hive.heating.get_temperature_history(device, start_ms, end_ms, "HOURS")

# 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.0b5

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

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for pyhive-integration 2.0.0b5
File Size Uploaded Provenance Actions
pyhive_integration-2.0.0b5.tar.gz 64.2 kB With provenance Details for pyhive_integration-2.0.0b5.tar.gz

Built distribution (wheel)

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

Total release size: 293.5 kB

Release files / pyhive_integration-2.0.0b5.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL pyhive_integration-2.0.0b5.tar.gz
Size 64.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1af4075a0a7bd2285858b58289b6450b4d348e65e5d8ae762105d0edfab78120
BLAKE2b-256 checksum
How to use checksums
3f9d24506d37ac35e2f691ce705292ba71a3c6d0f5ca6fe31d1b0b34d0db102e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 2, 2026.

Transparency log

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

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL pyhive_integration-2.0.0b5-py3-none-any.whl
Size 229.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e25eec817c92db6c9dd134d60e030ef19e49bda1848848e77542922017e4df0
BLAKE2b-256 checksum
How to use checksums
aa569eea349a62361cc82d6f4ae7918c91e19669a804aa5ae6178baf344879d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 2, 2026.

Transparency log

Security for pyhive-integration 2.0.0b5

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.

Change of provenance

The configuration that created this release differs from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 2 files

Attestation for pyhive_integration-2.0.0b5.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 Nov 2, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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