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

pull/1857/merge
Jon Evans 2016-04-19 23:00:03 -04:00 committed by Paulus Schoutsen
parent 46274d4393
commit 9090672146
1 changed files with 4 additions and 2 deletions

View File

@ -6,7 +6,7 @@ https://home-assistant.io/components/sensor.temper/
"""
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
_LOGGER = logging.getLogger(__name__)
@ -56,7 +56,9 @@ class TemperSensor(Entity):
def update(self):
"""Retrieve latest state."""
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:
_LOGGER.error('Failed to get temperature due to insufficient '
'permissions. Try running with "sudo"')