File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
custom_components/powersensor Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 11from homeassistant .components .sensor import SensorDeviceClass , SensorStateClass
2- from homeassistant .const import UnitOfPower , UnitOfElectricPotential , UnitOfEnergy
2+ from homeassistant .const import UnitOfPower , UnitOfEnergy , PERCENTAGE
33from homeassistant .core import HomeAssistant
44from homeassistant .helpers .device_registry import DeviceInfo
55
1515_config = {
1616 SensorMeasurements .Battery : {
1717 "name" : "Battery Level" ,
18- "device_class" : SensorDeviceClass .VOLTAGE ,
19- "unit" : UnitOfElectricPotential . VOLT ,
18+ "device_class" : SensorDeviceClass .BATTERY ,
19+ "unit" : PERCENTAGE ,
2020 "precision" : 2 ,
2121 'event' : 'battery_level' ,
22- 'message_key' : 'volts'
22+ 'message_key' : 'volts' ,
23+ 'callback' : lambda v : max (min (100.0 * (v - 3.2 ),100 ),0 )
2324 },
2425 SensorMeasurements .WATTS : {
2526 "name" : "Power" ,
You can’t perform that action at this time.
0 commit comments