2016-01-14 10:48:24 -07:00
|
|
|
"""
|
|
|
|
Support for Nest Thermostat Binary Sensors.
|
|
|
|
|
|
|
|
For more details about this platform, please refer to the documentation at
|
2016-01-27 09:00:01 +01:00
|
|
|
https://home-assistant.io/components/binary_sensor.nest/
|
2016-01-14 10:48:24 -07:00
|
|
|
"""
|
2016-04-12 00:52:19 -04:00
|
|
|
import voluptuous as vol
|
2016-01-14 10:48:24 -07:00
|
|
|
|
2016-09-01 22:08:03 +02:00
|
|
|
from homeassistant.components.binary_sensor import (
|
|
|
|
BinarySensorDevice, PLATFORM_SCHEMA)
|
2016-02-18 21:27:50 -08:00
|
|
|
from homeassistant.components.sensor.nest import NestSensor
|
2016-09-01 22:08:03 +02:00
|
|
|
from homeassistant.const import (CONF_SCAN_INTERVAL, CONF_MONITORED_CONDITIONS)
|
|
|
|
import homeassistant.components.nest as nest
|
|
|
|
import homeassistant.helpers.config_validation as cv
|
2016-01-14 10:48:24 -07:00
|
|
|
|
2016-02-11 21:28:08 -05:00
|
|
|
DEPENDENCIES = ['nest']
|
2016-01-14 10:48:24 -07:00
|
|
|
BINARY_TYPES = ['fan',
|
|
|
|
'hvac_ac_state',
|
|
|
|
'hvac_aux_heater_state',
|
2016-01-27 09:22:21 -05:00
|
|
|
'hvac_heater_state',
|
2016-01-14 10:48:24 -07:00
|
|
|
'hvac_heat_x2_state',
|
|
|
|
'hvac_heat_x3_state',
|
|
|
|
'hvac_alt_heat_state',
|
|
|
|
'hvac_alt_heat_x2_state',
|
|
|
|
'hvac_emer_heat_state',
|
|
|
|
'online']
|
|
|
|
|
2016-09-01 22:08:03 +02:00
|
|
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
2016-04-12 00:52:19 -04:00
|
|
|
vol.Optional(CONF_SCAN_INTERVAL):
|
|
|
|
vol.All(vol.Coerce(int), vol.Range(min=1)),
|
2016-09-01 22:08:03 +02:00
|
|
|
vol.Required(CONF_MONITORED_CONDITIONS):
|
|
|
|
vol.All(cv.ensure_list, [vol.In(BINARY_TYPES)]),
|
2016-04-12 00:52:19 -04:00
|
|
|
})
|
|
|
|
|
2016-01-14 14:19:35 -07:00
|
|
|
|
2016-01-14 10:48:24 -07:00
|
|
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
2016-02-22 10:11:46 +01:00
|
|
|
"""Setup Nest binary sensors."""
|
2016-04-12 00:52:19 -04:00
|
|
|
for structure, device in nest.devices():
|
|
|
|
add_devices([NestBinarySensor(structure, device, variable)
|
|
|
|
for variable in config[CONF_MONITORED_CONDITIONS]])
|
2016-01-14 10:48:24 -07:00
|
|
|
|
2016-01-14 14:19:35 -07:00
|
|
|
|
2016-01-16 12:52:22 -07:00
|
|
|
class NestBinarySensor(NestSensor, BinarySensorDevice):
|
2016-02-22 10:11:46 +01:00
|
|
|
"""Represents a Nest binary sensor."""
|
2016-01-14 10:48:24 -07:00
|
|
|
|
|
|
|
@property
|
2016-01-14 14:17:28 -07:00
|
|
|
def is_on(self):
|
2016-02-22 10:11:46 +01:00
|
|
|
"""True if the binary sensor is on."""
|
2016-01-14 14:17:28 -07:00
|
|
|
return bool(getattr(self.device, self.variable))
|