fixed sensors and thermostat. discovery working for both now.

This commit is contained in:
nkgilley@gmail.com committed 2015-11-23 11:15:19 -05:00
1 parent 8dc0de1d05
commit cc196d9888
5 files changed
+118 -73

No files matched your search

+3 -2
View File
@@ -9,7 +9,7 @@ https://home-assistant.io/components/sensor/
import logging
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.components import wink, zwave, isy994, verisure
from homeassistant.components import wink, zwave, isy994, verisure, ecobee
DOMAIN = 'sensor'
DEPENDENCIES = []
@@ -22,7 +22,8 @@ DISCOVERY_PLATFORMS = {
wink.DISCOVER_SENSORS: 'wink',
zwave.DISCOVER_SENSORS: 'zwave',
isy994.DISCOVER_SENSORS: 'isy994',
verisure.DISCOVER_SENSORS: 'verisure'
verisure.DISCOVER_SENSORS: 'verisure',
ecobee.DISCOVER_SENSORS: 'ecobee'
}
+37 -36
View File
@@ -1,22 +1,39 @@
"""
homeassistant.components.sensor.ecobee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This sensor component requires that the Ecobee Thermostat
component be setup first. This component shows remote
ecobee sensor data.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ecobee Thermostat Component
This component adds support for Ecobee3 Wireless Thermostats.
You will need to setup developer access to your thermostat,
and create and API key on the ecobee website.
The first time you run this component you will see a configuration
component card in Home Assistant. This card will contain a PIN code
that you will need to use to authorize access to your thermostat. You
can do this at https://www.ecobee.com/consumerportal/index.html
Click My Apps, Add application, Enter Pin and click Authorize.
After authorizing the application click the button in the configuration
card. Now your thermostat and sensors should shown in home-assistant.
You can use the optional hold_temp parameter to set whether or not holds
are set indefintely or until the next scheduled event.
ecobee:
api_key: asdfasdfasdfasdfasdfaasdfasdfasdfasdf
hold_temp: True
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.ecobee/
"""
from homeassistant.helpers.entity import Entity
import json
from homeassistant.components.ecobee import NETWORK
from homeassistant.const import TEMP_FAHRENHEIT
import logging
import os
DEPENDENCIES = ['thermostat']
DEPENDENCIES = ['ecobee']
SENSOR_TYPES = {
'temperature': ['Temperature', '°F'],
'temperature': ['Temperature', TEMP_FAHRENHEIT],
'humidity': ['Humidity', '%'],
'occupancy': ['Occupancy', '']
}
@@ -26,24 +43,12 @@ _LOGGER = logging.getLogger(__name__)
ECOBEE_CONFIG_FILE = 'ecobee.conf'
def config_from_file(filename):
''' Small configuration file reading function '''
if os.path.isfile(filename):
try:
with open(filename, 'r') as fdesc:
return json.loads(fdesc.read())
except IOError as error:
_LOGGER.error("ecobee sensor couldn't read config file: " + error)
return False
else:
return {}
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the sensors. """
config = config_from_file(hass.config.path(ECOBEE_CONFIG_FILE))
if discovery_info is None:
return
dev = list()
for name, data in config['sensors'].items():
for name, data in NETWORK.ecobee.sensors.items():
if 'temp' in data:
dev.append(EcobeeSensor(name, 'temperature', hass))
if 'humidity' in data:
@@ -80,14 +85,10 @@ class EcobeeSensor(Entity):
return self._unit_of_measurement
def update(self):
config = config_from_file(self.hass.config.path(ECOBEE_CONFIG_FILE))
try:
data = config['sensors'][self.sensor_name]
if self.type == 'temperature':
self._state = data['temp']
elif self.type == 'humidity':
self._state = data['humidity']
elif self.type == 'occupancy':
self._state = data['occupancy']
except KeyError:
print("Error updating ecobee sensors.")
data = NETWORK.ecobee.sensors[self.sensor_name]
if self.type == 'temperature':
self._state = data['temp']
elif self.type == 'humidity':
self._state = data['humidity']
elif self.type == 'occupancy':
self._state = data['occupancy']