TemperatureReading
TemperatureReading
Info
TemperatureReading is an interface representing a single temperature sensor reading from the host machine. Each reading corresponds to one physical sensor (CPU die, GPU hotspot, motherboard chipset, storage device, etc.) and is returned as part of a TemperatureSnapshot from the getTemperature() function.
Interface Introduction
You encounter TemperatureReading objects inside the readings array of a TemperatureSnapshot. Every sensor detected by the underlying LibreHardwareMonitor library produces one TemperatureReading entry. Use this interface to inspect individual sensor temperatures, filter by hardware category, or build temperature monitoring dashboards.
Properties
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier for this sensor, stable across calls within the same session |
label | string | Human-readable sensor name (e.g. "CPU Package", "GPU Core") |
category | TemperatureCategory | Hardware category this sensor belongs to |
temperatureCelsius | number | Current temperature in degrees Celsius |
source | "libre-hardware-monitor" | Fixed data source identifier, always "libre-hardware-monitor" |
Note
The id string is derived from the sensor's internal path in LibreHardwareMonitor. It remains consistent across consecutive calls but may change if the hardware topology changes (e.g. a USB device is plugged in).
Tips
Use the category property to group readings by hardware type rather than parsing the label string. The TemperatureCategory enum provides well-defined values ("cpu", "gpu", "motherboard", "storage", "unknown") that are more reliable than label-based heuristics.
Usage
TemperatureReading objects are read-only snapshots. You do not create them yourself; instead, call getTemperature() and iterate over the readings array of the returned TemperatureSnapshot.
A typical workflow:
- Call
getTemperature()to obtain the current TemperatureSnapshot. - Check
snapshot.isAvailableto confirm LibreHardwareMonitor is running. - Access
snapshot.readingsto get the array ofTemperatureReadingobjects. - Filter or display readings by
category,label, ortemperatureCelsius.
Tips
Temperature values are floating-point numbers in Celsius. To convert to Fahrenheit, use temp * 9 / 5 + 32. Avoid rounding before comparison to preserve precision.
Warning
When isAvailable is false on the parent TemperatureSnapshot, the readings array will be empty. Always check isAvailable before iterating.
Example
import { getTemperature, TemperatureReading } from '@eisland/windows-performance-monitor';
// Query the current temperature snapshot
const snapshot = getTemperature();
// Check if temperature data is available (requires LibreHardwareMonitor)
if (!snapshot.isAvailable) {
console.log('Temperature data unavailable — is the helper EXE running?');
} else {
// Iterate over all sensor readings
snapshot.readings.forEach((r: TemperatureReading) => {
// Pick a display icon based on the sensor category
const icon = r.category === 'cpu' ? '[CPU]'
: r.category === 'gpu' ? '[GPU]'
: r.category === 'storage' ? '[STO]'
: '[HW]';
// Print the sensor label and current temperature
console.log(`${icon} ${r.label}: ${r.temperatureCelsius}°C`);
});
// Filter readings to CPU sensors only
const cpuReadings: TemperatureReading[] = snapshot.readings.filter(
(r: TemperatureReading) => r.category === 'cpu'
);
console.log(`CPU sensors: ${cpuReadings.length}`);
}const { getTemperature } = require('@eisland/windows-performance-monitor');
// Query the current temperature snapshot
const snapshot = getTemperature();
// Check if temperature data is available (requires LibreHardwareMonitor)
if (!snapshot.isAvailable) {
console.log('Temperature data unavailable — is the helper EXE running?');
} else {
// Iterate over all sensor readings
snapshot.readings.forEach((r) => {
// Pick a display icon based on the sensor category
const icon = r.category === 'cpu' ? '[CPU]'
: r.category === 'gpu' ? '[GPU]'
: r.category === 'storage' ? '[STO]'
: '[HW]';
// Print the sensor label and current temperature
console.log(`${icon} ${r.label}: ${r.temperatureCelsius}°C`);
});
// Filter readings to CPU sensors only
const cpuReadings = snapshot.readings.filter(
(r) => r.category === 'cpu'
);
console.log(`CPU sensors: ${cpuReadings.length}`);
}Notes
Note
The source field is currently always "libre-hardware-monitor". Future versions may introduce additional data sources. Treat the value as a string rather than hard-coding equality checks if you want forward compatibility.
Note
Temperature readings are collected at the moment getTemperature() is called. There is no built-in polling or event-based update mechanism. To track temperature changes over time, call getTemperature() on your own interval.
Tips
If you only need the highest temperature across all sensors (for example, to display a single "system hot" indicator), use the maxTemperatureCelsius field on the parent TemperatureSnapshot instead of computing it yourself from the readings array.
Danger Avoidance
Caution
Do not assume temperatureCelsius is always a reasonable value. LibreHardwareMonitor may report 0 or negative values for sensors that are not actively reading. Always validate against expected ranges before using the value in threshold-based alerts or UI displays.
Caution
Calling getTemperature() in a tight loop (e.g. inside requestAnimationFrame or a zero-delay setInterval) will trigger repeated hardware polling via the LibreHardwareMonitor helper process. This wastes CPU cycles and can cause the helper EXE to become unresponsive. Poll at intervals of 1 second or longer.
Changelog
4f6b6-on

