diff --git a/homeassistant/components/ecobee.py b/homeassistant/components/ecobee.py index 03f17133501..0dc69c9d7a2 100644 --- a/homeassistant/components/ecobee.py +++ b/homeassistant/components/ecobee.py @@ -44,7 +44,7 @@ HOLD_TEMP = 'hold_temp' REQUIREMENTS = [ 'https://github.com/nkgilley/python-ecobee-api/archive/' - 'd35596b67c75451fa47001c493a15eebee195e93.zip#python-ecobee==0.0.1'] + '5645f843b64ac4f6e59dfb96233a07083c5e10c1.zip#python-ecobee==0.0.3'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/ecobee.py b/homeassistant/components/sensor/ecobee.py index a6499949015..c1bf5eab052 100644 --- a/homeassistant/components/sensor/ecobee.py +++ b/homeassistant/components/sensor/ecobee.py @@ -43,18 +43,36 @@ _LOGGER = logging.getLogger(__name__) ECOBEE_CONFIG_FILE = 'ecobee.conf' + def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the sensors. """ if discovery_info is None: return + data = ecobee.NETWORK + sensor_list = list() + for index in range(len(data.ecobee.thermostats)): + sensors = dict() + for sensor in data.ecobee.get_remote_sensors(index): + sensor_info = dict() + for item in sensor['capability']: + if item['type'] == 'temperature': + sensor_info['temp'] = float(item['value']) / 10 + elif item['type'] == 'humidity': + sensor_info['humidity'] = item['value'] + elif item['type'] == 'occupancy': + sensor_info['occupancy'] = item['value'] + sensors[sensor['name']] = sensor_info + sensor_list.append(sensors) + dev = list() - for name, data in ecobee.NETWORK.ecobee.sensors.items(): - if 'temp' in data: - dev.append(EcobeeSensor(name, 'temperature')) - if 'humidity' in data: - dev.append(EcobeeSensor(name, 'humidity')) - if 'occupancy' in data: - dev.append(EcobeeSensor(name, 'occupancy')) + for index in range(len(sensor_list)): + for name, data in sensor_list[index].items(): + if 'temp' in data: + dev.append(EcobeeSensor(name, 'temperature', index)) + if 'humidity' in data: + dev.append(EcobeeSensor(name, 'humidity', index)) + if 'occupancy' in data: + dev.append(EcobeeSensor(name, 'occupancy', index)) add_devices(dev) @@ -62,10 +80,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class EcobeeSensor(Entity): """ An ecobee sensor. """ - def __init__(self, sensor_name, sensor_type): + def __init__(self, sensor_name, sensor_type, sensor_index): self._name = sensor_name + ' ' + SENSOR_TYPES[sensor_type][0] self.sensor_name = sensor_name self.type = sensor_type + self.index = sensor_index self._state = None self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self.update() @@ -85,10 +104,19 @@ class EcobeeSensor(Entity): def update(self): ecobee.NETWORK.update() - data = ecobee.NETWORK.ecobee.sensors[self.sensor_name] + data = ecobee.NETWORK + for sensor in data.ecobee.get_remote_sensors(self.index): + sensor_info = dict() + for item in sensor['capability']: + if item['type'] == 'temperature': + sensor_info['temp'] = float(item['value']) / 10 + elif item['type'] == 'humidity': + sensor_info['humidity'] = item['value'] + elif item['type'] == 'occupancy': + sensor_info['occupancy'] = item['value'] if self.type == 'temperature': - self._state = data['temp'] + self._state = sensor_info['temp'] elif self.type == 'humidity': - self._state = data['humidity'] + self._state = sensor_info['humidity'] elif self.type == 'occupancy': - self._state = data['occupancy'] + self._state = sensor_info['occupancy'] diff --git a/homeassistant/components/thermostat/ecobee.py b/homeassistant/components/thermostat/ecobee.py index 78f4d555c9c..f55bdace587 100644 --- a/homeassistant/components/thermostat/ecobee.py +++ b/homeassistant/components/thermostat/ecobee.py @@ -163,14 +163,14 @@ class Thermostat(ThermostatDevice): """ Turns away on. """ self._away = True if self.hold_temp: - self.data.ecobee.set_climate_hold("away", "indefinite") + self.data.ecobee.set_climate_hold(self.thermostat_index, "away", "indefinite") else: - self.data.ecobee.set_climate_hold("away") + self.data.ecobee.set_climate_hold(self.thermostat_index, "away") def turn_away_mode_off(self): """ Turns away off. """ self._away = False - self.data.ecobee.resume_program() + self.data.ecobee.resume_program(self.thermostat_index) def set_temperature(self, temperature): """ Set new target temperature """ @@ -178,32 +178,32 @@ class Thermostat(ThermostatDevice): low_temp = temperature - 1 high_temp = temperature + 1 if self.hold_temp: - self.data.ecobee.set_hold_temp(low_temp, high_temp, "indefinite") + self.data.ecobee.set_hold_temp(self.thermostat_index, low_temp, high_temp, "indefinite") else: - self.data.ecobee.set_hold_temp(low_temp, high_temp) + self.data.ecobee.set_hold_temp(self.thermostat_index, low_temp, high_temp) def set_hvac_mode(self, mode): """ Set HVAC mode (auto, auxHeatOnly, cool, heat, off) """ - self.data.ecobee.set_hvac_mode(mode) + self.data.ecobee.set_hvac_mode(self.thermostat_index, mode) # Home and Sleep mode aren't used in UI yet: # def turn_home_mode_on(self): # """ Turns home mode on. """ # self._away = False - # self.data.ecobee.set_climate_hold("home") + # self.data.ecobee.set_climate_hold(self.thermostat_index, "home") # def turn_home_mode_off(self): # """ Turns home mode off. """ # self._away = False - # self.data.ecobee.resume_program() + # self.data.ecobee.resume_program(self.thermostat_index) # def turn_sleep_mode_on(self): # """ Turns sleep mode on. """ # self._away = False - # self.data.ecobee.set_climate_hold("sleep") + # self.data.ecobee.set_climate_hold(self.thermostat_index, "sleep") # def turn_sleep_mode_off(self): # """ Turns sleep mode off. """ # self._away = False - # self.data.ecobee.resume_program() + # self.data.ecobee.resume_program(self.thermostat_index) diff --git a/requirements_all.txt b/requirements_all.txt index b74226f4991..06464e4e00a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -161,4 +161,4 @@ pushetta==1.0.15 orvibo==1.0.0 # Ecobee (*.ecobee) -https://github.com/nkgilley/python-ecobee-api/archive/d35596b67c75451fa47001c493a15eebee195e93.zip#python-ecobee==0.0.1 +https://github.com/nkgilley/python-ecobee-api/archive/5645f843b64ac4f6e59dfb96233a07083c5e10c1.zip#python-ecobee==0.0.3