Skip to main content

A Python API client for LibreHardwareMonitor

Project description

LibreHardwareMonitor API Client

A Python library for interacting with the LibreHardwareMonitor API.

Overview

This library provides a simple interface for fetching data from the API provided by the inbuilt LibreHardwareMonitor web server.

Installation

To install the library, run the following command:

pip install librehardwaremonitor-api

Usage

The LibreHardwareMonitorClient takes the following parameters:

  • Required:
    • host (str): hostname or IP address of your system
    • port (int): port used by Libre Hardware Monitor (default: 8085)
  • Optional:
    • username (str): if you have set up authentication for the webserver in Libre Hardware Monitor
    • password (str): if you have set up authentication for the webserver in Libre Hardware Monitor
    • session (aiohttp.ClientSession): provide a aiohttp.ClientSession

The library provides one callable method:

  • get_data: Returns a LibreHardwareMonitorData object containing the computer name, main hardware device names and all sensor data from your Libre Hardware Monitor instance.

LibreHardwareMonitorData has 4 properties with the following structure:

LibreHardwareMonitorData(
    computer_name: str
    # for example: "MY_COMPUTER"

    main_device_ids_and_names: dict[DeviceId, DeviceName]
    # for example:
    # {
    #     "amdcpu-0": "AMD Ryzen 7 7800X3D",
    #     "gpu-nvidia-0": "NVIDIA GeForce RTX 4080 SUPER"
    # }
    # the dictionary keys represent a unique device id.

    sensor_data: dict[str, LibreHardwareMonitorSensorData]
    # for example
    # {
    #     "amdcpu-0-power-0": {
    #         "name": Package Power",
    #         "value": "25.6",
    #         "type": "Power",
    #         "min": "25.2",
    #         "max": "76.4",
    #         "unit": "W",
    #         "device_id": "amdcpu-0",
    #         "device_name": "AMD Ryzen 7 7800X3D",
    #         "device_type": "CPU",
    #         "sensor_id": "amdcpu-0-power-0"
    #     },
    #     "amdcpu-0-power-1" : { ... },
    #     ...
    # }
    # the dictionary keys represent a unique sensor id.
    
    is_deprecated_version: bool
    # indicates whether the requested API version is deprecated
    # at the moment, versions <= 0.9.4 are deprecated
)

Example

import asyncio
from librehardwaremonitor_api import LibreHardwareMonitorClient

async def main():
    client = LibreHardwareMonitorClient("192.168.1.100", 8085)

    lhm_data = await client.get_data()
    print(lhm_data.computer_name)
    print(lhm_data.main_device_ids_and_names)
    print(lhm_data.sensor_data)
    
    if lhm_data.is_deprecated_version:
        print("Deprecated version detected.")

asyncio.run(main())

Development

This package uses uv as project manager.
To set up a dev environment, clone the project and run

uv sync

inside the project's root directory.
Set up pre-commit hooks with:

uv run pre-commit install

Optionally, execute manually via:

uv run pre-commit run --all-files

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

librehardwaremonitor_api-1.11.0.tar.gz (71.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

librehardwaremonitor_api-1.11.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file librehardwaremonitor_api-1.11.0.tar.gz.

File metadata

  • Download URL: librehardwaremonitor_api-1.11.0.tar.gz
  • Upload date:
  • Size: 71.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for librehardwaremonitor_api-1.11.0.tar.gz
Algorithm Hash digest
SHA256 0034a2e4fc7558c4d61d2de9f5b9ca38071bcf6f13c97f2a1c496a151c7448a5
MD5 ed52b958628e9fc18ef23c132baa9128
BLAKE2b-256 05a1a644c959ca48f67b736ba78f0cefae9fbaad4c3a40ccf7376f221699dd2b

See more details on using hashes here.

File details

Details for the file librehardwaremonitor_api-1.11.0-py3-none-any.whl.

File metadata

  • Download URL: librehardwaremonitor_api-1.11.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for librehardwaremonitor_api-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee8a2b1d26267de950f1a9942edc972409c2cbbb3bbb6cee0d32e88502aa4e81
MD5 a996427221d0567206f9a63604043162
BLAKE2b-256 36d1671e082769a04a825585b7b380d44786abfae93a3ea5bdc8e8df3b6ed62c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page