diff --git a/homeassistant/components/sensor/nest.py b/homeassistant/components/sensor/nest.py index 53f767ab494..b9dde96a98c 100644 --- a/homeassistant/components/sensor/nest.py +++ b/homeassistant/components/sensor/nest.py @@ -128,13 +128,20 @@ class NestSensor(Entity): # device specific self._location = self.device.where - self._name = self.device.name_long + self._name = "{} {}".format(self.device.name_long, + self.variable.replace("_", " ")) self._state = None + self._unit = None @property def name(self): """Return the name of the nest, if any.""" - return "{} {}".format(self._name, self.variable.replace("_", " ")) + return self._name + + @property + def unit_of_measurement(self): + """Return the unit the value is expressed in.""" + return self._unit class NestBasicSensor(NestSensor): @@ -145,13 +152,10 @@ class NestBasicSensor(NestSensor): """Return the state of the sensor.""" return self._state - @property - def unit_of_measurement(self): - """Return the unit the value is expressed in.""" - return SENSOR_UNITS.get(self.variable, None) - def update(self): """Retrieve latest state.""" + self._unit = SENSOR_UNITS.get(self.variable, None) + if self.variable == 'operation_mode': self._state = getattr(self.device, "mode") else: @@ -161,14 +165,6 @@ class NestBasicSensor(NestSensor): class NestTempSensor(NestSensor): """Representation of a Nest Temperature sensor.""" - @property - def unit_of_measurement(self): - """Return the unit the value is expressed in.""" - if self.device.temperature_scale == 'C': - return TEMP_CELSIUS - else: - return TEMP_FAHRENHEIT - @property def state(self): """Return the state of the sensor.""" @@ -176,6 +172,11 @@ class NestTempSensor(NestSensor): def update(self): """Retrieve latest state.""" + if self.device.temperature_scale == 'C': + self._unit = TEMP_CELSIUS + else: + self._unit = TEMP_FAHRENHEIT + temp = getattr(self.device, self.variable) if temp is None: self._state = None