mirror of
https://github.com/USA-RedDragon/badnest.git
synced 2025-02-07 12:10:26 +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
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
"""Return the current temperature."""
|
"""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
|
@property
|
||||||
def current_humidity(self):
|
def current_humidity(self):
|
||||||
@ -175,7 +175,7 @@ class NestClimate(ClimateDevice):
|
|||||||
!= NEST_MODE_HEAT_COOL \
|
!= NEST_MODE_HEAT_COOL \
|
||||||
and not self.device.device_data[self.device_id]['eco']:
|
and not self.device.device_data[self.device_id]['eco']:
|
||||||
return \
|
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
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -185,8 +185,8 @@ class NestClimate(ClimateDevice):
|
|||||||
== NEST_MODE_HEAT_COOL \
|
== NEST_MODE_HEAT_COOL \
|
||||||
and not self.device.device_data[self.device_id]['eco']:
|
and not self.device.device_data[self.device_id]['eco']:
|
||||||
return \
|
return \
|
||||||
self.device. \
|
round(round(self.device. \
|
||||||
device_data[self.device_id]['target_temperature_high']
|
device_data[self.device_id]['target_temperature_high']*2)/2,1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -196,8 +196,8 @@ class NestClimate(ClimateDevice):
|
|||||||
== NEST_MODE_HEAT_COOL \
|
== NEST_MODE_HEAT_COOL \
|
||||||
and not self.device.device_data[self.device_id]['eco']:
|
and not self.device.device_data[self.device_id]['eco']:
|
||||||
return \
|
return \
|
||||||
self.device. \
|
round(round(self.device. \
|
||||||
device_data[self.device_id]['target_temperature_low']
|
device_data[self.device_id]['target_temperature_low']*2)/2,1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -67,7 +67,7 @@ class NestTemperatureSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the sensor."""
|
"""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
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
@ -86,9 +86,16 @@ class NestTemperatureSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""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 {
|
return {
|
||||||
ATTR_BATTERY_LEVEL:
|
ATTR_BATTERY_LEVEL: resBattery
|
||||||
self.device.device_data[self.device_id]['battery_level']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user