core: Netatmo thermostat not working

Home Assistant release with the issue:

0.93.1+

Last working Home Assistant release (if known): 0.92.4 - althou it was a bit buggy and not loading with every restart.

Operating environment (Hass.io/Docker/Windows/etc.):

Hass.IO

Component/platform:

Netatmo Climate

Description of problem: When starting Hass.IO the Netatmo Climate is not loaded.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

netatmo:
  api_key: !secret netatmo_api
  secret_key: !secret netatmo_key
  username: !secret netatmo_user
  password: !secret netatmo_pass
  discovery: true
  webhooks: false

climate:
  - platform: netatmo

Traceback (if applicable):

2019-05-19 15:31:44 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform netatmo
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/netatmo/climate.py", line 97, in setup_platform
    for room_id in room_data.get_room_ids():
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/netatmo/climate.py", line 345, in get_room_ids
    if not self.setup():
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/netatmo/climate.py", line 358, in setup
    self.update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/util/__init__.py", line 224, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/netatmo/climate.py", line 382, in update
    homestatus_room['therm_setpoint_temperature']
KeyError: 'therm_setpoint_temperature'

Additional information: Screenshot from the Netatmo API App. image

Original issue: https://github.com/home-assistant/home-assistant/issues/23990

I have found that when one or more thermostat is outside reach, then the platform will not load the ones within reach. If all thermostats is within reach no error is produced - need a fix so the platform will not crash if one or more thermostats is outside reach.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 81 (80 by maintainers)

Most upvoted comments

Sorry 😄 I told you - I’m working on something myself, so I have my dev-environment up and running most of the day 😄

And everything is still OK, even with one thermostat offline. Nice work, sir 😃

Great. Thanks again for your patience and quick testing.

Nailed it again 😉

Ok, the default max temp was wrong. I hope that was the issue.

Nailed it - but…

New climate entity: image

Old climate entity: image

Is it on purpose it doesn’t show “Cool” as status and doesn’t show the option to switch between auto and cool?

And another round. Sorry if this is just tiny steps.

New day - new error 😉

https://pastebin.com/mhqYqjrH

Nope - now a new error occurs

https://pastebin.com/burK32Mw

Tested in my setup (I found the same problem when 2 of my Netatmo radiator valves ran out of battery and therm_setpoint_temperature wasn’t in the API). With the last PR from @cgtobi, Netatmo thermostat are working again (tested on 0.94.2). Thanks!

It wouldn’t be possible without you extensive testing. Thanks again for your patience.

Works like a charm - thermostats are added if they are out of reach as being off and becomes active once it get back online. Thumbs up for great work there 😃

OH! You already did add the feature to present the thermostats when they come online?! Will test when the connection drops again, but it looks like the missing one got added when it came back online.

BINGO!

2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] {'id': '5cab32a16b5cc203808b45b5', 'rooms': [{'id': '1194567178', 'reachable': False}, {'therm_setpoint_mode': 'hg', 'id': '1988162774', 'therm_measured_temperature': 20, 'reachable': True, 'therm_setpoint_start_time': 1561131016, 'therm_setpoint_temperature': 5, 'heating_power_request': 0, 'open_window': False, 'anticipating': False, 'therm_setpoint_end_time': 0}], 'modules': [{'rf_strength': 103, 'id': '70:ee:50:0f:40:c0', 'firmware_revision': 203, 'wifi_strength': 37, 'type': 'NAPlug'}, {'id': '09:00:00:03:a8:4b', 'bridge': '70:ee:50:0f:40:c0', 'reachable': False, 'type': 'NRV'}, {'id': '09:00:00:03:aa:39', 'bridge': '70:ee:50:0f:40:c0', 'reachable': True, 'battery_level': 2989, 'rf_strength': 87, 'type': 'NRV', 'battery_state': 'full', 'firmware_revision': 79}]}
2019-06-22 10:03:31 ERROR (Thread-5) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Stue in Stue (1194567178).
2019-06-22 10:03:31 ERROR (Thread-5) [homeassistant.components.netatmo.climate] Thermostat in 1194567178 not available.
2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-22 10:03:31 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Køkken in Køkken (1988162774).
2019-06-22 10:03:31 ERROR (Thread-7) [homeassistant.components.netatmo.climate] The thermostat in room 1194567178 seems to be out of reach.
2019-06-22 10:03:31 ERROR (MainThread) [homeassistant.components.netatmo.climate] Current temperature could not be retrieved for netatmo_Stue in Stue (1194567178)

Then it’s just the “nice to have” feature of adding the missing thermostats when they become available.

Nice work @cgtobi!

Still not quite there:

2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] {'modules': [{'firmware_revision': 203, 'wifi_strength': 37, 'type': 'NAPlug', 'id': '70:ee:50:0f:40:c0', 'rf_strength': 103}, {'firmware_revision': 79, 'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV', 'battery_level': 2925, 'battery_state': 'high', 'reachable': True, 'id': '09:00:00:03:a8:4b', 'rf_strength': 91}, {'bridge': '70:ee:50:0f:40:c0', 'reachable': False, 'id': '09:00:00:03:aa:39', 'type': 'NRV'}], 'id': '5cab32a16b5cc203808b45b5', 'rooms': [{'anticipating': False, 'therm_setpoint_start_time': 1561131016, 'therm_setpoint_mode': 'hg', 'therm_measured_temperature': 20.5, 'therm_setpoint_end_time': 0, 'therm_setpoint_temperature': 5, 'heating_power_request': 0, 'open_window': False, 'reachable': True, 'id': '1194567178'}, {'reachable': False, 'id': '1988162774'}]}
2019-06-21 17:33:14 ERROR (Thread-6) [homeassistant.components.netatmo.climate] Update of room 1988162774 failed. Error: 'therm_setpoint_temperature'
2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Køkken in Køkken (1988162774).
2019-06-21 17:33:14 ERROR (Thread-6) [homeassistant.components.netatmo.climate] Thermostat in 1988162774 not available.
2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-21 17:33:14 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Stue in Stue (1194567178).
2019-06-21 17:33:14 ERROR (Thread-6) [homeassistant.components.netatmo.climate] The thermostat in room 1988162774 seems to be out of reach.
2019-06-21 17:33:14 ERROR (MainThread) [homeassistant.components.netatmo.climate] Current temperature could not be retrieved for netatmo_Køkken in Køkken (1988162774)
2019-06-21 17:33:14 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity_platform.py", line 365, in _async_add_entity
    await entity.async_update_ha_state()
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    self._async_write_ha_state()
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity.py", line 256, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 200, in device_state_attributes
    module_type = self._data.room_status[self._room_id]['module_type']
KeyError: '1988162774'

Yes - no disconnects for a few days. Really annoying when we are testing this 😄

Today it looks like my thermostats are behaving - they haven’t been offline untill now 😃

I’ll have an eye on the app, and test as soon as one of them goes offline.

Nah - that busted something with the native climate domain:

2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] {'modules': [{'rf_strength': 105, 'wifi_strength': 51, 'type': 'NAPlug', 'id': '70:ee:50:0f:40:c0', 'firmware_revision': 203}, {'bridge': '70:ee:50:0f:40:c0', 'reachable': False, 'type': 'NRV', 'id': '09:00:00:03:a8:4b'}, {'rf_strength': 78, 'bridge': '70:ee:50:0f:40:c0', 'reachable': True, 'battery_state': 'full', 'battery_level': 3002, 'id': '09:00:00:03:aa:39', 'type': 'NRV', 'firmware_revision': 79}], 'id': '5cab32a16b5cc203808b45b5', 'rooms': [{'reachable': False, 'id': '1194567178'}, {'therm_setpoint_mode': 'hg', 'reachable': True, 'open_window': False, 'therm_setpoint_start_time': 1560119949, 'heating_power_request': 0, 'id': '1988162774', 'therm_setpoint_end_time': 0, 'therm_measured_temperature': 20, 'therm_setpoint_temperature': 5, 'anticipating': False}]}
2019-06-10 00:44:34 ERROR (Thread-4) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Køkken in Køkken (1988162774).
2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-10 00:44:34 DEBUG (Thread-4) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Stue in Stue (1194567178).
2019-06-10 00:44:34 ERROR (Thread-4) [homeassistant.components.netatmo.climate] Thermostat in 1194567178 not available.
2019-06-10 00:44:34 ERROR (Thread-3) [homeassistant.components.netatmo.climate] The thermostat in room 1194567178 seems to be out of reach.
2019-06-10 00:44:34 ERROR (MainThread) [homeassistant.components.netatmo.climate] Current temperature could not be retrieved for netatmo_Stue in Stue (1194567178)
2019-06-10 00:44:34 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity_platform.py", line 365, in _async_add_entity
    await entity.async_update_ha_state()
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    self._async_write_ha_state()
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity.py", line 255, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/home/landroidcloud/home-assistant/homeassistant/components/climate/__init__.py", line 227, in state_attributes
    if supported_features & SUPPORT_TARGET_TEMPERATURE_HIGH:
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

You are too quick to test. 😆

Bad bad bad 😄 Traceback and error was so long so I put it in hastebin:

https://hastebin.com/uqitucopab.sql

Better - now it does load the thermostats in range and “skips” the ones not in range.

But the KeyError is still present in logs:

2019-06-08 18:19:28 ERROR (Thread-9) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-08 18:19:28 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-08 18:19:28 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-08 18:19:28 ERROR (Thread-9) [homeassistant.components.netatmo.climate] Thermostat in Stue (1194567178) not available.
2019-06-08 18:19:28 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-08 18:19:28 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-08 18:19:28 ERROR (Thread-6) [homeassistant.components.netatmo.climate] NetatmoThermostat::update() got exception.
2019-06-08 18:19:28 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity_platform.py", line 365, in _async_add_entity
    await entity.async_update_ha_state()
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
    self._async_write_ha_state()
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity.py", line 248, in _async_write_ha_state
    state = self.state
  File "/home/landroidcloud/home-assistant/homeassistant/components/climate/__init__.py", line 190, in state
    if self.is_on is False:
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 212, in is_on
    return self.target_temperature > 0
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 169, in target_temperature
    return self._data.room_status[self._room_id]['target_temperature']
KeyError: '1194567178'

Next to test is to see if the missing thermostats are loaded automatically when they connect/get in range.

Dev branch traceback is:

2019-06-07 21:52:46 ERROR (Thread-9) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-07 21:52:46 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform netatmo
Traceback (most recent call last):
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 105, in setup_platform
    devices.append(NetatmoThermostat(room_data, room_id))
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 121, in __init__
    self._module_type = self._data.room_status[room_id]['module_type']
KeyError: '1194567178'

But again - the reason for the error is the same on dev and release branch.