mirror of
https://github.com/USA-RedDragon/badnest.git
synced 2025-01-31 08:00:27 +00:00
Make sensor return battery % and rounding temps to match nest UI
This commit is contained in:
parent
7ab48d968e
commit
58834ccdfe
@ -146,7 +146,7 @@ class NestClimate(ClimateDevice):
|
||||
@property
|
||||
def current_temperature(self):
|
||||
"""Return the current temperature."""
|
||||
return self.device.device_data[self.device_id]['current_temperature']
|
||||
return round(round(self.device.device_data[self.device_id]['current_temperature']*2)/2,1)
|
||||
|
||||
@property
|
||||
def current_humidity(self):
|
||||
@ -175,7 +175,7 @@ class NestClimate(ClimateDevice):
|
||||
!= NEST_MODE_HEAT_COOL \
|
||||
and not self.device.device_data[self.device_id]['eco']:
|
||||
return \
|
||||
self.device.device_data[self.device_id]['target_temperature']
|
||||
round(round(self.device.device_data[self.device_id]['target_temperature']*2)/2,1)
|
||||
return None
|
||||
|
||||
@property
|
||||
@ -185,8 +185,8 @@ class NestClimate(ClimateDevice):
|
||||
== NEST_MODE_HEAT_COOL \
|
||||
and not self.device.device_data[self.device_id]['eco']:
|
||||
return \
|
||||
self.device. \
|
||||
device_data[self.device_id]['target_temperature_high']
|
||||
round(round(self.device. \
|
||||
device_data[self.device_id]['target_temperature_high']*2)/2,1)
|
||||
return None
|
||||
|
||||
@property
|
||||
@ -196,8 +196,8 @@ class NestClimate(ClimateDevice):
|
||||
== NEST_MODE_HEAT_COOL \
|
||||
and not self.device.device_data[self.device_id]['eco']:
|
||||
return \
|
||||
self.device. \
|
||||
device_data[self.device_id]['target_temperature_low']
|
||||
round(round(self.device. \
|
||||
device_data[self.device_id]['target_temperature_low']*2)/2,1)
|
||||
return None
|
||||
|
||||
@property
|
||||
|
@ -67,7 +67,7 @@ class NestTemperatureSensor(Entity):
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self.device.device_data[self.device_id]['temperature']
|
||||
return round(round(self.device.device_data[self.device_id]['temperature']*2)/2,1)
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
@ -86,9 +86,16 @@ class NestTemperatureSensor(Entity):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
maxBattery = 4.0
|
||||
zeroBattery = 3.6
|
||||
curBattery = float(self.device.device_data[self.device_id]['battery_level'])
|
||||
resBattery = round(((curBattery - zeroBattery)/(maxBattery-zeroBattery))*100,2)
|
||||
if resBattery < 0.0:
|
||||
resBattery = 0.0
|
||||
if resBattery > 100.0:
|
||||
resBattery = 100.0
|
||||
return {
|
||||
ATTR_BATTERY_LEVEL:
|
||||
self.device.device_data[self.device_id]['battery_level']
|
||||
ATTR_BATTERY_LEVEL: resBattery
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user