Compile statistics for power sensors (#52299)
parent
e1797ea670
commit
6131ed09f0
|
@ -19,8 +19,11 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
DEVICE_CLASS_POWER,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
POWER_KILO_WATT,
|
||||
POWER_WATT,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, State
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
@ -33,16 +36,21 @@ DEVICE_CLASS_STATISTICS = {
|
|||
DEVICE_CLASS_BATTERY: {"mean", "min", "max"},
|
||||
DEVICE_CLASS_ENERGY: {"sum"},
|
||||
DEVICE_CLASS_HUMIDITY: {"mean", "min", "max"},
|
||||
DEVICE_CLASS_MONETARY: {"sum"},
|
||||
DEVICE_CLASS_POWER: {"mean", "min", "max"},
|
||||
DEVICE_CLASS_PRESSURE: {"mean", "min", "max"},
|
||||
DEVICE_CLASS_TEMPERATURE: {"mean", "min", "max"},
|
||||
DEVICE_CLASS_MONETARY: {"sum"},
|
||||
}
|
||||
|
||||
UNIT_CONVERSIONS = {
|
||||
DEVICE_CLASS_ENERGY: {
|
||||
ENERGY_KILO_WATT_HOUR: lambda x: x,
|
||||
ENERGY_WATT_HOUR: lambda x: x / 1000,
|
||||
}
|
||||
},
|
||||
DEVICE_CLASS_POWER: {
|
||||
POWER_WATT: lambda x: x,
|
||||
POWER_KILO_WATT: lambda x: x * 1000,
|
||||
},
|
||||
}
|
||||
|
||||
WARN_UNSUPPORTED_UNIT = set()
|
||||
|
|
Loading…
Reference in New Issue