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.typedmarker; passesmypy --strict. - Immutable data models (
frozendataclasses) 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
transientflag for retry decisions. - No hidden retries — rate-limit
Retry-Afteris 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`.
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) from permanent ones (HTTP 404,
malformed data).
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 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).
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.
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.
Exceptions
| Exception | Transient | Meaning |
|---|---|---|
OHMError |
— | Base class. |
OHMConnectionError |
yes | DNS / refused / reset. |
OHMTimeoutError |
yes | Connect or read timeout. |
OHMHTTPError |
no | Unexpected 4xx/5xx status. |
OHMNotFoundError |
no | HTTP 404 (API disabled / wrong port). |
OHMRateLimitError |
yes | HTTP 429; exposes retry_after. |
OHMDataError |
no | Malformed payload. |
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 stringsMin: "Min",Value: "Value",Max: "Max". - Branch nodes (computer / hardware / category) carry empty strings
""forMin/Value/Max. - Sensor leaves carry real reading strings such as
"31.0 °C", or"-"when there is no reading. - There is no
Typefield in the payload. - A node is a usable sensor iff it has no children and its
Valuecontains 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
Metadata
Release files for pyopenhwmon 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyopenhwmon-0.1.0.tar.gz | 14.8 kB | With provenance | Details for pyopenhwmon-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyopenhwmon-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyopenhwmon-0.1.0-py3-none-any.whl |
Total release size: 25.9 kB
Release files / pyopenhwmon-0.1.0.tar.gz
| Download URL | pyopenhwmon-0.1.0.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
058eae1b0bb5a57e224133d75a22f23e8b74097f040fbdc1adfb008d26014e68
|
|
BLAKE2b-256 checksum How to use checksums |
2c2fd45a77d38225b6fad55782b59e5401e590da688ca4844639c29a7998d43a
|
| 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 3, 2026.
Transparency logRelease files / pyopenhwmon-0.1.0-py3-none-any.whl
| Download URL | pyopenhwmon-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a99377ea6a68ed8d40f1e58d2a90b59d4a84cd15049247eebc20cd53eef441dd
|
|
BLAKE2b-256 checksum How to use checksums |
d0e0ceda4fe54419f1e337c01b23676e3ac46747dc2d8a8f940c580401df654a
|
| 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 3, 2026.
Transparency logSecurity for pyopenhwmon 0.1.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.
Attestation for pyopenhwmon-0.1.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 3, 2026.
Transparency logA 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.