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