Nest fixes (#5011)

* Updated Nest API to have logical names

* Fix NoneType not having replace method in NestSensor constructor

* Move name setting to constructor, in case zone.name causes IO.

* normalize is_online to online

* Updated python-nest API

* push is_* helpers down to python-nest, and use inheritence to implement rather than checking class name

* Update python-nest
This commit is contained in:
Josh Nichols 2016-12-22 14:22:07 -05:00 committed by Pascal Vizeli
parent 5e1e5992af
commit 6c50f53696
6 changed files with 31 additions and 55 deletions

View file

@ -9,7 +9,8 @@ import logging
import voluptuous as vol
from homeassistant.components.nest import DATA_NEST, DOMAIN
from homeassistant.components.nest import (
DATA_NEST, DOMAIN)
from homeassistant.helpers.entity import Entity
from homeassistant.const import (
TEMP_CELSIUS, TEMP_FAHRENHEIT, CONF_PLATFORM,
@ -93,31 +94,21 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_LOGGER.error(wstr)
all_sensors = []
for structure, device in chain(nest.devices(), nest.protect_devices()):
for structure, device in chain(nest.thermostats(), nest.smoke_co_alarms()):
sensors = [NestBasicSensor(structure, device, variable)
for variable in conf
if variable in SENSOR_TYPES and is_thermostat(device)]
if variable in SENSOR_TYPES and device.is_thermostat]
sensors += [NestTempSensor(structure, device, variable)
for variable in conf
if variable in SENSOR_TEMP_TYPES and is_thermostat(device)]
if variable in SENSOR_TEMP_TYPES and device.is_thermostat]
sensors += [NestProtectSensor(structure, device, variable)
for variable in conf
if variable in PROTECT_VARS and is_protect(device)]
if variable in PROTECT_VARS and device.is_smoke_co_alarm]
all_sensors.extend(sensors)
add_devices(all_sensors, True)
def is_thermostat(device):
"""Target devices that are Nest Thermostats."""
return bool(device.__class__.__name__ == 'Device')
def is_protect(device):
"""Target devices that are Nest Protect Smoke Alarms."""
return bool(device.__class__.__name__ == 'ProtectDevice')
class NestSensor(Entity):
"""Representation of a Nest sensor."""