home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.55k stars 30.35k forks source link

Netatmo thermostat not working #24380

Closed MTrab closed 5 years ago

MTrab commented 5 years ago

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.

Danielhiversen commented 5 years ago

Please update to the new traceback, since the error you report here is fixed and could not happen anymore. That will make it easier find the bug and fix it.

MTrab commented 5 years ago

The traceback is the same on the current release (.94)

Danielhiversen commented 5 years ago

Yes, but fixed in the latest dev version. But the other traceback you reported is not fixed

MTrab commented 5 years ago

Nope - not fixed in the latest dev version. And I have provided traceback for that too - but you closed the issue without it being fixed.

MTrab commented 5 years ago

The error just moved in the dev version - the reason for the error in the first place is the same.

As soon as one or more thermostat is outside reach the whole platform crashes and do not load. Same issue on current release as on dev, just 2 differet traces.

Danielhiversen commented 5 years ago

Ok, it was just a suggestion to help finding the bug. Because the traceback you report here, can not happen in the latest dev version

MTrab commented 5 years ago

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.

cgtobi commented 5 years ago

@MTrab Could you try if this helps? (https://github.com/home-assistant/home-assistant/pull/24407)

MTrab commented 5 years ago

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.

cgtobi commented 5 years ago

@MTrab Please check the latest changes when you find some time.

MTrab commented 5 years ago

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

https://hastebin.com/uqitucopab.sql

MTrab commented 5 years ago

With the previous, working code, this is the result when and out of range thermostat comes back online:

2019-06-08 20:33:47 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-08 20:33:47 DEBUG (Thread-5) [homeassistant.components.netatmo.climate] {'modules': [{'id': '70:ee:50:0f:40:c0', 'type': 'NAPlug', 'wifi_strength': 54, 'rf_strength': 100, 'firmware_revision': 203}, {'battery_state': 'high', 'reachable': True, 'firmware_revision': 79, 'id': '09:00:00:03:a8:4b', 'battery_level': 2931, 'type': 'NRV', 'rf_strength': 93, 'bridge': '70:ee:50:0f:40:c0'}, {'battery_state': 'full', 'reachable': True, 'firmware_revision': 79, 'id': '09:00:00:03:aa:39', 'battery_level': 3000, 'type': 'NRV', 'rf_strength': 79, 'bridge': '70:ee:50:0f:40:c0'}], 'id': '5cab32a16b5cc203808b45b5', 'rooms': [{'open_window': False, 'heating_power_request': 0, 'therm_setpoint_end_time': 0, 'reachable': True, 'therm_measured_temperature': 20.5, 'therm_setpoint_temperature': 5, 'anticipating': False, 'id': '1194567178', 'therm_setpoint_mode': 'hg', 'therm_setpoint_start_time': 1559941182}, {'open_window': False, 'heating_power_request': 0, 'therm_setpoint_end_time': 0, 'reachable': True, 'therm_measured_temperature': 20, 'therm_setpoint_temperature': 5, 'anticipating': False, 'id': '1988162774', 'therm_setpoint_mode': 'hg', 'therm_setpoint_start_time': 1559941182}]}
2019-06-08 20:33:47 ERROR (Thread-7) [homeassistant.components.netatmo.climate] NetatmoThermostat::update() got exception.
2019-06-08 20:33:47 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.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 192, in state
    if self.current_operation:
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 174, in current_operation
    return self._operation_mode
AttributeError: 'NetatmoThermostat' object has no attribute '_operation_mode'
cgtobi commented 5 years ago

Ops, that was an oversight in the error message. Should be fixed now.

MTrab commented 5 years ago

Let's see when the thermostat comes back online.

Currently this is the result when one thermostat is missing:

2019-06-08 22:51:08 DEBUG (Thread-10) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-08 22:51:08 DEBUG (Thread-10) [homeassistant.components.netatmo.climate] {'id': '5cab32a16b5cc203808b45b5', 'modules': [{'wifi_strength': 51, 'type': 'NAPlug', 'id': '70:ee:50:0f:40:c0', 'rf_strength': 105, 'firmware_revision': 203}, {'reachable': False, 'id': '09:00:00:03:a8:4b', 'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV'}, {'type': 'NRV', 'id': '09:00:00:03:aa:39', 'firmware_revision': 79, 'battery_level': 3000, 'reachable': True, 'rf_strength': 77, 'bridge': '70:ee:50:0f:40:c0', 'battery_state': 'full'}], 'rooms': [{'reachable': False, 'id': '1194567178'}, {'therm_setpoint_temperature': 5, 'id': '1988162774', 'therm_setpoint_start_time': 1559941182, 'anticipating': False, 'therm_setpoint_end_time': 0, 'heating_power_request': 0, 'reachable': True, 'therm_measured_temperature': 20, 'open_window': False, 'therm_setpoint_mode': 'hg'}]}
2019-06-08 22:51:08 ERROR (Thread-10) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-08 22:51:08 DEBUG (Thread-10) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-08 22:51:08 DEBUG (Thread-10) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-08 22:51:08 ERROR (Thread-10) [homeassistant.components.netatmo.climate] Thermostat in 1194567178 not available.
2019-06-08 22:51:08 DEBUG (Thread-10) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-08 22:51:08 DEBUG (Thread-10) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-08 22:51:08 ERROR (Thread-8) [homeassistant.components.netatmo.climate] NetatmoThermostat::update() got exception.
2019-06-08 22:51:08 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 220, in is_on
    return self.target_temperature > 0
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 177, in target_temperature
    return self._data.room_status[self._room_id]['target_temperature']
KeyError: '1194567178'
MTrab commented 5 years ago

Sorry - still same error when thermostat comes back online:

2019-06-09 00:01:05 DEBUG (Thread-7) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-09 00:01:05 DEBUG (Thread-7) [homeassistant.components.netatmo.climate] {'id': '5cab32a16b5cc203808b45b5', 'modules': [{'wifi_strength': 49, 'type': 'NAPlug', 'id': '70:ee:50:0f:40:c0', 'rf_strength': 104, 'firmware_revision': 203}, {'reachable': False, 'id': '09:00:00:03:a8:4b', 'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV'}, {'type': 'NRV', 'id': '09:00:00:03:aa:39', 'firmware_revision': 79, 'battery_level': 3000, 'reachable': True, 'rf_strength': 78, 'bridge': '70:ee:50:0f:40:c0', 'battery_state': 'full'}], 'rooms': [{'reachable': False, 'id': '1194567178'}, {'therm_setpoint_temperature': 5, 'id': '1988162774', 'therm_setpoint_start_time': 1559941182, 'anticipating': False, 'therm_setpoint_end_time': 0, 'heating_power_request': 0, 'reachable': True, 'therm_measured_temperature': 19.5, 'open_window': False, 'therm_setpoint_mode': 'hg'}]}
2019-06-09 00:01:05 ERROR (Thread-7) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-09 00:01:05 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.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 192, in state
    if self.current_operation:
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 182, in current_operation
    return self._operation_mode
AttributeError: 'NetatmoThermostat' object has no attribute '_operation_mode'

And thermostat entity is not created.

cgtobi commented 5 years ago

I just pushed another attempt to fix it.

MTrab commented 5 years ago

Now there's only an initial error on starting HA with one or more thermostats out of reach:

2019-06-09 09:59:43 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-09 09:59:43 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] {'id': '5cab32a16b5cc203808b45b5', 'rooms': [{'id': '1194567178', 'reachable': False}, {'id': '1988162774', 'therm_measured_temperature': 19, 'open_window': False, 'heating_power_request': 0, 'anticipating': False, 'therm_setpoint_mode': 'hg', 'reachable': True, 'therm_setpoint_start_time': 1559941182, 'therm_setpoint_temperature': 5, 'therm_setpoint_end_time': 0}], 'modules': [{'wifi_strength': 50, 'id': '70:ee:50:0f:40:c0', 'firmware_revision': 203, 'rf_strength': 104, 'type': 'NAPlug'}, {'id': '09:00:00:03:a8:4b', 'reachable': False, 'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV'}, {'id': '09:00:00:03:aa:39', 'battery_state': 'full', 'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV', 'rf_strength': 77, 'reachable': True, 'battery_level': 3002, 'firmware_revision': 79}]}
2019-06-09 09:59:43 ERROR (Thread-9) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-09 09:59:43 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-09 09:59:43 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-09 09:59:43 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-09 09:59:43 DEBUG (Thread-9) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-09 09:59:43 ERROR (Thread-9) [homeassistant.components.netatmo.climate] Thermostat in 1194567178 not available.
2019-06-09 09:59:43 ERROR (MainThread) [homeassistant.components.climate] netatmo: Error on device update!
Traceback (most recent call last):
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/home/landroidcloud/home-assistant/homeassistant/helpers/entity.py", line 377, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.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 299, in update
    self._data.room_status[self._room_id]['target_temperature']
KeyError: '1194567178'

Only downside is that when the thermostat(s) out of reach comes online, they are not created as entities in HA.

cgtobi commented 5 years ago

Yeah, that’s not covered right now.

cgtobi commented 5 years ago

That exception should now be covered.

MTrab commented 5 years ago

Almost there :)

2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] {'rooms': [{'id': '1194567178', 'reachable': False}, {'open_window': False, 'anticipating': False, 'heating_power_request': 100, 'therm_setpoint_start_time': 1560096000, 'therm_setpoint_end_time': 0, 'therm_setpoint_mode': 'schedule', 'therm_setpoint_temperature': 24, 'id': '1988162774', 'reachable': True, 'therm_measured_temperature': 20.5}], 'id': '5cab32a16b5cc203808b45b5', 'modules': [{'wifi_strength': 45, 'id': '70:ee:50:0f:40:c0', 'type': 'NAPlug', 'rf_strength': 102, 'firmware_revision': 203}, {'id': '09:00:00:03:a8:4b', 'type': 'NRV', 'reachable': False, 'bridge': '70:ee:50:0f:40:c0'}, {'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV', 'firmware_revision': 79, 'battery_state': 'full', 'battery_level': 3002, 'id': '09:00:00:03:aa:39', 'reachable': True, 'rf_strength': 86}]}
2019-06-09 18:22:48 ERROR (Thread-8) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Køkken in Køkken (1988162774).
2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-09 18:22:48 DEBUG (Thread-8) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Stue in Stue (1194567178).
2019-06-09 18:22:48 ERROR (Thread-8) [homeassistant.components.netatmo.climate] Thermostat in 1194567178 not available.
2019-06-09 18:22:48 ERROR (Thread-7) [homeassistant.components.netatmo.climate] The thermostat in room 1194567178 seems to be out of reach.
2019-06-09 18:22:48 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 228, in is_on
    return self.target_temperature > 0
TypeError: unorderable types: NoneType() > int()
cgtobi commented 5 years ago

You are too quick to test. 😆

MTrab commented 5 years ago

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

cgtobi commented 5 years ago

Well, then give it another try now.

MTrab commented 5 years ago

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'
cgtobi commented 5 years ago

Feel free to test the latest commit.

MTrab commented 5 years ago

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.

cgtobi commented 5 years ago

I really appreciate you willingness to test.

cgtobi commented 5 years ago

Is it still running stable?

MTrab commented 5 years ago

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

MTrab commented 5 years ago

"Finally" one of the thermostats disconnected :D

Unfortunately we still have tracebacks.

2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] {'rooms': [{'id': '1194567178', 'reachable': False}, {'therm_setpoint_temperature': 5, 'open_window': False, 'therm_measured_temperature': 20, 'therm_setpoint_start_time': 1560543859, 'therm_setpoint_mode': 'hg', 'anticipating': False, 'id': '1988162774', 'therm_setpoint_end_time': 0, 'heating_power_request': 100, 'reachable': True}], 'id': '5cab32a16b5cc203808b45b5', 'modules': [{'rf_strength': 101, 'id': '70:ee:50:0f:40:c0', 'firmware_revision': 203, 'wifi_strength': 40, 'type': 'NAPlug'}, {'id': '09:00:00:03:a8:4b', 'reachable': False, 'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV'}, {'battery_state': 'full', 'rf_strength': 89, 'battery_level': 3000, 'id': '09:00:00:03:aa:39', 'type': 'NRV', 'reachable': True, 'bridge': '70:ee:50:0f:40:c0', 'firmware_revision': 79}]}
2019-06-14 22:25:48 ERROR (Thread-6) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Stue in Stue (1194567178).
2019-06-14 22:25:48 ERROR (Thread-6) [homeassistant.components.netatmo.climate] Thermostat in 1194567178 not available.
2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-14 22:25:48 DEBUG (Thread-6) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Køkken in Køkken (1988162774).
2019-06-14 22:25:48 ERROR (Thread-2) [homeassistant.components.netatmo.climate] The thermostat in room 1194567178 seems to be out of reach.
2019-06-14 22:25:48 ERROR (MainThread) [homeassistant.components.netatmo.climate] Current temperature could not be retrieved for netatmo_Stue in Stue (1194567178)
2019-06-14 22:25:48 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'
cgtobi commented 5 years ago

I just pushed another change, so when you get a chance I'd be grateful for feedback.

MTrab commented 5 years ago

Still issues:

2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] Following is the debugging output for homestatus:
2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] {'modules': [{'id': '70:ee:50:0f:40:c0', 'type': 'NAPlug', 'wifi_strength': 39, 'firmware_revision': 203, 'rf_strength': 100}, {'id': '09:00:00:03:a8:4b', 'type': 'NRV', 'bridge': '70:ee:50:0f:40:c0', 'reachable': False}, {'id': '09:00:00:03:aa:39', 'bridge': '70:ee:50:0f:40:c0', 'type': 'NRV', 'reachable': True, 'firmware_revision': 79, 'rf_strength': 83, 'battery_level': 2989, 'battery_state': 'full'}], 'id': '5cab32a16b5cc203808b45b5', 'rooms': [{'id': '1194567178', 'reachable': False}, {'id': '1988162774', 'therm_setpoint_temperature': 22, 'therm_setpoint_end_time': 0, 'reachable': True, 'open_window': False, 'heating_power_request': 100, 'anticipating': False, 'therm_measured_temperature': 21, 'therm_setpoint_start_time': 1561096802, 'therm_setpoint_mode': 'schedule'}]}
2019-06-21 09:01:10 ERROR (Thread-3) [homeassistant.components.netatmo.climate] Update of room 1194567178 failed. Error: 'therm_setpoint_temperature'
2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] Setting up Køkken (1988162774) ...
2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] Adding devices for room Køkken (1988162774) ...
2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Køkken in Køkken (1988162774).
2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] Setting up Stue (1194567178) ...
2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] Adding devices for room Stue (1194567178) ...
2019-06-21 09:01:10 DEBUG (Thread-3) [homeassistant.components.netatmo.climate] Setting up thermostat netatmo_Stue in Stue (1194567178).
2019-06-21 09:01:10 ERROR (Thread-3) [homeassistant.components.netatmo.climate] Thermostat in 1194567178 not available.
2019-06-21 09:01:10 ERROR (Thread-9) [homeassistant.components.netatmo.climate] The thermostat in room 1194567178 seems to be out of reach.
2019-06-21 09:01:10 ERROR (MainThread) [homeassistant.components.netatmo.climate] Current temperature could not be retrieved for netatmo_Stue in Stue (1194567178)
2019-06-21 09:01:10 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 256, in state_attributes
    if self.operation_list:
  File "/home/landroidcloud/home-assistant/homeassistant/components/netatmo/climate.py", line 194, in operation_list
    return self._operation_list
AttributeError: 'NetatmoThermostat' object has no attribute '_operation_list'
cgtobi commented 5 years ago

Ah, fixed that now.

MTrab commented 5 years ago

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'
cgtobi commented 5 years ago

I think I got that.

MTrab commented 5 years ago

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!

MTrab commented 5 years ago

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.

MTrab commented 5 years ago

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 :)

cgtobi commented 5 years ago

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

gonzalezcalleja commented 5 years ago

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!

cgtobi commented 5 years ago

Due to a major overhaul of the climate components this is not merged yeah. More info on this once it’s ready for testing.

bend commented 5 years ago

@cgtobi good to know :) I still have this issue on the latest 0.95.4

2019-07-02 11:35:33 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.netatmo                                                  
2019-07-02 11:35:33 ERROR (SyncWorker_15) [homeassistant.components.netatmo.climate] Update of room 2213695605 failed. Error: 'therm_setpoint_tempe
rature'                                                                                                                                            
2019-07-02 11:35:33 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform netatmo                                  
Traceback (most recent call last):                                                                                                                 
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform                                                 
    SLOW_SETUP_MAX_WAIT)                                                                                                                           
  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/src/app/homeassistant/components/netatmo/climate.py", line 106, in setup_platform                                                     
    devices.append(NetatmoThermostat(room_data, room_id))                                                                                          
  File "/usr/src/app/homeassistant/components/netatmo/climate.py", line 122, in __init__                                                           
    self._module_type = self._data.room_status[room_id]['module_type']                                                                             
KeyError: '2213695605'
cgtobi commented 5 years ago

@bend in the meantime you can manually patch with https://github.com/home-assistant/home-assistant/pull/24407. (At your own risk 😉)

cgtobi commented 5 years ago

@MTrab Would you mind testing the latest dev branch? A lot of changes from #24407 have found their way into the big climate migration that is comming for 0.96 and I would like to make sure that your original issue is fixed.

MTrab commented 5 years ago

Nope - now a new error occurs

https://pastebin.com/burK32Mw

cgtobi commented 5 years ago

@MTrab if you have a few minutes, I'd be grateful for another round of feedback for https://github.com/home-assistant/home-assistant/pull/25068.

MTrab commented 5 years ago

Nah - still similar errors

https://pastebin.com/vcEeF0f2

cgtobi commented 5 years ago

Duh, stupid me. Pushed another one.

MTrab commented 5 years ago

New day - new error ;)

https://pastebin.com/mhqYqjrH

cgtobi commented 5 years ago

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