diff --git a/homeassistant/components/demo.py b/homeassistant/components/demo.py
index 3db878b7ae8..4076ca63159 100644
--- a/homeassistant/components/demo.py
+++ b/homeassistant/components/demo.py
@@ -10,12 +10,14 @@ import homeassistant as ha
import homeassistant.loader as loader
from homeassistant.helpers import extract_entity_ids
from homeassistant.const import (
- SERVICE_TURN_ON, SERVICE_TURN_OFF, STATE_ON, STATE_OFF,
- ATTR_ENTITY_PICTURE, ATTR_ENTITY_ID, CONF_LATITUDE, CONF_LONGITUDE)
+ SERVICE_TURN_ON, SERVICE_TURN_OFF,
+ STATE_ON, STATE_OFF, TEMP_CELCIUS,
+ ATTR_ENTITY_PICTURE, ATTR_ENTITY_ID, ATTR_UNIT_OF_MEASUREMENT,
+ CONF_LATITUDE, CONF_LONGITUDE)
from homeassistant.components.light import (
ATTR_XY_COLOR, ATTR_RGB_COLOR, ATTR_BRIGHTNESS, GROUP_NAME_ALL_LIGHTS)
from homeassistant.components.thermostat import (
- ATTR_TARGET_TEMPERATURE, ATTR_AWAY_MODE)
+ ATTR_CURRENT_TEMPERATURE, ATTR_AWAY_MODE)
from homeassistant.util import split_entity_id, color_RGB_to_xy
DOMAIN = "demo"
@@ -161,10 +163,10 @@ def setup(hass, config):
})
# Nest demo
- hass.states.set("thermostat.Nest", "15.6",
+ hass.states.set("thermostat.Nest", "23",
{
- 'unit_of_measurement': '°C',
- ATTR_TARGET_TEMPERATURE: '23.6',
+ ATTR_UNIT_OF_MEASUREMENT: TEMP_CELCIUS,
+ ATTR_CURRENT_TEMPERATURE: '18',
ATTR_AWAY_MODE: STATE_OFF
})
diff --git a/homeassistant/components/http/frontend.py b/homeassistant/components/http/frontend.py
index 7908edf33f1..ae20b77249b 100644
--- a/homeassistant/components/http/frontend.py
+++ b/homeassistant/components/http/frontend.py
@@ -1,2 +1,2 @@
""" DO NOT MODIFY. Auto-generated by build_frontend script """
-VERSION = "7dec66ac57c858565b26db16e150a3b5"
+VERSION = "7484b7aecbe15593d924b47daf4a89df"
diff --git a/homeassistant/components/http/www_static/frontend.html b/homeassistant/components/http/www_static/frontend.html
index 0d3aa902643..d2870ef5ba4 100644
--- a/homeassistant/components/http/www_static/frontend.html
+++ b/homeassistant/components/http/www_static/frontend.html
@@ -50,18 +50,16 @@ if(this.removeAttribute(a),d)return j(this,a,c);var e=c,f=m(this,a,e);return j(t
{{label}}
++
{{stateObj.entityDisplay}}
{{stateObj.relativeLastChanged}}
{{stateObj.stateDisplay}}
{{label}}
- {{stateObj.stateDisplay}}
-
- -> {{stateObj.attributes.target_temperature}} {{stateObj.attributes.unit_of_measurement}}
-
{{heading}}
{{event.event}}
diff --git a/homeassistant/components/http/www_static/polymer/cards/state-card-thermostat.html b/homeassistant/components/http/www_static/polymer/cards/state-card-thermostat.html
index d8beb2f344f..7642e1216e5 100644
--- a/homeassistant/components/http/www_static/polymer/cards/state-card-thermostat.html
+++ b/homeassistant/components/http/www_static/polymer/cards/state-card-thermostat.html
@@ -8,28 +8,30 @@
- {{stateObj.stateDisplay}}
-
- -> {{stateObj.attributes.target_temperature}} {{stateObj.attributes.unit_of_measurement}}
-
+
+ {{stateObj.stateDisplay}}
+
-
diff --git a/homeassistant/components/http/www_static/polymer/components/domain-icon.html b/homeassistant/components/http/www_static/polymer/components/domain-icon.html
index 18d06e31911..a35bbfaacaa 100644
--- a/homeassistant/components/http/www_static/polymer/components/domain-icon.html
+++ b/homeassistant/components/http/www_static/polymer/components/domain-icon.html
@@ -57,10 +57,7 @@
return "announcement";
case "thermostat":
- return "homeassistant:nest-thermostat";
-
- case "smokedetector":
- return "homeassistant:nest-protect";
+ return "homeassistant:thermostat";
default:
return "bookmark-outline";
diff --git a/homeassistant/components/http/www_static/polymer/resources/home-assistant-icons.html b/homeassistant/components/http/www_static/polymer/resources/home-assistant-icons.html
index 69f93114fa8..b5180795d70 100644
--- a/homeassistant/components/http/www_static/polymer/resources/home-assistant-icons.html
+++ b/homeassistant/components/http/www_static/polymer/resources/home-assistant-icons.html
@@ -1,14 +1,13 @@
-
+
diff --git a/homeassistant/components/thermostat/__init__.py b/homeassistant/components/thermostat/__init__.py
index 3f2b186a95d..825f9abb51a 100644
--- a/homeassistant/components/thermostat/__init__.py
+++ b/homeassistant/components/thermostat/__init__.py
@@ -26,7 +26,7 @@ SERVICE_TURN_AWAY_MODE_ON = "turn_away_mode_on"
SERVICE_TURN_AWAY_MODE_OFF = "turn_away_mode_off"
SERVICE_SET_TEMPERATURE = "set_temperature"
-ATTR_TARGET_TEMPERATURE = "target_temperature"
+ATTR_CURRENT_TEMPERATURE = "current_temperature"
ATTR_AWAY_MODE = "away_mode"
_LOGGER = logging.getLogger(__name__)
@@ -59,6 +59,8 @@ def set_temperature(hass, temperature, entity_id=None):
def setup(hass, config):
""" Setup thermostats. """
+ logger = logging.getLogger(__name__)
+
thermostats = platform_devices_from_config(
config, DOMAIN, hass, ENTITY_ID_FORMAT, _LOGGER)
@@ -69,7 +71,7 @@ def setup(hass, config):
@util.Throttle(MIN_TIME_BETWEEN_SCANS)
def update_state(now):
""" Update thermostat state. """
- logging.getLogger(__name__).info("Update nest state")
+ logger.info("Updating nest state")
for thermostat in thermostats.values():
thermostat.update_ha_state(hass, True)
@@ -126,6 +128,59 @@ class ThermostatDevice(Device):
# pylint: disable=no-self-use
+ @property
+ def state(self):
+ """ Returns the current state. """
+ return self.target_temperature
+
+ @property
+ def unit_of_measurement(self):
+ """ Returns the unit of measurement. """
+ return ""
+
+ @property
+ def device_state_attributes(self):
+ """ Returns device specific state attributes. """
+ return None
+
+ @property
+ def state_attributes(self):
+ """ Returns optional state attributes. """
+ data = {
+ ATTR_UNIT_OF_MEASUREMENT: self.unit_of_measurement,
+ ATTR_CURRENT_TEMPERATURE: self.current_temperature
+ }
+
+ is_away = self.is_away_mode_on
+
+ if is_away is not None:
+ data[ATTR_AWAY_MODE] = STATE_ON if is_away else STATE_OFF
+
+ device_attr = self.device_state_attributes
+
+ if device_attr is not None:
+ data.update(device_attr)
+
+ return data
+
+ @property
+ def current_temperature(self):
+ """ Returns the current temperature. """
+ raise NotImplementedError
+
+ @property
+ def target_temperature(self):
+ """ Returns the temperature we try to reach. """
+ raise NotImplementedError
+
+ @property
+ def is_away_mode_on(self):
+ """
+ Returns if away mode is on.
+ Return None if no away mode available.
+ """
+ return None
+
def set_temperate(self, temperature):
""" Set new target temperature. """
pass
@@ -137,33 +192,3 @@ class ThermostatDevice(Device):
def turn_away_mode_off(self):
""" Turns away mode off. """
pass
-
- def is_away_mode_on(self):
- """ Returns if away mode is on. """
- return False
-
- def get_target_temperature(self):
- """ Returns the temperature we try to reach. """
- return None
-
- def get_unit_of_measurement(self):
- """ Returns the unit of measurement. """
- return ""
-
- def get_device_state_attributes(self):
- """ Returns device specific state attributes. """
- return {}
-
- def get_state_attributes(self):
- """ Returns optional state attributes. """
- data = {
- ATTR_UNIT_OF_MEASUREMENT: self.get_unit_of_measurement(),
- ATTR_AWAY_MODE: STATE_ON if self.is_away_mode_on() else STATE_OFF
- }
-
- target_temp = self.get_target_temperature()
-
- if target_temp is not None:
- data[ATTR_TARGET_TEMPERATURE] = target_temp
-
- return data
diff --git a/homeassistant/components/thermostat/nest.py b/homeassistant/components/thermostat/nest.py
index 2357053d3d0..3e43ee49ddc 100644
--- a/homeassistant/components/thermostat/nest.py
+++ b/homeassistant/components/thermostat/nest.py
@@ -29,9 +29,7 @@ def get_devices(hass, config):
return []
- thermostat = NestThermostat(username, password)
-
- return [thermostat]
+ return [NestThermostat(username, password)]
class NestThermostat(ThermostatDevice):
@@ -41,17 +39,40 @@ class NestThermostat(ThermostatDevice):
# pylint: disable=no-name-in-module, import-error
import homeassistant.external.pynest.nest as pynest
- self.nest = pynest.Nest(username, password, None)
+ self.nest = pynest.Nest(username, password)
self.nest.login()
+ self.update()
- def get_name(self):
+ @property
+ def name(self):
""" Returns the name of the nest, if any. """
return "Nest" # TODO Possible to get actual name from Nest device?
- def get_state(self):
+ @property
+ def unit_of_measurement(self):
+ """ Returns the unit of measurement. """
+ return TEMP_FAHRENHEIT if self.nest.units == 'F' else TEMP_CELCIUS
+
+ @property
+ def device_state_attributes(self):
+ """ Returns device specific state attributes. """
+ return None
+
+ @property
+ def current_temperature(self):
""" Returns the current temperature. """
return self.nest.get_curtemp()
+ @property
+ def target_temperature(self):
+ """ Returns the temperature we try to reach. """
+ return self.nest.get_tartemp()
+
+ @property
+ def is_away_mode_on(self):
+ """ Returns if away mode is on. """
+ return self.nest.is_away()
+
def set_temperature(self, temperature):
""" Set new target temperature """
self.nest.set_temperature(temperature)
@@ -64,18 +85,6 @@ class NestThermostat(ThermostatDevice):
""" Turns away off. """
self.nest.set_away("here")
- def is_away_mode_on(self):
- """ Returns if away mode is on. """
- return self.nest.is_away()
-
- def get_target_temperature(self):
- """ Returns the temperature we try to reach. """
- return self.nest.get_tartemp()
-
- def get_unit_of_measurement(self):
- """ Returns the unit of measurement. """
- return TEMP_FAHRENHEIT if self.nest.units == 'F' else TEMP_CELCIUS
-
- def get_device_state_attributes(self):
- """ Returns device specific state attributes. """
- return {}
+ def update(self):
+ """ Update nest. """
+ self.nest.get_status()