Skip to main content

pyopenhwmon

An async, fully-typed Python client for the Open Hardware Monitor (OHM) remote server. It fetches and parses the /data.json payload into immutable, easy-to-work-with data models.

pyopenhwmon is purpose-built for the Home Assistant Open Hardware Monitor integration and is also suitable for standalone use.

Scope: This library targets Open Hardware Monitor (OHM) only. Libre Hardware Monitor (LHM) is a different application with a different API and is covered by a separate integration/library.

Features

  • Async end-to-end, built on aiohttp.
  • Fully typed with a py.typed marker; passes mypy --strict.
  • Immutable data models (frozen dataclasses) that mirror the API without over-interpreting it.
  • IPv6-safe URL construction via yarl.
  • Tolerant parsing — one malformed node never crashes an entire update.
  • Clear exception hierarchy with a transient flag for retry decisions.
  • No hidden retries — rate-limit Retry-After is surfaced to the caller.
  • Accepts a caller-provided aiohttp.ClientSession (never closed by the client) or manages its own.

Installation

pip install pyopenhwmon

Requires Python 3.13 or newer.

Quick start (standalone)

import asyncio

from pyopenhwmon import OHMClient


async def main() -> None:
    async with OHMClient("192.168.1.50") as client:
        if not await client.ping():
            print("OHM server not reachable")
            return
        data = await client.get_data()
        for sensor in data.sensors:
            print(sensor.unique_id, sensor.value, sensor.unit)


asyncio.run(main())

Using your own session

import aiohttp
from pyopenhwmon import OHMClient

async with aiohttp.ClientSession() as session:
    client = OHMClient("192.168.1.50", session=session)
    data = await client.get_data()
    # `session` is closed by the caller, not by `client`.

Probing connectivity

ping() returns a simple bool. For a richer outcome — for example to distinguish "host up but the API is disabled" (HTTP 404) from "unreachable" — use probe():

from pyopenhwmon import OHMClient, ProbeStatus

async with OHMClient("192.168.1.50") as client:
    result = await client.probe()
    if result.status is ProbeStatus.OK:
        data = await client.get_data()
    elif result.status is ProbeStatus.API_DISABLED:
        print("OHM is running but the API is disabled")
    elif result.status is ProbeStatus.UNREACHABLE:
        print("OHM server not reachable")

Home Assistant

The Home Assistant integration uses this library as its data layer. A typical DataUpdateCoordinator fetch:

from pyopenhwmon import OHMClient, OHMError


async def async_update_data():
    try:
        return await client.get_data()
    except OHMError as err:
        if err.transient:
            raise UpdateFailed(...) from err
        raise ConfigEntryError(...) from err

The transient flag lets the coordinator distinguish retryable failures (connection errors, timeouts, rate limits, server errors, and malformed data) from permanent ones (HTTP 404).

API

OHMClient

OHMClient(
    host: str,
    port: int = 8085,
    *,
    session: aiohttp.ClientSession | None = None,
    scheme: str = "http",
    timeout: float = 10.0,
)
Member Description
await get_data() -> OHMData Fetch and parse the full data tree.
await probe() -> ProbeResult Rich connectivity probe (see ProbeStatus).
await ping() -> bool Lightweight connectivity check (True on HTTP 200).
await close() -> None Close the session if the client created it.
url -> yarl.URL The absolute /data.json URL.

OHMClient is an async context manager (async with). The scheme must be "http" or "https"; a ValueError is raised otherwise.

Data models

  • OHMData — a full snapshot: root_name, computers, sensors.
  • Computer — a computer node: name, sensors.
  • Sensor — a single reading: name, value, min, max, unit, raw_value, computer, path, unique_id.
  • ProbeResult — the outcome of probe(): status (a ProbeStatus) and http_status (the HTTP status when a response was received).
  • ProbeStatus — enum: OK, API_DISABLED, HTTP_ERROR, UNREACHABLE.

All models are frozen dataclasses exposing to_dict() for diagnostics.

Sensor.unique_id is a stable, human-readable identifier built from the name path, e.g. TEST-PC/Intel Core i7-7700/Temperatures/CPU Core #1. Note: two computers that share the same name produce colliding unique_id values (a rare edge case, matching the legacy integration).

Exceptions

Exception Transient Meaning
OHMError — Base class.
OHMConnectionError yes DNS / refused / reset.
OHMTimeoutError yes Connect or read timeout.
OHMHTTPError no Unexpected 4xx status.
OHMNotFoundError no HTTP 404 (API disabled / wrong port).
OHMRateLimitError yes HTTP 429; exposes retry_after.
OHMServerError yes HTTP 5xx (server-side failure).
OHMDataError yes Malformed payload (retry may succeed).

The OHM /data.json payload

OHM serves a JSON tree at GET /data.json (no authentication, default port 8085). Every node carries the keys id, Text, Children, Min, Value, Max, and ImageURL.

  • The root node is hardcoded with Text: "Sensor" and the literal header strings Min: "Min", Value: "Value", Max: "Max".
  • Branch nodes (computer / hardware / category) carry empty strings "" for Min/Value/Max.
  • Sensor leaves carry real reading strings such as "31.0 °C", or "-" when there is no reading.
  • There is no Type field in the payload.
  • A node is a usable sensor iff it has no children and its Value contains a space (i.e. looks like <number> <unit>).
  • Locale decimal commas occur (e.g. "29,0 °C").

Example (trimmed):

{
  "id": 0,
  "Text": "Sensor",
  "Children": [
    {
      "id": 1,
      "Text": "TEST-PC",
      "Children": [
        {
          "id": 2,
          "Text": "Intel Core i7-7700",
          "Children": [
            {
              "id": 3,
              "Text": "Temperatures",
              "Children": [
                {
                  "id": 4,
                  "Text": "CPU Core #1",
                  "Children": [],
                  "Min": "0.0 °C",
                  "Value": "31.0 °C",
                  "Max": "100.0 °C",
                  "ImageURL": "images/transparent.png"
                }
              ],
              "Min": "",
              "Value": "",
              "Max": "",
              "ImageURL": "images_icon/temperature.png"
            }
          ],
          "Min": "",
          "Value": "",
          "Max": "",
          "ImageURL": "images_icon/cpu.png"
        }
      ],
      "Min": "",
      "Value": "",
      "Max": "",
      "ImageURL": "images_icon/computer.png"
    }
  ],
  "Min": "Min",
  "Value": "Value",
  "Max": "Max",
  "ImageURL": ""
}

Development

python -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest            # runs the suite with 100% coverage gate
.venv/bin/ruff check .
.venv/bin/mypy

License

MIT

Metadata

Release files for pyopenhwmon 0.2.0

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

Source distribution (sdist)

Source distribution for pyopenhwmon 0.2.0
File Size Uploaded Provenance Actions
pyopenhwmon-0.2.0.tar.gz 16.5 kB With provenance Details for pyopenhwmon-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyopenhwmon 0.2.0
File Interpreter ABI Platform Actions
pyopenhwmon-0.2.0-py3-none-any.whl Python 3 none any Details for pyopenhwmon-0.2.0-py3-none-any.whl

Total release size: 29.0 kB

Release files / pyopenhwmon-0.2.0.tar.gz

Download URL pyopenhwmon-0.2.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f405b6bdd8f7a6178adf952133dbbdb677a54c3e330aa84361be6c563e80b59e
BLAKE2b-256 checksum
How to use checksums
47d17d18727a519571df4fd48a6d977fc275562af916d07ac20a904d5d97945b
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 Dec 4, 2026.

Transparency log

Release files / pyopenhwmon-0.2.0-py3-none-any.whl

Download URL pyopenhwmon-0.2.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2449563eba938ac035c0ce6d6c08748578af606222985217931c8638f918a274
BLAKE2b-256 checksum
How to use checksums
e416aafc7b2d07910f4f67043cbac83b6c874d7ac60a31a90728b3fd6a44cae0
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 Dec 4, 2026.

Transparency log

Security for pyopenhwmon 0.2.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyopenhwmon-0.2.0.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 Dec 4, 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.

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