From a69c575dab90c2bf7f7ebe6f8faf88ebcc8f9994 Mon Sep 17 00:00:00 2001
From: John Arild Berentsen <turbokongen@hotmail.com>
Date: Mon, 12 Sep 2016 17:40:46 +0200
Subject: [PATCH] Bugfix ecobee: inverted high and low temps and enforce int to
 temps (#3325)

* inverted high and low temps

* Looks like somethings are mixed up

* Added debugentires

* Added debugentires 2

* Enforce int on temperatures
---
 homeassistant/components/climate/ecobee.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/homeassistant/components/climate/ecobee.py b/homeassistant/components/climate/ecobee.py
index 5d78aeb8597..21a2c89c31a 100644
--- a/homeassistant/components/climate/ecobee.py
+++ b/homeassistant/components/climate/ecobee.py
@@ -116,9 +116,6 @@ class Thermostat(ClimateDevice):
             return self.target_temperature_low
         elif self.operation_mode == 'cool':
             return self.target_temperature_high
-        else:
-            return (self.target_temperature_low +
-                    self.target_temperature_high) / 2
 
     @property
     def target_temperature_low(self):
@@ -223,19 +220,27 @@ class Thermostat(ClimateDevice):
         """Set new target temperature."""
         if kwargs.get(ATTR_TEMPERATURE) is not None:
             temperature = kwargs.get(ATTR_TEMPERATURE)
-            low_temp = temperature - 1
-            high_temp = temperature + 1
+            low_temp = int(temperature)
+            high_temp = int(temperature)
         if kwargs.get(ATTR_TARGET_TEMP_LOW) is not None and \
            kwargs.get(ATTR_TARGET_TEMP_HIGH) is not None:
-            low_temp = kwargs.get(ATTR_TARGET_TEMP_LOW)
-            high_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH)
+            high_temp = int(kwargs.get(ATTR_TARGET_TEMP_LOW))
+            low_temp = int(kwargs.get(ATTR_TARGET_TEMP_HIGH))
 
         if self.hold_temp:
             self.data.ecobee.set_hold_temp(self.thermostat_index, low_temp,
                                            high_temp, "indefinite")
+            _LOGGER.debug("Setting ecobee hold_temp to: low=%s, is=%s, "
+                          "high=%s, is=%s", low_temp, isinstance(
+                              low_temp, (int, float)), high_temp,
+                          isinstance(high_temp, (int, float)))
         else:
             self.data.ecobee.set_hold_temp(self.thermostat_index, low_temp,
                                            high_temp)
+            _LOGGER.debug("Setting ecobee temp to: low=%s, is=%s, "
+                          "high=%s, is=%s", low_temp, isinstance(
+                              low_temp, (int, float)), high_temp,
+                          isinstance(high_temp, (int, float)))
 
     def set_operation_mode(self, operation_mode):
         """Set HVAC mode (auto, auxHeatOnly, cool, heat, off)."""
-- 
GitLab