Skip to content

Commit

Permalink
Migrate to voluptuous (home-assistant#3276)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabaff authored Sep 11, 2016
1 parent d20b4c1 commit ab826ee
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions homeassistant/components/climate/radiotherm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@
import logging
from urllib.error import URLError

import voluptuous as vol

from homeassistant.components.climate import (
STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, STATE_OFF,
ClimateDevice)
ClimateDevice, PLATFORM_SCHEMA)
from homeassistant.const import CONF_HOST, TEMP_FAHRENHEIT, ATTR_TEMPERATURE
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['radiotherm==1.2']
HOLD_TEMP = 'hold_temp'

_LOGGER = logging.getLogger(__name__)

ATTR_FAN = 'fan'
ATTR_MODE = 'mode'

CONF_HOLD_TEMP = 'hold_temp'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_HOST): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_HOLD_TEMP, default=False): cv.boolean,
})


def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the Radio Thermostat."""
Expand All @@ -29,10 +42,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
hosts.append(radiotherm.discover.discover_address())

if hosts is None:
_LOGGER.error("No radiotherm thermostats detected.")
_LOGGER.error("No Radiotherm Thermostats detected")
return False

hold_temp = config.get(HOLD_TEMP, False)
hold_temp = config.get(CONF_HOLD_TEMP)
tstats = []

for host in hosts:
Expand Down Expand Up @@ -75,8 +88,8 @@ def unit_of_measurement(self):
def device_state_attributes(self):
"""Return the device specific state attributes."""
return {
"fan": self.device.fmode['human'],
"mode": self.device.tmode['human']
ATTR_FAN: self.device.fmode['human'],
ATTR_MODE: self.device.tmode['human']
}

@property
Expand Down Expand Up @@ -124,8 +137,11 @@ def set_temperature(self, **kwargs):
def set_time(self):
"""Set device time."""
now = datetime.datetime.now()
self.device.time = {'day': now.weekday(),
'hour': now.hour, 'minute': now.minute}
self.device.time = {
'day': now.weekday(),
'hour': now.hour,
'minute': now.minute
}

def set_operation_mode(self, operation_mode):
"""Set operation mode (auto, cool, heat, off)."""
Expand Down

0 comments on commit ab826ee

Please sign in to comment.