diff --git a/custom_components/badnest/climate.py b/custom_components/badnest/climate.py index e21f22d..d2b62d3 100644 --- a/custom_components/badnest/climate.py +++ b/custom_components/badnest/climate.py @@ -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 diff --git a/custom_components/badnest/sensor.py b/custom_components/badnest/sensor.py index 5638e78..4b9b562 100644 --- a/custom_components/badnest/sensor.py +++ b/custom_components/badnest/sensor.py @@ -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 }