mirror of
https://github.com/USA-RedDragon/badnest.git
synced 2025-01-18 19:20:44 +00:00
round battery percent to int
This commit is contained in:
parent
58834ccdfe
commit
c3a6d8c948
@ -89,11 +89,11 @@ class NestTemperatureSensor(Entity):
|
|||||||
maxBattery = 4.0
|
maxBattery = 4.0
|
||||||
zeroBattery = 3.6
|
zeroBattery = 3.6
|
||||||
curBattery = float(self.device.device_data[self.device_id]['battery_level'])
|
curBattery = float(self.device.device_data[self.device_id]['battery_level'])
|
||||||
resBattery = round(((curBattery - zeroBattery)/(maxBattery-zeroBattery))*100,2)
|
resBattery = round(((curBattery - zeroBattery)/(maxBattery-zeroBattery))*100)
|
||||||
if resBattery < 0.0:
|
if resBattery < 0:
|
||||||
resBattery = 0.0
|
resBattery = 0
|
||||||
if resBattery > 100.0:
|
if resBattery > 100:
|
||||||
resBattery = 100.0
|
resBattery = 100
|
||||||
return {
|
return {
|
||||||
ATTR_BATTERY_LEVEL: resBattery
|
ATTR_BATTERY_LEVEL: resBattery
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user