address PR comments for Nest Sensor
parent
0e6a60b086
commit
7b993da0de
|
@ -37,6 +37,7 @@ omit =
|
|||
homeassistant/components/*/rfxtrx.py
|
||||
|
||||
homeassistant/components/binary_sensor/arest.py
|
||||
homeassistant/components/binary_sensor/nest.py
|
||||
homeassistant/components/binary_sensor/rest.py
|
||||
homeassistant/components/browser.py
|
||||
homeassistant/components/camera/*
|
||||
|
@ -93,6 +94,7 @@ omit =
|
|||
homeassistant/components/sensor/forecast.py
|
||||
homeassistant/components/sensor/glances.py
|
||||
homeassistant/components/sensor/mysensors.py
|
||||
homeassistant/components/sensor/nest.py
|
||||
homeassistant/components/sensor/openweathermap.py
|
||||
homeassistant/components/sensor/rest.py
|
||||
homeassistant/components/sensor/rpi_gpio.py
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
"""
|
||||
homeassistant.components.binary.nest
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Support for Nest Thermostat Binary Sensors.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.nest/
|
||||
"""
|
||||
import logging
|
||||
import socket
|
||||
import homeassistant.components.nest as nest
|
||||
|
||||
from homeassistant.components.sensor.nest import NestSensor
|
||||
from homeassistant.const import (STATE_ON, STATE_OFF)
|
||||
|
||||
|
||||
BINARY_TYPES = ['fan',
|
||||
'hvac_ac_state',
|
||||
'hvac_aux_heater_state',
|
||||
'hvac_heat_x2_state',
|
||||
'hvac_heat_x3_state',
|
||||
'hvac_alt_heat_state',
|
||||
'hvac_alt_heat_x2_state',
|
||||
'hvac_emer_heat_state',
|
||||
'online']
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
logger = logging.getLogger(__name__)
|
||||
try:
|
||||
for structure in nest.NEST.structures:
|
||||
for device in structure.devices:
|
||||
for variable in config['monitored_conditions']:
|
||||
if variable in BINARY_TYPES:
|
||||
add_devices([NestBinarySensor(structure, device, variable)])
|
||||
else:
|
||||
logger.error('Nest sensor type: "%s" does not exist', variable)
|
||||
except socket.error:
|
||||
logger.error(
|
||||
"Connection error logging into the nest web service."
|
||||
)
|
||||
|
||||
class NestBinarySensor(NestSensor):
|
||||
""" Represents a Nst Binary sensor. """
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
if getattr(self.device, self.variable):
|
||||
return STATE_ON
|
||||
else:
|
||||
return STATE_OFF
|
|
@ -7,7 +7,7 @@ For more details about this platform, please refer to the documentation at
|
|||
https://home-assistant.io/components/sensor.nest/
|
||||
"""
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.const import (STATE_ON, STATE_OFF, TEMP_CELCIUS)
|
||||
from homeassistant.const import TEMP_CELCIUS
|
||||
from homeassistant.helpers.temperature import convert
|
||||
|
||||
import homeassistant.components.nest as nest
|
||||
|
@ -22,16 +22,6 @@ SENSOR_TYPES = ['humidity',
|
|||
'last_connection',
|
||||
'battery_level']
|
||||
|
||||
BINARY_TYPES = ['fan',
|
||||
'hvac_ac_state',
|
||||
'hvac_aux_heater_state',
|
||||
'hvac_heat_x2_state',
|
||||
'hvac_heat_x3_state',
|
||||
'hvac_alt_heat_state',
|
||||
'hvac_alt_heat_x2_state',
|
||||
'hvac_emer_heat_state',
|
||||
'online']
|
||||
|
||||
SENSOR_UNITS = {'humidity': '%', 'battery_level': '%'}
|
||||
|
||||
SENSOR_TEMP_TYPES = ['temperature',
|
||||
|
@ -47,8 +37,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
for variable in config['monitored_conditions']:
|
||||
if variable in SENSOR_TYPES:
|
||||
add_devices([NestSensor(structure, device, variable)])
|
||||
elif variable in BINARY_TYPES:
|
||||
add_devices([NestBinarySensor(structure, device, variable)])
|
||||
elif variable in SENSOR_TEMP_TYPES:
|
||||
add_devices([NestTempSensor(structure, device, variable)])
|
||||
else:
|
||||
|
@ -104,13 +92,3 @@ class NestTempSensor(NestSensor):
|
|||
self.hass.config.temperature_unit)
|
||||
|
||||
return round(value, 1)
|
||||
|
||||
class NestBinarySensor(NestSensor):
|
||||
""" Represents a Nst Binary sensor. """
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
if getattr(self.device, self.variable):
|
||||
return STATE_ON
|
||||
else:
|
||||
return STATE_OFF
|
||||
|
|
|
@ -89,6 +89,9 @@ https://github.com/bashwork/pymodbus/archive/d7fc4f1cc975631e0a9011390e8017f64b6
|
|||
# homeassistant.components.mqtt
|
||||
paho-mqtt==1.1
|
||||
|
||||
# homeassistant.components.nest
|
||||
python-nest==2.6.0
|
||||
|
||||
# homeassistant.components.notify.pushbullet
|
||||
pushbullet.py==0.9.0
|
||||
|
||||
|
@ -184,9 +187,6 @@ heatmiserV3==0.9.1
|
|||
# homeassistant.components.thermostat.honeywell
|
||||
evohomeclient==0.2.4
|
||||
|
||||
# homeassistant.components.thermostat.nest
|
||||
python-nest==2.6.0
|
||||
|
||||
# homeassistant.components.thermostat.radiotherm
|
||||
radiotherm==1.2
|
||||
|
||||
|
|
Loading…
Reference in New Issue