Reference

Exceptions

exception sensors.SensorsException

Raised when an error occurs. This normally means that a libsensors function call failed.

message

The error message returned from the libsensors API.

Functions

sensors.cleanup()

You have to call this function when you don’t need the module anymore. Use a try/finally block to make sure it’s called:

try:
    main()
finally:
    sensors.cleanup()
sensors.get_detected_chips([ChipName match])

Return a list of ChipName for all the detected chips matching the chip name. If match isn’t provided, all the detected chips are returned.

sensors.get_adapter_name(int bus_type, int bus_nr)

Return the name of the bus, or None if it can’t be found.

sensors.init(filename)

When you import sensors, libsensors will load the configuration files from the default directory, which is what you want in most cases. Call this function if you need to load a different configuration file. Internally, it calls sensors_cleanup() and then sensors_init() with your file. If the file can’t be opened, IOError is raised. If the initialization fails, SensorsException is raised.

sensors.replace_parse_error_handler(handler)

handler will be called when a parse error occurs. It will be passed three arguments: the error message, the filename and the line number. In some cases the filename may be None, and the line number may be 0.

sensors.replace_fatal_error_handler(handler)

handler will be called when a fatal error occurs. It will be passed two arguments: the name of the function that failed, and the error message. If your function doesn’t exit the process, it will be done automatically when after your function returns.

Classes

class sensors.ChipName(prefix=None, bus_type=0, bus_nr=0, addr=0, path=None)
repr(c)
str(c)

Return a user-friendly representation of the chip name, using sensors_snprintf_chip_name(). Note that this C function will fail when “wildcards” are used, and __str__() will raise SensorsException. Wildcards are invalid values that have a special meaning, for example None can be used to match any chip name prefix.

c1 == c2

Return True if the members of c1 and c2 are equal.

c1 != c2

Equivalent to not c1 == c2.

prefix
bus_type
bus_nr
addr
path
get_features()
get_all_subfeatures(feature)
get_subfeature(feature, int type)

Return the subfeature of feature that has type, or None if it can’t be found. type should be a constant such as SUBFEATURE_TEMP_INPUT, see Subfeatures.

get_label(feature)

Return the label of the given feature. The chip shouldn’t contain wilcard values.

get_value(int subfeat_nr)

Return the value of a subfeature for the chip, as a float. The chip shouldn’t contain wildcard values.

get_value_or_none(int subfeat_nr)

Return the value of a subfeature for the chip as a float, or None if an error occurred. The chip shouldn’t contain wildcard values.

set_value(int subfeat_nr, float value)

Set a value of the chip. The chip shouldn’t contain wildcard values.

do_chip_sets()

Execute all set statements for the chip. The chip may contain contain wildcards.

static parse_chip_name(str orig_name)

Return a ChipName object corresponding to the chip name represented by orig_name.

class sensors.Feature(name=None, number=0, type=0)

You can think of features as categories for Subfeature objects.

repr(f)
f1 == f2

Return True if the members of f1 and f2 are equal.

f1 != f2

Equivalent to not f1 == f2.

name
number
type
class sensors.Subfeature(name=None, number=0, type=0, mapping=0, flags=0)
repr(s)
s1 == s2

Return True if the members of s1 and s2 are equal.

s1 != s2

Equivalent to not s1 == s2.

name

Used to refer to the feature in config files.

number

Internal subfeature number, used throughout the API to refer to the subfeature.

type

Subfeature type.

mapping

Number of the main Feature this subfeature belongs to. For example, subfeatures SUBFEATURE_FAN_INPUT, SUBFEATURE_FAN_MIN, SUBFEATURE_FAN_DIV and SUBFEATURE_FAN_ALARM are mapped to main feature FEATURE_FAN.

flags

This is a bitfield, its value is a combination of MODE_R (readable), MODE_W (writable) and COMPUTE_MAPPING (affected by the computation rules of the main feature).

Constants

API version

sensors.LIBSENSORS_VERSION

A string describing the libsensors version, e.g. '3.3.1'.

sensors.API_VERSION

A number whose digits, in hexadecimal, represent the API version. The first digit is the major version (large changes that break the compatibility), the second one is for large changes, the third one is for small additions.

Bus numbers

sensors.BUS_NR_ANY
sensors.BUS_NR_IGNORE

Bus types

sensors.BUS_TYPE_ACPI
sensors.BUS_TYPE_ANY
sensors.BUS_TYPE_HID
sensors.BUS_TYPE_I2C
sensors.BUS_TYPE_ISA
sensors.BUS_TYPE_PCI
sensors.BUS_TYPE_SPI
sensors.BUS_TYPE_VIRTUAL

Chip names wilcards

sensors.CHIP_NAME_ADDR_ANY
sensors.CHIP_NAME_PREFIX_ANY

Features

sensors.FEATURE_BEEP_ENABLE
sensors.FEATURE_CURR
sensors.FEATURE_ENERGY
sensors.FEATURE_FAN
sensors.FEATURE_HUMIDITY
sensors.FEATURE_IN
sensors.FEATURE_INTRUSION
sensors.FEATURE_MAX_MAIN
sensors.FEATURE_MAX_OTHER
sensors.FEATURE_POWER
sensors.FEATURE_TEMP
sensors.FEATURE_UNKNOWN
sensors.FEATURE_VID

Constants used in Subfeature.flags

sensors.MODE_R
sensors.MODE_W
sensors.COMPUTE_MAPPING

Subfeatures

sensors.SUBFEATURE_BEEP_ENABLE
sensors.SUBFEATURE_CURR_BEEP
sensors.SUBFEATURE_CURR_CRIT
sensors.SUBFEATURE_CURR_CRIT_ALARM
sensors.SUBFEATURE_CURR_INPUT
sensors.SUBFEATURE_CURR_LCRIT
sensors.SUBFEATURE_CURR_LCRIT_ALARM
sensors.SUBFEATURE_CURR_MAX
sensors.SUBFEATURE_CURR_MAX_ALARM
sensors.SUBFEATURE_CURR_MIN
sensors.SUBFEATURE_CURR_MIN_ALARM
sensors.SUBFEATURE_ENERGY_INPUT
sensors.SUBFEATURE_FAN_ALARM
sensors.SUBFEATURE_FAN_BEEP
sensors.SUBFEATURE_FAN_DIV
sensors.SUBFEATURE_FAN_FAULT
sensors.SUBFEATURE_FAN_INPUT
sensors.SUBFEATURE_FAN_MIN
sensors.SUBFEATURE_FAN_PULSES
sensors.SUBFEATURE_HUMIDITY_INPUT
sensors.SUBFEATURE_INTRUSION_ALARM
sensors.SUBFEATURE_INTRUSION_BEEP
sensors.SUBFEATURE_IN_BEEP
sensors.SUBFEATURE_IN_CRIT
sensors.SUBFEATURE_IN_CRIT_ALARM
sensors.SUBFEATURE_IN_INPUT
sensors.SUBFEATURE_IN_LCRIT
sensors.SUBFEATURE_IN_LCRIT_ALARM
sensors.SUBFEATURE_IN_MAX
sensors.SUBFEATURE_IN_MAX_ALARM
sensors.SUBFEATURE_IN_MIN
sensors.SUBFEATURE_IN_MIN_ALARM
sensors.SUBFEATURE_POWER_ALARM
sensors.SUBFEATURE_POWER_AVERAGE
sensors.SUBFEATURE_POWER_AVERAGE_HIGHEST
sensors.SUBFEATURE_POWER_AVERAGE_LOWEST
sensors.SUBFEATURE_POWER_CAP
sensors.SUBFEATURE_POWER_CAP_ALARM
sensors.SUBFEATURE_POWER_CAP_HYST
sensors.SUBFEATURE_POWER_CRIT
sensors.SUBFEATURE_POWER_CRIT_ALARM
sensors.SUBFEATURE_POWER_INPUT
sensors.SUBFEATURE_POWER_INPUT_HIGHEST
sensors.SUBFEATURE_POWER_INPUT_LOWEST
sensors.SUBFEATURE_POWER_MAX
sensors.SUBFEATURE_POWER_MAX_ALARM
sensors.SUBFEATURE_TEMP_BEEP
sensors.SUBFEATURE_TEMP_CRIT
sensors.SUBFEATURE_TEMP_CRIT_ALARM
sensors.SUBFEATURE_TEMP_CRIT_HYST
sensors.SUBFEATURE_TEMP_EMERGENCY
sensors.SUBFEATURE_TEMP_EMERGENCY_ALARM
sensors.SUBFEATURE_TEMP_EMERGENCY_HYST
sensors.SUBFEATURE_TEMP_FAULT
sensors.SUBFEATURE_TEMP_INPUT
sensors.SUBFEATURE_TEMP_LCRIT
sensors.SUBFEATURE_TEMP_LCRIT_ALARM
sensors.SUBFEATURE_TEMP_MAX
sensors.SUBFEATURE_TEMP_MAX_ALARM
sensors.SUBFEATURE_TEMP_MAX_HYST
sensors.SUBFEATURE_TEMP_MIN
sensors.SUBFEATURE_TEMP_MIN_ALARM
sensors.SUBFEATURE_TEMP_OFFSET
sensors.SUBFEATURE_TEMP_TYPE
sensors.SUBFEATURE_UNKNOWN
sensors.SUBFEATURE_VID