Use logger the same as other platforms do

This commit is contained in:
Fabian Affolter 2015-10-24 00:29:47 +02:00
parent f2fda2914a
commit 1e0e48fcd7

View File

@ -15,16 +15,14 @@ from homeassistant.components.thermostat import (ThermostatDevice, STATE_COOL,
from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT) from homeassistant.const import (CONF_HOST, TEMP_FAHRENHEIT)
REQUIREMENTS = ['radiotherm==1.2'] REQUIREMENTS = ['radiotherm==1.2']
HOLD_TEMP = 'hold_temp' HOLD_TEMP = 'hold_temp'
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Radio Thermostat. """ """ Sets up the Radio Thermostat. """
import radiotherm import radiotherm
logger = logging.getLogger(__name__)
hosts = [] hosts = []
if CONF_HOST in config: if CONF_HOST in config:
hosts = config[CONF_HOST] hosts = config[CONF_HOST]
@ -32,7 +30,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
hosts.append(radiotherm.discover.discover_address()) hosts.append(radiotherm.discover.discover_address())
if hosts is None: if hosts is None:
logger.error("no radiotherm thermostats detected") _LOGGER.error("No radiotherm thermostats detected")
return return
hold_temp = config.get(HOLD_TEMP, False) hold_temp = config.get(HOLD_TEMP, False)
@ -43,8 +41,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
tstat = radiotherm.get_thermostat(host) tstat = radiotherm.get_thermostat(host)
tstats.append(RadioThermostat(tstat, hold_temp)) tstats.append(RadioThermostat(tstat, hold_temp))
except (URLError, OSError): except (URLError, OSError):
logger.exception( _LOGGER.exception("Unable to connect to Radio Thermostat: %s",
"Unable to connect to Radio Thermostat: %s", host) host)
add_devices(tstats) add_devices(tstats)