Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Climate/nest does not work properly on 0.29.1 #3574

Closed
tchellomello opened this issue Sep 29, 2016 · 6 comments · Fixed by #3606
Closed

Climate/nest does not work properly on 0.29.1 #3574

tchellomello opened this issue Sep 29, 2016 · 6 comments · Fixed by #3606

Comments

@tchellomello
Copy link
Contributor

Home Assistant release (hass --version):
0.29.1

Python release (python3 --version):
3.5.1

Component/platform:
climate/nest

Description of problem:

  1. Climate/nest does not load due to the traceback below:
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=nest>
ERROR:homeassistant.components.climate:Error while setting up platform nest
Traceback (most recent call last):
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 107, in _setup_platform
    discovery_info)
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/components/climate/nest.py", line 30, in setup_platform
    for structure, device in nest.devices()])
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 198, in add_entities
    if self.component.add_entity(entity, self):
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 134, in add_entity
    entity.update_ha_state()
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 157, in update_ha_state
    attr = self.state_attributes or {}
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/components/climate/__init__.py", line 358, in state_attributes
    self._convert_for_display(self.current_temperature),
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/components/climate/__init__.py", line 539, in _convert_for_display
    value = convert_temperature(temp, self.unit_of_measurement,
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/components/climate/nest.py", line 60, in unit_of_measurement
    if self.device.measurement_scale == 'F':
AttributeError: 'Device' object has no attribute 'measurement_scale'

It seems it was more than a typo because this method does not exist on my tests here

(home_assistant) ↪ pip3 freeze | grep -e homeassistant -e nest
homeassistant==0.29.1
python-nest==2.10.0

# ipython
In [1]: import nest
In [3]: napi = nest.Nest('myusername', 'mypassword')
In [5]: upstairs = napi.devices[0]
In [6]: upstairs.
upstairs.away_temperature        upstairs.hvac_emer_heat_state    upstairs.postal_code
upstairs.battery_level           upstairs.hvac_heat_x2_state      upstairs.serial
upstairs.error_code              upstairs.hvac_heat_x3_state      upstairs.structure
upstairs.fan                     upstairs.hvac_heater_state       upstairs.target
upstairs.humidity                upstairs.last_connection         upstairs.target_humidity
upstairs.hvac_ac_state           upstairs.last_ip                 upstairs.temperature
upstairs.hvac_alt_heat_state     upstairs.local_ip                upstairs.weather
upstairs.hvac_alt_heat_x2_state  upstairs.mode                    upstairs.where
upstairs.hvac_aux_heater_state   upstairs.name                    
upstairs.hvac_cool_x2_state      upstairs.online   

So, reverting this code it loaded as expected.

diff --git a/homeassistant/components/climate/nest.py b/homeassistant/components/climate/nest.py
index 10abf81..437e63e 100644
--- a/homeassistant/components/climate/nest.py
+++ b/homeassistant/components/climate/nest.py
@@ -57,10 +57,7 @@ class NestThermostat(ClimateDevice):
     @property
     def unit_of_measurement(self):
         """Return the unit of measurement."""
-        if self.device.measurement_scale == 'F':
-            return TEMP_FAHRENHEIT
-        elif self.device.measurement_scale == 'C':
-            return TEMP_CELSIUS
+        return TEMP_CELSIUS

Note: I tested it with imperial and metric and HA was able to successfully to convert the values but it kept the wrong temperature symbol:

unit_system: 'imperial

Downstairs
3 minutes ago
Currently: 74 °C

After reverting the patch above, the second issue is related with the frontend. The target temperature slider only is displayed on the frontend if the Nest Thermostat is operating on Heat/Cool modes or on away mode.

Below we can see a screenshot that shows it:

My nest downstairs is set to heat/cool mode and the frontend show the data as expected
screenshot at 2016-09-29 03-30-01

I'm also able to set the temperature when the thermostat in on this state:

INFO:homeassistant.components.http:Serving /api/services/climate/set_temperature to 127.0.0.1 (auth: True)
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service=set_temperature, domain=climate, service_call_id=140647003476488-4, service_data=entity_id=climate.upstairs, target_temp_low=21.5, target_temp_high=23.5>
DEBUG:homeassistant.components.climate.nest:Nest set_temperature-output-value=(21.5, 23.5)
DEBUG:requests.packages.urllib3.connectionpool:"POST /v2/put/shared.0XXXXXXXX HTTP/1.1" 200 0
DEBUG:requests.packages.urllib3.connectionpool:"GET /v2/mobile/user.3XXXXXX HTTP/1.1" 200 None
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=140647003476488-4>

On the other hand, I don't see the target slider or any control to set the temperature running on cool mode only.
screenshot at 2016-09-29 03-31-27

However if I set to away mode via the frontend I can see it:
screenshot at 2016-09-29 03-32-14

But if I try to set the temperature on via slider I got this traceback

INFO:homeassistant.components.http:Serving /api/services/climate/set_temperature to 127.0.0.1 (auth: True)
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service=set_temperature, domain=climate, service_call_id=140647003476488-2, service_data=entity_id=climate.downstairs, target_temp_low=23.6, target_temp_high=27.5>
DEBUG:homeassistant.components.climate.nest:Nest set_temperature-output-value=(23.6, 27.5)
DEBUG:requests.packages.urllib3.connectionpool:"POST /v2/put/shared.09AA01AC44150KNW HTTP/1.1" 400 0
ERROR:homeassistant.core:BusHandler:Exception doing job
Traceback (most recent call last):
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/core.py", line 1162, in job_handler
    func(*args)
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/core.py", line 1025, in _execute_service
    service(call)
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/core.py", line 825, in __call__
    self.func(call)
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/components/climate/__init__.py", line 240, in temperature_set_service
    climate.set_temperature(**kwargs)
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/homeassistant/components/climate/nest.py", line 123, in set_temperature
    self.device.target = temp
  File "/home/mdemello/.homeassistant/deps/nest/nest.py", line 499, in target
    self._set('shared', data)
  File "/home/mdemello/.homeassistant/deps/nest/nest.py", line 278, in _set
    response.raise_for_status()
  File "/home/mdemello/.virtualenvs/home_assistant/lib/python3.5/site-packages/requests/models.py", line 862, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://czfe21-front01-iad01.transport.home.nest.com/v2/put/shared.0XXXXXXXXX

Additional info:

Should we revert the commit to make it work and then use this workaround to make climate/nest for now?

@balloob
Copy link
Member

balloob commented Sep 29, 2016

Let's revert the commit for now and do the other fixes when we got some sleep 👍

@turbokongen
Copy link
Contributor

Could you test with #3591 To see if that fixes your problems?
It will not fix the temperature symbol.
The intended way this works, is that the range slider will always be visible no matter what mode you are in.
But you set the temp with the corresponding high or low slider.

@tchellomello
Copy link
Contributor Author

@turbokongen thanks for your assistance on this.

I applied your changes on my test branch. In addition to your patch, I kept the function below to allow Nest component to load.

--- a/homeassistant/components/climate/nest.py
+++ b/homeassistant/components/climate/nest.py
@@ -57,10 +57,7 @@ class NestThermostat(ClimateDevice):
     @property
     def unit_of_measurement(self):
         """Return the unit of measurement."""
-        if self.device.measurement_scale == 'F':
-            return TEMP_FAHRENHEIT
-        elif self.device.measurement_scale == 'C':
-            return TEMP_CELSIUS
+        return TEMP_CELSIUS

I see a new Operation dropbox field now but I don't see the target tempeturate slider when operation in 1 mode.

downstairs running on cool mode
screenshot at 2016-09-29 13-39-46

upstairs running on heat/cool mode
screenshot at 2016-09-29 13-40-01

I think the problem is related to the way self.device.hvac_heater_state and device.hvac_ac_state are being used to determine the mode. They will just return True if the compressor is on. In other words, if it compressor is Idle, we don't return the temperature on target_temperature_high() and target_temperature_low().

Also here to set the temperature the function is returning a before assigned error because of the same condition.

114     def set_temperature(self, **kwargs):
115         """Set new target temperature."""
116         if kwargs.get(ATTR_TARGET_TEMP_LOW) is not None and \
117            kwargs.get(ATTR_TARGET_TEMP_HIGH) is not None:
118             target_temp_high = convert_temperature(kwargs.get(
119                 ATTR_TARGET_TEMP_HIGH), self._unit, TEMP_CELSIUS)
120             target_temp_low = convert_temperature(kwargs.get(
121                 ATTR_TARGET_TEMP_LOW), self._unit, TEMP_CELSIUS)
122 
123         if self.device.hvac_heater_state:  # <--- return true only if furnance compressor is on
124             temp = target_temp_low
125         if self.device.hvac_ac_state:    # <-- return true only if cool compressor is on
126             temp = target_temp_high
127         if self.device.mode == 'range':
128             temp = (target_temp_low, target_temp_high)
129         _LOGGER.debug("Nest set_temperature-output-value=%s", temp)
130         self.device.target = temp

Based on those findings, to test it, I initiated Nest the module directly to double check it:

In [29]: upstairs.hvac_ac_state
Out[29]: False

In [30]: upstairs.hvac_heater_state
Out[30]: False

In [31]: upstairs.mode
Out[31]: 'range'

In [32]: downstairs.hvac_ac_state
Out[32]: False

In [33]: downstairs.hvac_heater_state
Out[33]: False

In [34]: downstairs.mode
Out[34]: 'cool'

# --- Forcing the compressor on to cool it returned True then
In [43]: upstairs.hvac_ac_state
Out[43]: True

Having said this, after changed a little bit (not ready to merge) I got the target slider displayed in any mode. I was also able to set the temperature via the slider.

The only problem is when sliding the bar, it shows the 2 knobs instead only one (target_temp_low, target_temp_high). I don't understand the frontend well to troubleshoot it any idea would be very welcomed.

  • prior_sliding
    prior_sliding
  • new knob controller when sliding
    during_slide

Besides the visual issue, it applied the temperature correctly.

INFO:homeassistant.components.http:Serving /api/services/climate/set_temperature to 127.0.0.1 (auth: True)
DEBUG:homeassistant.components.climate.nest:Nest set_temperature-output-value=22.5
DEBUG:homeassistant.components.api:STREAM 140239919170384 FORWARDING <Event state_changed[L]: old_state=<state climate.upstairs=idle; fan_list=['on', 'auto'], target_temp_low=23.0, temperature=None, target_temp_high=23.0, humidity=61, operation_mode=idle, operation_list=None, friendly_name=Upstairs, unit_of_measurement=°C, min_temp=19.5, mode=cool, current_temperature=23.3, target_humidity=40.0, max_temp=27.0, fan_mode=auto, away_mode=off @ 2016-09-29T17:00:15.554956-04:00>, new_state=<state climate.upstairs=idle; fan_list=['on', 'auto'], target_temp_low=22.5, temperature=None, target_temp_high=22.5, humidity=61, operation_mode=idle, operation_list=None, friendly_name=Upstairs, unit_of_measurement=°C, min_temp=19.5, mode=cool, current_temperature=23.3, target_humidity=40.0, max_temp=27.0, fan_mode=auto, away_mode=off @ 2016-09-29T17:00:15.554956-04:00>, entity_id=climate.upstairs>
DEBUG:homeassistant.components.api:STREAM 140239919170384 WRITING data: {"data": {"old_state": {"state": "idle", "last_updated": "2016-09-29T21:15:00.858270+00:00", "attributes": {"fan_list": ["on", "auto"], "target_humidity": 40.0, "current_temperature": 23.3, "temperature": null, "target_temp_high": 23.0, "operation_mode": "idle", "operation_list": null, "mode": "cool", "away_mode": "off", "fan_mode": "auto", "unit_of_measurement": "\u00b0C", "friendly_name": "Upstairs", "target_temp_low": 23.0, "max_temp": 27.0, "min_temp": 19.5, "humidity": 61}, "entity_id": "climate.upstairs", "last_changed": "2016-09-29T21:00:15.554956+00:00"}, "new_state": {"state": "idle", "last_updated": "2016-09-29T21:16:16.657290+00:00", "attributes": {"fan_list": ["on", "auto"], "target_humidity": 40.0, "current_temperature": 23.3, "temperature": null, "target_temp_high": 22.5, "operation_mode": "idle", "operation_list": null, "mode": "cool", "away_mode": "off", "fan_mode": "auto", "unit_of_measurement": "\u00b0C", "friendly_name": "Upstairs", "target_temp_low": 22.5, "max_temp": 27.0, "min_temp": 19.5, "humidity": 61}, "entity_id": "climate.upstairs", "last_changed": "2016-09-29T21:00:15.554956+00:00"}, "entity_id": "climate.upstairs"}, "time_fired": "2016-09-29T21:16:16.657370+00:00", "event_type": "state_changed", "origin": "LOCAL"}

I think we are almost there. You can see the changes during the test here:

dev...tchellomello:fix_climate_nest_test

The symbol is still broken but I have not troubleshoot it yet.

Thanks.

@tchellomello
Copy link
Contributor Author

Many thanks @turbokongen @balloob
PR#3606 created

balloob pushed a commit that referenced this issue Sep 30, 2016
… mode (#3606)

* Fixed issue #3574 - Temperature slider fixed on frontend on heat/cool mode

* Fixed target_temperature to return None when self.is_away_mode_on is True
balloob pushed a commit that referenced this issue Sep 30, 2016
… mode (#3606)

* Fixed issue #3574 - Temperature slider fixed on frontend on heat/cool mode

* Fixed target_temperature to return None when self.is_away_mode_on is True
@broesie
Copy link

broesie commented Oct 1, 2016

There was a specific upgrade 0.29.5, that should fix the problems with Nest Thermostat.

I still got problems with it, especially nest sensor doesn't work correctly. Here is my log:

 16-10-01 11:32:15 homeassistant.components.sensor: Error while setting up platform nest
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 107, in _setup_platform
    discovery_info)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/nest.py", line 68, in setup_platform
    add_devices(sensors)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 198, in add_entities
    if self.component.add_entity(entity, self):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 134, in add_entity
    entity.update_ha_state()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py", line 156, in update_ha_state
    state = STATE_UNKNOWN if self.state is None else str(self.state)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/nest.py", line 147, in state
    return getattr(self.structure.weather.current, self.variable)
  File "/home/hass/.homeassistant/deps/nest/nest.py", line 254, in current
    return Forecast(self._current, self._tz)
  File "/home/hass/.homeassistant/deps/nest/nest.py", line 205, in __init__
    fget('observation_epoch')))))
TypeError: float() argument must be a string or a number, not 'NoneType'

@tchellomello
Copy link
Contributor Author

tchellomello commented Oct 1, 2016

@broesie see #3624

@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants