implement away mode
This commit is contained in:
parent
b3227e491b
commit
c703c89dbd
1 changed files with 33 additions and 5 deletions
|
@ -6,8 +6,9 @@ Adds support for Honeywell Round Connected and Honeywell Evohome thermostats.
|
|||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/thermostat.honeywell/
|
||||
"""
|
||||
import socket
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from homeassistant.components.thermostat import ThermostatDevice
|
||||
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD, TEMP_CELCIUS)
|
||||
|
||||
|
@ -15,6 +16,7 @@ REQUIREMENTS = ['evohomeclient==0.2.4']
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_AWAY_TEMP = "away_temperature"
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
@ -23,20 +25,25 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
username = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
|
||||
try:
|
||||
away_temp = float(config.get(CONF_AWAY_TEMP,16))
|
||||
except ValueError:
|
||||
_LOGGER.error("value entered for item {} should convert to a number"
|
||||
.format(CONF_AWAY_TEMP))
|
||||
if username is None or password is None:
|
||||
_LOGGER.error("Missing required configuration items %s or %s",
|
||||
CONF_USERNAME, CONF_PASSWORD)
|
||||
return False
|
||||
|
||||
evo_api = EvohomeClient(username, password)
|
||||
|
||||
try:
|
||||
zones = evo_api.temperatures(force_refresh=True)
|
||||
for i, zone in enumerate(zones):
|
||||
add_devices([RoundThermostat(evo_api, zone['id'], i == 0)])
|
||||
add_devices([RoundThermostat(evo_api, zone['id'], i == 0,away_temp)])
|
||||
except socket.error:
|
||||
_LOGGER.error(
|
||||
"Connection error logging into the honeywell evohome web service"
|
||||
"Connection error logging into the honeywell evohome web service"
|
||||
)
|
||||
return False
|
||||
|
||||
|
@ -44,7 +51,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class RoundThermostat(ThermostatDevice):
|
||||
""" Represents a Honeywell Round Connected thermostat. """
|
||||
|
||||
def __init__(self, device, zone_id, master):
|
||||
def __init__(self, device, zone_id, master, away_temp):
|
||||
self.device = device
|
||||
self._current_temperature = None
|
||||
self._target_temperature = None
|
||||
|
@ -52,6 +59,8 @@ class RoundThermostat(ThermostatDevice):
|
|||
self._id = zone_id
|
||||
self._master = master
|
||||
self._is_dhw = False
|
||||
self._away_temp = away_temp
|
||||
self._away = False
|
||||
self.update()
|
||||
|
||||
@property
|
||||
|
@ -80,6 +89,25 @@ class RoundThermostat(ThermostatDevice):
|
|||
""" Set new target temperature """
|
||||
self.device.set_temperature(self._name, temperature)
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
""" Returns if away mode is on. """
|
||||
return self._away
|
||||
|
||||
def turn_away_mode_on(self):
|
||||
""" Turns away on.
|
||||
Evohome does have a proprietary away mode, but it doesn't really work
|
||||
the way it should. For example: If you set a temperature manually
|
||||
it doesn't get overwritten when away mode is switched on.
|
||||
"""
|
||||
self._away = True
|
||||
self.device.set_temperature(self._name, self._away_temp)
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
""" Turns away off. """
|
||||
self._away = False
|
||||
self.device.cancel_temp_override(self._name)
|
||||
|
||||
def update(self):
|
||||
try:
|
||||
# Only refresh if this is the "master" device,
|
||||
|
|
Loading…
Add table
Reference in a new issue