Skip to content

Commit

Permalink
Set percent unit for battery level so that history displays properly;…
Browse files Browse the repository at this point in the history
… edited variable name for consistency (#10932)
  • Loading branch information
nbougues authored and fabaff committed Dec 4, 2017
1 parent 17f3cf0 commit 19a9758
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions homeassistant/components/sensor/tesla.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TeslaSensor(TeslaDevice, Entity):
def __init__(self, tesla_device, controller, sensor_type=None):
"""Initialisation of the sensor."""
self.current_value = None
self._temperature_units = None
self._unit = None
self.last_changed_time = None
self.type = sensor_type
super().__init__(tesla_device, controller)
Expand All @@ -59,7 +59,7 @@ def state(self):
@property
def unit_of_measurement(self):
"""Return the unit_of_measurement of the device."""
return self._temperature_units
return self._unit

def update(self):
"""Update the state from the sensor."""
Expand All @@ -74,8 +74,9 @@ def update(self):
tesla_temp_units = self.tesla_device.measurement

if tesla_temp_units == 'F':
self._temperature_units = TEMP_FAHRENHEIT
self._unit = TEMP_FAHRENHEIT
else:
self._temperature_units = TEMP_CELSIUS
self._unit = TEMP_CELSIUS
else:
self.current_value = self.tesla_device.battery_level()
self._unit = "%"

0 comments on commit 19a9758

Please sign in to comment.