Battery Class Reference
from PyKDE5.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, FullyCharged } |
Technology | { UnknownTechnology, LithiumIon, LithiumPolymer, LithiumIronPhosphate, LeadAcid, NickelCadmium, NickelMetalHydride } |
Signals | |
capacityChanged (int value, QString udi) | |
chargePercentChanged (int value, QString udi) | |
chargeStateChanged (int newState, QString udi) | |
energyChanged (float energy, QString udi) | |
energyRateChanged (float energyRate, QString udi) | |
powerSupplyStateChanged (bool newState, QString udi) | |
presentStateChanged (bool newState, QString udi) | |
temperatureChanged (float temperature, QString udi) | |
timeToEmptyChanged (long time, QString udi) | |
timeToFullChanged (long time, QString udi) | |
voltageChanged (float voltage, QString udi) | |
Methods | |
__init__ (self, QObject backendObject) | |
int | capacity (self) |
int | chargePercent (self) |
Solid::Battery::ChargeState | chargeState (self) |
float | energy (self) |
float | energyRate (self) |
bool | isPlugged (self) |
bool | isPowerSupply (self) |
bool | isPresent (self) |
bool | isRecalled (self) |
bool | isRechargeable (self) |
QString | recallUrl (self) |
QString | recallVendor (self) |
QString | serial (self) |
Solid::Battery::Technology | technology (self) |
float | temperature (self) |
long | timeToEmpty (self) |
long | timeToFull (self) |
Solid::Battery::BatteryType | type (self) |
float | voltage (self) |
Static Methods | |
Solid::DeviceInterface::Type | deviceInterfaceType () |
Signal Documentation
capacityChanged | ( | int | value, | |
QString | udi | |||
) |
This signal is emitted when the capacity of this battery has changed.
- Parameters:
-
value the new capacity of the battery udi the UDI of the battery with the new capacity
- Since:
- 4.11
- Signal syntax:
QObject.connect(source, SIGNAL("capacityChanged(int, const QString&)"), target_slot)
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)
energyChanged | ( | float | energy, | |
QString | udi | |||
) |
This signal is emitted when the energy value of this battery has changed.
- Parameters:
-
energy the new energy value of the battery udi the UDI of the battery with the new charge percent
- Signal syntax:
QObject.connect(source, SIGNAL("energyChanged(double, const QString&)"), target_slot)
energyRateChanged | ( | float | energyRate, | |
QString | udi | |||
) |
This signal is emitted when the energy rate value of this battery has changed.
If positive, the source is being discharged, if negative it's being charged.
- Parameters:
-
energyRate the new energy rate value of the battery udi the UDI of the battery with the new charge percent
- Signal syntax:
QObject.connect(source, SIGNAL("energyRateChanged(double, const QString&)"), target_slot)
powerSupplyStateChanged | ( | bool | newState, | |
QString | udi | |||
) |
This signal is emitted when the power supply state of the battery changes.
- Parameters:
-
newState the new power supply state, type is boolean udi the UDI of the battery with the new power supply state
- Since:
- 4.11
- Signal syntax:
QObject.connect(source, SIGNAL("powerSupplyStateChanged(bool, const QString&)"), target_slot)
presentStateChanged | ( | 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 thew new plugging state
- Signal syntax:
QObject.connect(source, SIGNAL("presentStateChanged(bool, const QString&)"), target_slot)
temperatureChanged | ( | float | temperature, | |
QString | udi | |||
) |
This signal is emitted when the battery temperature has changed.
- Parameters:
-
temperature the new temperature of the battery in degrees Celsius udi the UDI of the battery with the new temperature
- Since:
- 5.0
- Signal syntax:
QObject.connect(source, SIGNAL("temperatureChanged(double, const QString&)"), target_slot)
timeToEmptyChanged | ( | long | time, | |
QString | udi | |||
) |
This signal is emitted when the time until the battery is empty has changed.
- Parameters:
-
time the new remaining time udi the UDI of the battery with the new remaining time
- Since:
- 5.0
- Signal syntax:
QObject.connect(source, SIGNAL("timeToEmptyChanged(qlonglong, const QString&)"), target_slot)
timeToFullChanged | ( | long | time, | |
QString | udi | |||
) |
This signal is emitted when the time until the battery is full has changed.
- Parameters:
-
time the new remaining time udi the UDI of the battery with the new remaining time
- Since:
- 5.0
- Signal syntax:
QObject.connect(source, SIGNAL("timeToFullChanged(qlonglong, const QString&)"), target_slot)
voltageChanged | ( | float | voltage, | |
QString | udi | |||
) |
This signal is emitted when the voltage in the cell has changed.
- Parameters:
-
voltage the new voltage of the cell udi the UDI of the battery with the new voltage
- Since:
- 5.0
- Signal syntax:
QObject.connect(source, SIGNAL("voltageChanged(double, 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 capacity | ( | self ) |
Retrieves the battery capacity normalised to percent, meaning how much energy can it hold compared to what it is designed to. The capacity of the battery will reduce with age. A capacity value less than 75% is usually a sign that you should renew your battery.
- Since:
- 4.11
- Returns:
- the battery capacity normalised to percent
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
float energy | ( | self ) |
Amount of energy (measured in Wh) currently available in the power source.
- Returns:
- amount of battery energy in Wh
float energyRate | ( | self ) |
Amount of energy being drained from the source, measured in W. If positive, the source is being discharged, if negative it's being charged.
- Returns:
- battery rate in Watts
bool isPlugged | ( | self ) |
Indicates if this battery is currently present in its bay.
- Deprecated:
- since Solid 5.0. Use isPresent instead.
bool isPowerSupply | ( | self ) |
Indicates if the battery is powering the machine.
- Returns:
- true if the battery is powersupply, false otherwise
bool isPresent | ( | self ) |
Indicates if this battery is currently present in its bay.
- Returns:
- true if the battery is present, false otherwise
bool isRecalled | ( | self ) |
The battery may have been recalled by the vendor due to a suspected fault.
- Returns:
- true if the battery has been recalled, false otherwise
- Since:
- 5.0
bool isRechargeable | ( | self ) |
Indicates if the battery is rechargeable.
- Returns:
- true if the battery is rechargeable, false otherwise (one time usage)
QString recallUrl | ( | self ) |
The website URL of the vendor that has recalled the battery.
- Returns:
- the website URL of the vendor that has recalled the battery
- Since:
- 5.0
QString recallVendor | ( | self ) |
The vendor that has recalled the battery.
- Returns:
- the vendor name that has recalled the battery
- Since:
- 5.0
QString serial | ( | self ) |
The serial number of the battery
- Returns:
- the serial number of the battery
- Since:
- 5.0
Solid::Battery::Technology technology | ( | self ) |
Retrieves the technology used to manufacture the battery.
- Returns:
- the battery technology
- See also:
- Solid.Battery.Technology
float temperature | ( | self ) |
The temperature of the battery in degrees Celsius.
- Returns:
- the battery temperature in degrees Celsius
- Since:
- 5.0
long timeToEmpty | ( | self ) |
Time (in seconds) until the battery is empty.
- Returns:
- time until the battery is empty
- Since:
- 5.0
long timeToFull | ( | self ) |
Time (in seconds) until the battery is full.
- Returns:
- time until the battery is full
- Since:
- 5.0
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
float voltage | ( | self ) |
Voltage in the Cell or being recorded by the meter.
- Returns:
- voltage in Volts
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 - FullyCharged: The battery is fully charged; a battery not neccessarily charges up to 100%
- Enumerator:
-
NoCharge Charging Discharging FullyCharged
Technology |
Technology used in the battery
0: Unknown 1: Lithium ion 2: Lithium polymer 3: Lithium iron phosphate 4: Lead acid 5: Nickel cadmium 6: Nickel metal hydride
- Enumerator:
-
UnknownTechnology = 0 LithiumIon LithiumPolymer LithiumIronPhosphate LeadAcid NickelCadmium NickelMetalHydride