UPowerGlib.Device

g GObject.Object GObject.Object UPowerGlib.Device UPowerGlib.Device GObject.Object->UPowerGlib.Device

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

kind_from_string (type)

class

kind_to_string (type_enum)

class

level_from_string (level)

class

level_to_string (level_enum)

class

new ()

class

state_from_string (state)

class

state_to_string (state_enum)

class

technology_from_string (technology)

class

technology_to_string (technology_enum)

get_history_sync (type, timespec, resolution, cancellable)

get_object_path ()

get_statistics_sync (type, cancellable)

refresh_sync (cancellable)

set_object_path_sync (object_path, cancellable)

to_text ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

battery-level

int

r/w

capacity

float

r/w

charge-cycles

int

r/w

energy

float

r/w

energy-empty

float

r/w

energy-full

float

r/w

energy-full-design

float

r/w

energy-rate

float

r/w

has-history

bool

r/w

has-statistics

bool

r/w

icon-name

str

r/w

is-present

bool

r/w

is-rechargeable

bool

r/w

kind

int

r/w

luminosity

float

r/w

model

str

r/w

native-path

str

r/w

online

bool

r/w

percentage

float

r/w

power-supply

bool

r/w

serial

str

r/w

state

int

r/w

technology

int

r/w

temperature

float

r/w

time-to-empty

int

r/w

time-to-full

int

r/w

update-time

int

r/w

vendor

str

r/w

voltage

float

r/w

warning-level

int

r/w

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

priv

UPowerGlib.DevicePrivate

r

Class Details

class UPowerGlib.Device(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

UPowerGlib.DeviceClass

classmethod kind_from_string(type)
Parameters:

type (str) –

Returns:

enumerated value

Return type:

UPowerGlib.DeviceKind

Converts a string to a UPowerGlib.DeviceKind.

New in version 0.9.0.

classmethod kind_to_string(type_enum)
Parameters:

type_enum (UPowerGlib.DeviceKind) –

Returns:

identifier string

Return type:

str

Converts a UPowerGlib.DeviceKind to a string.

New in version 0.9.0.

classmethod level_from_string(level)
Parameters:

level (str) –

Returns:

enumerated value

Return type:

UPowerGlib.DeviceLevel

Converts a string to a UPowerGlib.DeviceLevel.

New in version 1.0.

classmethod level_to_string(level_enum)
Parameters:

level_enum (UPowerGlib.DeviceLevel) –

Returns:

identifier string

Return type:

str

Converts a UPowerGlib.DeviceLevel to a string.

New in version 1.0.

classmethod new()
Returns:

a new UPowerGlib.Device object.

Return type:

UPowerGlib.Device

Creates a new UPowerGlib.Device object.

New in version 0.9.0.

classmethod state_from_string(state)
Parameters:

state (str) –

Returns:

enumerated value

Return type:

UPowerGlib.DeviceState

Converts a string to a UPowerGlib.DeviceState.

New in version 0.9.0.

classmethod state_to_string(state_enum)
Parameters:

state_enum (UPowerGlib.DeviceState) –

Returns:

identifier string

Return type:

str

Converts a UPowerGlib.DeviceState to a string.

New in version 0.9.0.

classmethod technology_from_string(technology)
Parameters:

technology (str) –

Returns:

enumerated value

Return type:

UPowerGlib.DeviceTechnology

Converts a string to a UPowerGlib.DeviceTechnology.

New in version 0.9.0.

classmethod technology_to_string(technology_enum)
Parameters:

technology_enum (UPowerGlib.DeviceTechnology) –

Returns:

identifier string

Return type:

str

Converts a UPowerGlib.DeviceTechnology to a string.

New in version 0.9.0.

get_history_sync(type, timespec, resolution, cancellable)
Parameters:
  • type (str) – The type of history, known values are “rate” and “charge”.

  • timespec (int) – the amount of time to look back into time.

  • resolution (int) – the resolution of data.

  • cancellable (Gio.Cancellable or None) – a Gio.Cancellable or None

Raises:

GLib.Error

Returns:

an array of UPowerGlib.HistoryItem's, with the most recent one being first; None if error is set or self is invalid

Return type:

[UPowerGlib.HistoryItem]

Gets the device history.

New in version 0.9.0.

get_object_path()
Returns:

the object path, or None

Return type:

str

Gets the object path for the device.

New in version 0.9.0.

get_statistics_sync(type, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

an array of UPowerGlib.StatsItem's, else None and error is used

Return type:

[UPowerGlib.StatsItem]

Gets the device current statistics.

New in version 0.9.0.

refresh_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – a Gio.Cancellable or None

Raises:

GLib.Error

Returns:

True for success, else False and error is used

Return type:

bool

Refreshes properties on the device. This function is normally not required and will only return without an error if the daemon was started in debug mode.

New in version 0.9.0.

set_object_path_sync(object_path, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success, else False and error is used

Return type:

bool

Sets the object path of the object and fills up initial properties.

New in version 0.9.0.

to_text()
Returns:

text representation of UPowerGlib.Device

Return type:

str

Converts the device to a string description.

New in version 0.9.0.

Property Details

UPowerGlib.Device.props.battery_level
Name:

battery-level

Type:

int

Default Value:

1

Flags:

READABLE, WRITABLE

The battery level, e.g. UPowerGlib.DeviceLevel.CRITICAL. If this is something other than UPowerGlib.DeviceLevel.NONE, then User Interfaces should use this approximate level instead of percentages.

New in version 1.0.

UPowerGlib.Device.props.capacity
Name:

capacity

Type:

float

Default Value:

100.0

Flags:

READABLE, WRITABLE

The percentage capacity of the device where 100% means the device has the same charge potential as when it was manufactured.

New in version 0.9.0.

UPowerGlib.Device.props.charge_cycles
Name:

charge-cycles

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE

The number of charge cycles for the battery, or -1 if unknown or non-applicable.

New in version 1.0.

UPowerGlib.Device.props.energy
Name:

energy

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The energy left in the device. Measured in mWh.

New in version 0.9.0.

UPowerGlib.Device.props.energy_empty
Name:

energy-empty

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The energy the device will have when it is empty. This is usually zero. Measured in mWh.

New in version 0.9.0.

UPowerGlib.Device.props.energy_full
Name:

energy-full

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The amount of energy when the device is fully charged. Measured in mWh.

New in version 0.9.0.

UPowerGlib.Device.props.energy_full_design
Name:

energy-full-design

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The amount of energy when the device was brand new. Measured in mWh.

New in version 0.9.0.

UPowerGlib.Device.props.energy_rate
Name:

energy-rate

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The rate of discharge or charge. Measured in mW.

New in version 0.9.0.

UPowerGlib.Device.props.has_history
Name:

has-history

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the device has history data that might be useful.

New in version 0.9.0.

UPowerGlib.Device.props.has_statistics
Name:

has-statistics

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the device has statistics data that might be useful.

New in version 0.9.0.

UPowerGlib.Device.props.icon_name
Name:

icon-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The icon name, following the Icon Naming Speficiation

New in version 1.0.

UPowerGlib.Device.props.is_present
Name:

is-present

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the device is present, as some devices like laptop batteries can be removed, leaving an empty bay that is still technically a device.

New in version 0.9.0.

UPowerGlib.Device.props.is_rechargeable
Name:

is-rechargeable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the device has a rechargable battery.

New in version 0.9.0.

UPowerGlib.Device.props.kind
Name:

kind

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The device kind, e.g. UPowerGlib.DeviceKind.KEYBOARD.

New in version 0.9.0.

UPowerGlib.Device.props.luminosity
Name:

luminosity

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The current luminosity of the device.

New in version 0.9.19.

UPowerGlib.Device.props.model
Name:

model

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The model of the device.

New in version 0.9.0.

UPowerGlib.Device.props.native_path
Name:

native-path

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The native path of the device, useful for direct device access.

New in version 0.9.0.

UPowerGlib.Device.props.online
Name:

online

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the device is online, i.e. connected.

New in version 0.9.0.

UPowerGlib.Device.props.percentage
Name:

percentage

Type:

float

Default Value:

100.0

Flags:

READABLE, WRITABLE

The percentage charge of the device. Note that if the battery level property is something other than UPowerGlib.DeviceLevel.NONE, then this percentage is an approximation, and should not be used a number to display to the user.

New in version 0.9.0.

UPowerGlib.Device.props.power_supply
Name:

power-supply

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If the device is powering the system.

New in version 0.9.0.

UPowerGlib.Device.props.serial
Name:

serial

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The serial number of the device.

New in version 0.9.0.

UPowerGlib.Device.props.state
Name:

state

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The state the device is in at this time, e.g. UPowerGlib.DeviceState.EMPTY.

New in version 0.9.0.

UPowerGlib.Device.props.technology
Name:

technology

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The battery technology e.g. UPowerGlib.DeviceTechnology.LITHIUM_ION.

New in version 0.9.0.

UPowerGlib.Device.props.temperature
Name:

temperature

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The temperature of the device in degrees Celsius.

New in version 0.9.22.

UPowerGlib.Device.props.time_to_empty
Name:

time-to-empty

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The amount of time until the device is empty.

New in version 0.9.0.

UPowerGlib.Device.props.time_to_full
Name:

time-to-full

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The amount of time until the device is fully charged.

New in version 0.9.0.

UPowerGlib.Device.props.update_time
Name:

update-time

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The last time the device was updated.

New in version 0.9.0.

UPowerGlib.Device.props.vendor
Name:

vendor

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The vendor of the device.

New in version 0.9.0.

UPowerGlib.Device.props.voltage
Name:

voltage

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE

The current voltage of the device.

New in version 0.9.0.

UPowerGlib.Device.props.warning_level
Name:

warning-level

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The warning level e.g. UPowerGlib.DeviceLevel.CRITICAL.

New in version 1.0.