Skip to content

epinter/lhwservice

Repository files navigation

LibHardwareService

A C++ client library for LibreHardwareService

Latest Release Downloads Release Date License

This library is used to retrieve data from LibreHardwareService.

Runtime Requirements

Building

./cmake/build.ps1

Usage

#include <lhwservice/HardwareService.h>
...

int main() {
    lhws::HardwareService hwService;
    for (auto &a: hwService.getSmartAttributes("Harddisk Name", "Storage")) {
        std::cout << a.getName() << ": " << a.getValue() << std::endl;
    }

    try {
        lhws::Sensor a = hardwareService.getSensorByName("Sensor Name", "Temperature", "Hardware Name");
        std::cout << a.getName() << ": " << a.getValue() << std::endl;
    } catch (const SensorNotFoundException &e) {
        std::cerr << e.what() << endl;
    }

    try {
        lhws::Sensor a = hardwareService.getSensorById("/intelcpu/0/temperature/2");
        std::cout << a.getName() << ": " << a.getValue() << std::endl;
    } catch (const SensorNotFoundException &e) {
        std::cerr << e.what() << endl;
    }
}

For sensor types and names, run ShowSensors.exe from LibreHardwareService, or see LibreHardwareMonitor documentation / code.

License

This software is licensed under the terms of Mozilla Public License Version 2.0.