mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Migrate to voluptuous (#3276)
This commit is contained in:
parent
d20b4c17a2
commit
ab826eef0d
@ -8,15 +8,28 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
from urllib.error import URLError
|
from urllib.error import URLError
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, STATE_OFF,
|
STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, STATE_OFF,
|
||||||
ClimateDevice)
|
ClimateDevice, PLATFORM_SCHEMA)
|
||||||
from homeassistant.const import CONF_HOST, TEMP_FAHRENHEIT, ATTR_TEMPERATURE
|
from homeassistant.const import CONF_HOST, TEMP_FAHRENHEIT, ATTR_TEMPERATURE
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['radiotherm==1.2']
|
REQUIREMENTS = ['radiotherm==1.2']
|
||||||
HOLD_TEMP = 'hold_temp'
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Setup the Radio Thermostat."""
|
"""Setup the Radio Thermostat."""
|
||||||
@ -29,10 +42,10 @@ 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 False
|
return False
|
||||||
|
|
||||||
hold_temp = config.get(HOLD_TEMP, False)
|
hold_temp = config.get(CONF_HOLD_TEMP)
|
||||||
tstats = []
|
tstats = []
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
@ -75,8 +88,8 @@ class RadioThermostat(ClimateDevice):
|
|||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the device specific state attributes."""
|
"""Return the device specific state attributes."""
|
||||||
return {
|
return {
|
||||||
"fan": self.device.fmode['human'],
|
ATTR_FAN: self.device.fmode['human'],
|
||||||
"mode": self.device.tmode['human']
|
ATTR_MODE: self.device.tmode['human']
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -124,8 +137,11 @@ class RadioThermostat(ClimateDevice):
|
|||||||
def set_time(self):
|
def set_time(self):
|
||||||
"""Set device time."""
|
"""Set device time."""
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
self.device.time = {'day': now.weekday(),
|
self.device.time = {
|
||||||
'hour': now.hour, 'minute': now.minute}
|
'day': now.weekday(),
|
||||||
|
'hour': now.hour,
|
||||||
|
'minute': now.minute
|
||||||
|
}
|
||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode):
|
||||||
"""Set operation mode (auto, cool, heat, off)."""
|
"""Set operation mode (auto, cool, heat, off)."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user