Pass format through to temper_device so that Fahrenheit works (#1858)

This commit is contained in:
Jon Evans 2016-04-19 23:00:03 -04:00 committed by Paulus Schoutsen
parent 46274d4393
commit 9090672146

View File

@ -6,7 +6,7 @@ https://home-assistant.io/components/sensor.temper/
""" """
import logging import logging
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME, TEMP_FAHRENHEIT
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -56,7 +56,9 @@ class TemperSensor(Entity):
def update(self): def update(self):
"""Retrieve latest state.""" """Retrieve latest state."""
try: try:
self.current_value = self.temper_device.get_temperature() format_str = ('fahrenheit' if self.temp_unit == TEMP_FAHRENHEIT
else 'celsius')
self.current_value = self.temper_device.get_temperature(format_str)
except IOError: except IOError:
_LOGGER.error('Failed to get temperature due to insufficient ' _LOGGER.error('Failed to get temperature due to insufficient '
'permissions. Try running with "sudo"') 'permissions. Try running with "sudo"')