Merge branch 'pr/579' into dev
Conflicts: requirements_all.txt
This commit is contained in:
commit
0665af7f0f
3 changed files with 105 additions and 0 deletions
|
@ -97,6 +97,7 @@ omit =
|
|||
homeassistant/components/switch/rpi_gpio.py
|
||||
homeassistant/components/switch/transmission.py
|
||||
homeassistant/components/switch/wemo.py
|
||||
homeassistant/components/thermostat/honeywell_round_connected.py
|
||||
homeassistant/components/thermostat/nest.py
|
||||
homeassistant/components/thermostat/radiotherm.py
|
||||
|
||||
|
|
101
homeassistant/components/thermostat/honeywell_round_connected.py
Normal file
101
homeassistant/components/thermostat/honeywell_round_connected.py
Normal file
|
@ -0,0 +1,101 @@
|
|||
"""
|
||||
homeassistant.components.thermostat.honeywell_round_connected
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Adds support for Honeywell Round Connected thermostats.
|
||||
"""
|
||||
import socket
|
||||
import logging
|
||||
from homeassistant.components.thermostat import ThermostatDevice
|
||||
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD, TEMP_CELCIUS)
|
||||
logger=logging.getLogger(__name__)
|
||||
|
||||
REQUIREMENTS = ['evohomeclient==0.2.3']
|
||||
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
""" Sets up the honeywel thermostat. """
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
username = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
|
||||
if username is None or password is None:
|
||||
logger.error("Missing required configuration items %s or %s",
|
||||
CONF_USERNAME, CONF_PASSWORD)
|
||||
return
|
||||
|
||||
try:
|
||||
from evohomeclient import EvohomeClient
|
||||
except ImportError:
|
||||
logger.exception(
|
||||
"Error while importing dependency evohomeclient. "
|
||||
"Did you maybe not install the python evohomeclient dependency?")
|
||||
|
||||
return
|
||||
|
||||
evo_api = EvohomeClient(username, password)
|
||||
try:
|
||||
add_devices([
|
||||
RoundThermostat(evo_api)
|
||||
])
|
||||
except socket.error:
|
||||
logger.error(
|
||||
"Connection error logging into the honeywell evohome web service"
|
||||
)
|
||||
|
||||
|
||||
class RoundThermostat(ThermostatDevice):
|
||||
""" Represents a Honeywell Round Connected thermostat. """
|
||||
|
||||
def __init__(self, device):
|
||||
self.device = device
|
||||
self._current_temperature = None
|
||||
self._target_temperature = None
|
||||
self._name = "round connected"
|
||||
self.update()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
""" Returns the name of the honeywell, if any. """
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
""" Unit of measurement this thermostat expresses itself in. """
|
||||
return TEMP_CELCIUS
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
""" Returns device specific state attributes. """
|
||||
# Move these to Thermostat Device and make them global
|
||||
return {}
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
""" Returns the current temperature. """
|
||||
return self._current_temperature
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
""" Returns the temperature we try to reach. """
|
||||
return self._target_temperature
|
||||
|
||||
def set_temperature(self, temperature):
|
||||
""" Set new target temperature """
|
||||
self.device.set_temperature(self._name, temperature)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
""" Should poll the evohome cloud service """
|
||||
return True
|
||||
|
||||
def update(self):
|
||||
try:
|
||||
# assuming I am only receiving one temperature sensor from the api..
|
||||
_device = next(self.device.temperatures(force_refresh=True))
|
||||
self._current_temperature = _device['temp']
|
||||
self._target_temperature = _device['setpoint']
|
||||
self._name = _device['name']
|
||||
except StopIteration:
|
||||
logger.error("Did not receive any temperature data from the evohomeclient api.")
|
|
@ -150,3 +150,6 @@ py-cpuinfo==0.1.6
|
|||
|
||||
# Radio Thermostat (thermostat.radiotherm)
|
||||
radiotherm==1.2
|
||||
|
||||
# Honeywell Evo Home Client
|
||||
evohomeclient==0.2.3
|
||||
|
|
Loading…
Add table
Reference in a new issue