Solid.Battery

KDE 4.9 PyKDE API Reference

- KDE's Python API

# Battery Class Reference

`from PyKDE4.solid import *`

Inherits: Solid.DeviceInterface → QObject
Namespace: Solid

## Detailed Description

This device interface is available on batteries.

## Enumerations
BatteryType | { UnknownBattery, PdaBattery, UpsBattery, PrimaryBattery, MouseBattery, KeyboardBattery, KeyboardMouseBattery, CameraBattery, PhoneBattery, MonitorBattery }
ChargeState | { NoCharge, Charging, Discharging }
## Signals
| chargePercentChanged (int value, QString udi)
| chargeStateChanged (int newState, QString udi)
| plugStateChanged (bool newState, QString udi)
## Methods
| __init__ (self, QObject backendObject)
int | chargePercent (self)
Solid.Battery.ChargeState | chargeState (self)
bool | isPlugged (self)
bool | isRechargeable (self)
Solid.Battery.BatteryType | type (self)
## Static Methods
Solid.DeviceInterface.Type | deviceInterfaceType ()

## Signal Documentation

chargePercentChanged | ( | int | value,
|  | QString | udi
| ) |  |  |

This signal is emitted when the charge percent value of this battery has changed.

Parameters:

  | value | the new charge percent value of the battery
  | udi | the UDI of the battery with the new charge percent

Signal syntax:
  `QObject.connect(source, SIGNAL("chargePercentChanged(int, const QString&)"), target_slot)`

chargeStateChanged | ( | int | newState,
|  | QString | udi
| ) |  |  |

This signal is emitted when the charge state of this battery has changed.

Parameters:

  | newState | the new charge state of the battery, it's one of the type Solid.Battery.ChargeState

See also:
  Solid.Battery.ChargeState

Parameters:

  | udi | the UDI of the battery with the new charge state

Signal syntax:
  `QObject.connect(source, SIGNAL("chargeStateChanged(int, const QString&)"), target_slot)`

plugStateChanged | ( | bool | newState,
|  | QString | udi
| ) |  |  |

This signal is emitted if the battery get plugged in/out of the battery bay.

Parameters:

  | newState | the new plugging state of the battery, type is boolean
  | udi | the UDI of the battery with the new plugging state

Signal syntax:
  `QObject.connect(source, SIGNAL("plugStateChanged(bool, const QString&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QObject | backendObject
| ) |  |  |

Creates a new Battery object. You generally won't need this. It's created when necessary using Device.as().

Parameters:

  | backendObject | the device interface object provided by the backend

See also:
  Solid.Device.as()

int chargePercent | ( |  | self ) |

Retrieves the current charge level of the battery normalised to percent.

Returns:
  the current charge level normalised to percent

Solid.Battery.ChargeState chargeState | ( |  | self ) |

Retrieves the current charge state of the battery. It can be in a stable state (no charge), charging or discharging.

Returns:
  the current battery charge state

See also:
  Solid.Battery.ChargeState

bool isPlugged | ( |  | self ) |

Indicates if this battery is plugged.

Returns:
  true if the battery is plugged, false otherwise

bool isRechargeable | ( |  | self ) |

Indicates if the battery is rechargeable.

Returns:
  true if the battery is rechargeable, false otherwise (one time usage)

Solid.Battery.BatteryType type | ( |  | self ) |

Retrieves the type of device holding this battery.

Returns:
  the type of device holding this battery

See also:
  Solid.Battery.BatteryType

## Static Method Documentation

Solid.DeviceInterface.Type deviceInterfaceType | ( |  | ) |

Get the Solid.DeviceInterface.Type of the Battery device interface.

Returns:
  the Battery device interface type

See also:
  Solid.DeviceInterface.Type

## Enumeration Documentation

BatteryType

This enum type defines the type of the device holding the battery

- PdaBattery : A battery in a Personal Digital Assistant - UpsBattery : A battery in an Uninterruptible Power Supply - PrimaryBattery : A primary battery for the system (for example laptop battery) - MouseBattery : A battery in a mouse - KeyboardBattery : A battery in a keyboard - KeyboardMouseBattery : A battery in a combined keyboard and mouse - CameraBattery : A battery in a camera - PhoneBattery : A battery in a phone - MonitorBattery : A battery in a monitor - UnknownBattery : A battery in an unknown device

Enumerator:

  UnknownBattery |
  PdaBattery |
  UpsBattery |
  PrimaryBattery |
  MouseBattery |
  KeyboardBattery |
  KeyboardMouseBattery |
  CameraBattery |
  PhoneBattery |
  MonitorBattery |

ChargeState

This enum type defines charge state of a battery

- NoCharge : Battery charge is stable, not charging or discharging or the state is Unknown - Charging : Battery is charging - Discharging : Battery is discharging

Enumerator:

  NoCharge |
  Charging |
  Discharging |