Skip to content

🌡️ Thermal and cooling API

linuxpy.thermal

Human friendly interface to linux thermal subsystem.

The heart of linuxpy thermal library are the ThermalZone and CoolingDevice classes.

Probably the most common way to create a thermal device is through the find helper:

with find(type="x86_pkg_temp") as tz:
    print(f"X86 temperature: {tz.temperature/1000:6.2f} C")

ThermalZone(syspath: os.PathLike)

Bases: Device

Thermal sensor

ATTRIBUTE DESCRIPTION
type

thermal zone type

TYPE: str

policy

the policy

TYPE: str

available_policies

list of available policies

TYPE: list[str]

temperature

current temperature in milli-celsius

TYPE: int

offset

offet in milli-celsius

TYPE: int

mode

current mode (enabled/disabled)

TYPE: Mode

device_number

thermal device number

TYPE: int

trip_points

list of trip points (new list every time)

TYPE: list[TripPoint]

TripPoint(temperature_path, type_path)

Trip point associated with the thermal zone

ATTRIBUTE DESCRIPTION
temperature

trip point temperature in milli-celsius

TYPE: int

type

trip point type

TYPE: str

CoolingDevice(syspath: os.PathLike)

Bases: Device

Cooling device (fan, processor, ...)

ATTRIBUTE DESCRIPTION
type

thermal zone type

TYPE: str

iter_thermal_zone_paths() -> Iterable[pathlib.Path]

Returns an iterator over all thermal zone paths

iter_thermal_zone_devices() -> Iterable[ThermalZone]

Returns an iterator over all thermal zone devices

iter_cooling_device_paths() -> Iterable[pathlib.Path]

Returns an iterator over all cooling device paths

iter_cooling_devices() -> Iterable[CoolingDevice]

Returns an iterator over all cooling devices

iter_devices() -> Iterable[Union[ThermalZone, CoolingDevice]]

Returns an iterator over all thermal and cooling devices

find(find_all: bool = False, custom_match: Optional[Callable] = None, **kwargs) -> Union[Device, Iterable[Device], None]

If find_all is False:

Find a device follwing the criteria matched by custom_match and kwargs. If no device is found matching the criteria it returns None. Default is to return a random first device.

If find_all is True:

The result is an iterator. Find all devices that match the criteria custom_match and kwargs. If no device is found matching the criteria it returns an empty iterator. Default is to return an iterator over all input devices found on the system.