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
71.07k stars 29.73k forks source link

The Tradfri integration stops working every few days. #42563

Closed rubenbe closed 2 years ago

rubenbe commented 3 years ago

The problem

The Tradfri integration stops working every few days. A restart of the integration (or hass entirely) is required to revive it. No need to restart the ikea tradfri hub.

Environment

Problem-relevant configuration.yaml

Configured via flow

Traceback/Error logs

2020-10-28 17:05:08 ERROR (MainThread) [homeassistant.core] Error executing service: <ServiceCall light.turn_on (c:081e8aff193811ebac0de104ad2b18e1): entity_id=['light.tradfri_bulb_e27_ws_opal_980lm'], params=brightness=175, color_temp=370>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1351, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1370, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 470, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 655, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 507, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 249, in async_handle_light_on_service
    await light.async_turn_on(**params)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/light.py", line 262, in async_turn_on
    await self._api(command)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/base_class.py", line 22, in wrapper
    await func(command)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 164, in request
    result = await self._execute(api_commands)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 148, in _execute
    _, res = await self._get_response(msg)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 96, in _get_response
    r = await pr.response
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 731, in _run_outer
    await cls._run(app_request, response, weak_observation, protocol, log)
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 783, in _run
    blockresponse = await blockrequest.response
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 313, in send
    request_interface.request(plumbing_request)
  File "/usr/local/lib/python3.8/site-packages/aiocoap/tokenmanager.py", line 243, in request
    self.outgoing_requests[key] = request
TypeError: 'NoneType' object does not support item assignment
2020-10-28 17:05:08 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65544]: {'3311': [{'5711': 370}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://192.168.1.3:5684/15001/65544'))
2020-10-28 17:05:08 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65544]: {'3311': [{'5851': 175}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://192.168.1.3:5684/15001/65544'))
2020-10-28 17:05:08 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65538]: {'3311': [{'5850': 1}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://192.168.1.3:5684/15001/65538'))
2020-10-28 17:13:12 ERROR (MainThread) [coap] Connection loss was not expected.

Additional information

Originally discussed here: https://community.home-assistant.io/t/tradfri-integration-stops-working-approx-once-twice-a-week/238429/4 I'll see if the issue keeps appearing on the 0.117.x

litinoveweedle commented 3 years ago

Investigating further into the code, in the place where I believe the error is raised, it seems the author of aiocoap has realised there are some limitations to the implementation: "Matching is currently based on wildcards, but not yet very well thought out."

While I still don't understand why your setups are throwing so many errors (mine has run like a Swiss watch for many years), I believe it would be a good idea to investigate further if that part of aiocoap could be rewritten.

Please take a look here: https://github.com/home-assistant/core/issues/42563#issuecomment-725520545

In regards with credentials_from_request code it means, that it is being called on empty instance. So even if you will rewrite credentials_from_request method it it will not help to match anything, as it is called on void. :-o

    def credentials_from_request(self, msg):
        """Return the most specific match to a request message. Matching is
        currently based on wildcards, but not yet very well thought out."""

        uri = msg.get_request_uri()

        for i in range(1000):
            for (k, v) in sorted(self.items(), key=lambda x: len(x[0]), reverse=True):
                if self._wildcard_match(uri, k):
                    if isinstance(v, str):
                        uri = v
                        continue
                    return v
            else:
                raise CredentialsMissingError("No suitable credentials for %s" % uri)
        else:
            raise CredentialsLoadError("Search for suitable credentials for %s exceeds recursion limit")

Maybe if we can find out why self._context.client_credentials is empty after pytradfri resets protocol.

ggravlingen commented 3 years ago

Good input to the discussion! I’m quite curious to see what’s going on in that for-loop, especially when things break down. Are you able to print that self.items() and the uri?

litinoveweedle commented 3 years ago

This is from @rubenbe post #42563 (comment)

code:

                print(uri)
                print(self.items())
                raise CredentialsMissingError("No suitable credentials for %s" % uri)

output (I believe in original post it was in the wrong order):

coaps://192.168.1.3:5684/15001/65538
dict_items([])

I am not the best case to test on - my problems are more spurious, so please could with more often issues step in?

ggravlingen commented 3 years ago

Ok, if items is empty, it will raise the error straight away if I read the code correctly. We need to figure out what populates items(). 🤔

litinoveweedle commented 3 years ago

Nothing. :-) as items() is method - https://www.w3schools.com/python/ref_dictionary_items.asp

it is being called upon _context.client_credentials which represents self in credentials_from_request context.

client_credentials is being IMHO populated when given transport is created.

ggravlingen commented 3 years ago

Oh, it’s that method. I now see it’s there because the class inherits from dict: https://github.com/chrysn/aiocoap/blob/ae4c7e91326a4e7e2611f8d4e5d418c3c4ba9c53/aiocoap/credentials.py#L208

litinoveweedle commented 3 years ago

This is where client_credentials are populated inside of pytradfri:

    async def generate_psk(self, security_key):
        """Generate and set a psk from the security key."""
        if not self._psk:
            # Set context once for generating key
            protocol = await self._get_protocol()
            command = Gateway().generate_psk(self._psk_id)
            protocol.client_credentials.load_from_dict(
                {
                    f"coaps://{self._host}:5684/{command.path_str}": {
                        "dtls": {
                            "psk": security_key.encode("utf-8"),
                            "client-identity": "Client_identity".encode("utf-8"),
                        }
                    }
                }
            )

            self._psk = await self.request(command)

            # aiocoap has now cached our psk, so it must be reset.
            # We also no longer need the protocol, so this will clean that up.
            await self._reset_protocol()
            await self._update_credentials()

    async def _update_credentials(self):
        """Update credentials."""
        protocol = await self._get_protocol()
        protocol.client_credentials.load_from_dict(
            {
                f"coaps://{self._host}:5684/*": {
                    "dtls": {
                        "psk": self._psk.encode("utf-8"),
                        "client-identity": self._psk_id.encode("utf-8"),
                    }
                }
            }
        )

Based on that code I think I see the issue. While protocol is re-created after being destroyed upon "Protocol reset", no credentials are re-loaded.

So IMHO something like this COULD help:

    async def _get_protocol(self):
        """Get the protocol for the request."""
        if self._protocol is None:
            self._protocol = asyncio.create_task(Context.create_client_context())
            self._protocol.client_credentials.load_from_dict(
                {
                    f"coaps://{self._host}:5684/*": {
                        "dtls": {
                            "psk": self._psk.encode("utf-8"),
                            "client-identity": self._psk_id.encode("utf-8"),
                        }
                    }
                }
        return await self._protocol

But is is terrible hack due to possible client_credentials duplicated call - it shall be rewritten better if it helps :-)

ggravlingen commented 3 years ago

Please give it a try and report back 😊

litinoveweedle commented 3 years ago

I will, but I am tooooooo lazy to wait... Please could other people reporting this issue try as well?

kim1138 commented 3 years ago

I'll try if you tell me where I can find the files I need change.

litinoveweedle commented 3 years ago

That depends on your installation, see this

you need to edit this file: /usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py

Find inside this file function _get_protocol and replace it with new content as mentioned above.

litinoveweedle commented 3 years ago

EDIT: I was already sleeping yesterday, so I am sorry but I screwed the code example having wrong order of the raise. :-o Sorry. Now it is corrected, please use it as it is now.

OK, here is refactored same hack - but this time little bit more elegant, as credentials are reloaded only as consequences of protocol reset. If you decide to try this one please do not use previous one.

in the pytradfri/api/aiocoap_api.py change content of _get_response into:


    async def _get_response(self, msg):
        """Perform the request, get the response."""
        try:
            protocol = await self._get_protocol()
            pr = protocol.request(msg)
            r = await pr.response
            return pr, r
        except CredentialsMissingError as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise ServerError("There was an error with the request.", e)
        except ConstructionRenderableError as e:
            raise ClientError("There was an error with the request.", e)
        except RequestTimedOut as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise RequestTimeout("Request timed out.", e)
        except LibraryShutdown:
            raise
        except Error as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise ServerError("There was an error with the request.", e)
        except asyncio.CancelledError as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise e

I did deployed this on my 0.118.4 and I can at least confirm, that is has no impact to tradfri function so far. ;-)

rubenbe commented 3 years ago

I've installed the patch too on 0.118.4. "unfortunately" I do see the issue far less than when I initially reported it.

onkelbeh commented 3 years ago

Here at my site, the integration is now running for 5 days without problems, since I did a manual update of the gateway (https://github.com/home-assistant/core/issues/42563#issuecomment-735208731).

Usually, the gateway is not allowed to talk to the internet, I left the NAT active after the update. Today I removed the NAT rule to see if it stays OK.

jonaslorander commented 3 years ago

EDIT: I was already sleeping yesterday, so I am sorry but I screwed the code example having wrong order of the raise. :-o Sorry. Now it is corrected, please use it as it is now.

OK, here is refactored same hack - but this time little bit more elegant, as credentials are reloaded only as consequences of protocol reset. If you decide to try this one please do not use previous one.

in the pytradfri/api/aiocoap_api.py change content of _get_response into:


    async def _get_response(self, msg):
        """Perform the request, get the response."""
        try:
            protocol = await self._get_protocol()
            pr = protocol.request(msg)
            r = await pr.response
            return pr, r
        except CredentialsMissingError as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise ServerError("There was an error with the request.", e)
        except ConstructionRenderableError as e:
            raise ClientError("There was an error with the request.", e)
        except RequestTimedOut as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise RequestTimeout("Request timed out.", e)
        except LibraryShutdown:
            raise
        except Error as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise ServerError("There was an error with the request.", e)
        except asyncio.CancelledError as e:
            await self._reset_protocol(e)
            await self._update_credentials()
            raise e

I did deployed this on my 0.118.4 and I can at least confirm, that is has no impact to tradfri function so far. ;-)

Hi,

I have tested this code above, since I also are having issues with TRÅDFRI integration being disconnected two or three times per week. I added the code around 48h ago, and today the integration failed yet again. When my wife left to pick up our kids the light was supposed to turn off, but the didn't, instead I had this error log waiting for me:

2020-12-09 16:07:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65567]: {'3312': [{'5850': 0}]}>: {"r":"02"}
2020-12-09 16:07:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65573]: {'3311': [{'5850': 0}]}>: {"r":"02"}
2020-12-09 16:07:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65586]: {'3311': [{'5850': 0}]}>: {"r":"02"}
2020-12-09 16:07:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65538]: {'3311': [{'5850': 0}]}>: {"r":"02"}
2020-12-09 16:07:30 WARNING (MainThread) [homeassistant.components.tradfri.base_class] Observation failed for None
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 888, in _run_observation
    weak_observation().callback(full_notification)
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 1034, in callback
    c(response)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 190, in success_callback
    api_command.result = _process_output(res)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/command.py", line 77, in result
    self._result = self._process_result(value)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/resource.py", line 47, in observe_callback
    callback(self)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/base_class.py", line 87, in _observe_update
    self._refresh(device)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/light.py", line 265, in _refresh
    self._device_control = device.light_control
  File "/usr/local/lib/python3.8/site-packages/pytradfri/device/__init__.py", line 53, in light_control
    return LightControl(self)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/device/light_control.py", line 38, in __init__
    if ATTR_LIGHT_DIMMER in self.raw[0]:
  File "/usr/local/lib/python3.8/site-packages/pytradfri/device/light_control.py", line 69, in raw
    return self._device.raw[ATTR_LIGHT_CONTROL]
KeyError: '3311'
2020-12-09 16:07:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command get ['15001', None]>: Not Found
2020-12-09 16:13:30 WARNING (MainThread) [homeassistant.components.tradfri.base_class] Observation failed for Fönster matrum
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 888, in _run_observation
    weak_observation().callback(full_notification)
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 1034, in callback
    c(response)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 190, in success_callback
    api_command.result = _process_output(res)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 256, in _process_output
    raise ClientError(output)
pytradfri.error.ClientError: {"r":"02"}
2020-12-09 16:13:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command get ['15001', 65583]>: {"r":"02"}
2020-12-09 16:13:30 WARNING (MainThread) [homeassistant.components.tradfri.base_class] Observation failed for None
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 888, in _run_observation
    weak_observation().callback(full_notification)
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 1034, in callback
    c(response)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 190, in success_callback
    api_command.result = _process_output(res)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/command.py", line 77, in result
    self._result = self._process_result(value)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/resource.py", line 47, in observe_callback
    callback(self)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/base_class.py", line 87, in _observe_update
    self._refresh(device)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/switch.py", line 36, in _refresh
    self._device_data = device.socket_control.sockets[0]
AttributeError: 'NoneType' object has no attribute 'sockets'
2020-12-09 16:13:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command get ['15001', None]>: Not Found
2020-12-09 16:13:30 WARNING (MainThread) [homeassistant.components.tradfri.base_class] Observation failed for None
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 888, in _run_observation
    weak_observation().callback(full_notification)
  File "/usr/local/lib/python3.8/site-packages/aiocoap/protocol.py", line 1034, in callback
    c(response)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/api/aiocoap_api.py", line 190, in success_callback
    api_command.result = _process_output(res)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/command.py", line 77, in result
    self._result = self._process_result(value)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/resource.py", line 47, in observe_callback
    callback(self)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/base_class.py", line 87, in _observe_update
    self._refresh(device)
  File "/usr/src/homeassistant/homeassistant/components/tradfri/light.py", line 265, in _refresh
    self._device_control = device.light_control
  File "/usr/local/lib/python3.8/site-packages/pytradfri/device/__init__.py", line 53, in light_control
    return LightControl(self)
  File "/usr/local/lib/python3.8/site-packages/pytradfri/device/light_control.py", line 38, in __init__
    if ATTR_LIGHT_DIMMER in self.raw[0]:
  File "/usr/local/lib/python3.8/site-packages/pytradfri/device/light_control.py", line 69, in raw
    return self._device.raw[ATTR_LIGHT_CONTROL]
KeyError: '3311'
2020-12-09 16:13:30 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command get ['15001', None]>: Not Found

And immediately after that my zeroconf started spamming me with errors for about three hours:

2020-12-09 17:02:19 WARNING (zeroconf-ServiceBrowser__googlecast._tcp.local._290) [homeassistant.components.cast.discovery] setup_internal_discovery failed to get info for 322f7ec3-a593-46b4-b077-02212951e1c1, Google-Cast-Group-322f7ec3a59346b4b07702212951e1c1._googlecast._tcp.local.
2020-12-09 17:21:15 WARNING (zeroconf-ServiceBrowser__googlecast._tcp.local._290) [homeassistant.components.cast.discovery] setup_internal_discovery failed to get info for 322f7ec3-a593-46b4-b077-02212951e1c1, Google-Cast-Group-322f7ec3a59346b4b07702212951e1c1._googlecast._tcp.local.
2020-12-09 17:43:10 ERROR (zeroconf-ServiceBrowser__coap._udp.local.-_googlecast._tcp.local.-_tivo-remote._tcp.local.-_appletv-v2._tcp.local.-_Volumio._tcp.local.-_axis-video._tcp.local.-_spotify-connect._tcp.local.-_miio._udp.local.-_hass-ios._tcp.local.-_hap._tcp.local.-_soundtouch._tcp.local.-_http._tcp.local.-_musc._tcp.local.-_lg-smart-device._tcp.local.-_fbx-api._tcp.local.-_home-assistant._tcp.local.-_printer._tcp.local.-_lutron._tcp.local.-_hass-mobile-app._tcp.local.-_arduino._tcp.local.-_e2stream._tcp.local.-_nanoleafapi._tcp.local.-_esphomelib._tcp.local._2781) [netdisco.mdns] Failed to add service L�V.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/netdisco/mdns.py", line 53, in _service_update
    service.add_service(zeroconf, service_type, name)
  File "/usr/local/lib/python3.8/site-packages/netdisco/discoverables/__init__.py", line 109, in add_service
    service = zconf.get_service_info(typ, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2448, in get_service_info
    info = ServiceInfo(type_, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 1798, in __init__
    if not type_.endswith(service_type_name(name, strict=False)):
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 293, in service_type_name
    raise BadTypeInNameException("Type '%s' must end with '%s'" % (type_, _LOCAL_TRAILER))
zeroconf.BadTypeInNameException: Type 'L�V.' must end with '.local.'
2020-12-09 17:48:31 ERROR (zeroconf-ServiceBrowser__coap._udp.local.-_googlecast._tcp.local.-_tivo-remote._tcp.local.-_appletv-v2._tcp.local.-_Volumio._tcp.local.-_axis-video._tcp.local.-_spotify-connect._tcp.local.-_miio._udp.local.-_hass-ios._tcp.local.-_hap._tcp.local.-_soundtouch._tcp.local.-_http._tcp.local.-_musc._tcp.local.-_lg-smart-device._tcp.local.-_fbx-api._tcp.local.-_home-assistant._tcp.local.-_printer._tcp.local.-_lutron._tcp.local.-_hass-mobile-app._tcp.local.-_arduino._tcp.local.-_e2stream._tcp.local.-_nanoleafapi._tcp.local.-_esphomelib._tcp.local._2785) [netdisco.mdns] Failed to add service L�V.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/netdisco/mdns.py", line 53, in _service_update
    service.add_service(zeroconf, service_type, name)
  File "/usr/local/lib/python3.8/site-packages/netdisco/discoverables/__init__.py", line 109, in add_service
    service = zconf.get_service_info(typ, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2448, in get_service_info
    info = ServiceInfo(type_, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 1798, in __init__
    if not type_.endswith(service_type_name(name, strict=False)):
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 293, in service_type_name
    raise BadTypeInNameException("Type '%s' must end with '%s'" % (type_, _LOCAL_TRAILER))
zeroconf.BadTypeInNameException: Type 'L�V.' must end with '.local.'
2020-12-09 17:53:44 ERROR (zeroconf-ServiceBrowser__coap._udp.local.-_googlecast._tcp.local.-_tivo-remote._tcp.local.-_appletv-v2._tcp.local.-_Volumio._tcp.local.-_axis-video._tcp.local.-_spotify-connect._tcp.local.-_miio._udp.local.-_hass-ios._tcp.local.-_hap._tcp.local.-_soundtouch._tcp.local.-_http._tcp.local.-_musc._tcp.local.-_lg-smart-device._tcp.local.-_fbx-api._tcp.local.-_home-assistant._tcp.local.-_printer._tcp.local.-_lutron._tcp.local.-_hass-mobile-app._tcp.local.-_arduino._tcp.local.-_e2stream._tcp.local.-_nanoleafapi._tcp.local.-_esphomelib._tcp.local._2789) [netdisco.mdns] Failed to add service L�V.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/netdisco/mdns.py", line 53, in _service_update
    service.add_service(zeroconf, service_type, name)
  File "/usr/local/lib/python3.8/site-packages/netdisco/discoverables/__init__.py", line 109, in add_service
    service = zconf.get_service_info(typ, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2448, in get_service_info
    info = ServiceInfo(type_, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 1798, in __init__
    if not type_.endswith(service_type_name(name, strict=False)):
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 293, in service_type_name
    raise BadTypeInNameException("Type '%s' must end with '%s'" % (type_, _LOCAL_TRAILER))
zeroconf.BadTypeInNameException: Type 'L�V.' must end with '.local.'
2020-12-09 17:58:57 ERROR (zeroconf-ServiceBrowser__coap._udp.local.-_googlecast._tcp.local.-_tivo-remote._tcp.local.-_appletv-v2._tcp.local.-_Volumio._tcp.local.-_axis-video._tcp.local.-_spotify-connect._tcp.local.-_miio._udp.local.-_hass-ios._tcp.local.-_hap._tcp.local.-_soundtouch._tcp.local.-_http._tcp.local.-_musc._tcp.local.-_lg-smart-device._tcp.local.-_fbx-api._tcp.local.-_home-assistant._tcp.local.-_printer._tcp.local.-_lutron._tcp.local.-_hass-mobile-app._tcp.local.-_arduino._tcp.local.-_e2stream._tcp.local.-_nanoleafapi._tcp.local.-_esphomelib._tcp.local._2793) [netdisco.mdns] Failed to add service L�V.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/netdisco/mdns.py", line 53, in _service_update
    service.add_service(zeroconf, service_type, name)
  File "/usr/local/lib/python3.8/site-packages/netdisco/discoverables/__init__.py", line 109, in add_service
    service = zconf.get_service_info(typ, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2448, in get_service_info
    info = ServiceInfo(type_, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 1798, in __init__
    if not type_.endswith(service_type_name(name, strict=False)):
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 293, in service_type_name
    raise BadTypeInNameException("Type '%s' must end with '%s'" % (type_, _LOCAL_TRAILER))
zeroconf.BadTypeInNameException: Type 'L�V.' must end with '.local.'
2020-12-09 18:04:10 ERROR (zeroconf-ServiceBrowser__coap._udp.local.-_googlecast._tcp.local.-_tivo-remote._tcp.local.-_appletv-v2._tcp.local.-_Volumio._tcp.local.-_axis-video._tcp.local.-_spotify-connect._tcp.local.-_miio._udp.local.-_hass-ios._tcp.local.-_hap._tcp.local.-_soundtouch._tcp.local.-_http._tcp.local.-_musc._tcp.local.-_lg-smart-device._tcp.local.-_fbx-api._tcp.local.-_home-assistant._tcp.local.-_printer._tcp.local.-_lutron._tcp.local.-_hass-mobile-app._tcp.local.-_arduino._tcp.local.-_e2stream._tcp.local.-_nanoleafapi._tcp.local.-_esphomelib._tcp.local._2800) [netdisco.mdns] Failed to add service L�V.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/netdisco/mdns.py", line 53, in _service_update
    service.add_service(zeroconf, service_type, name)
  File "/usr/local/lib/python3.8/site-packages/netdisco/discoverables/__init__.py", line 109, in add_service
    service = zconf.get_service_info(typ, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2448, in get_service_info
    info = ServiceInfo(type_, name)
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 1798, in __init__
    if not type_.endswith(service_type_name(name, strict=False)):
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 293, in service_type_name
    raise BadTypeInNameException("Type '%s' must end with '%s'" % (type_, _LOCAL_TRAILER))
zeroconf.BadTypeInNameException: Type 'L�V.' must end with '.local.'

I see these zeroconf error frequently appear at the same time that my TRÅDFRI integratin stops working. When I reloaded the integration I got spammed with 150 of these, with the same timestamp:

2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>

I've had these issues with disconnecting TRÅDFRI for about two month now I think, and it ususally happends during the night, so in the morning the light wont be controllable from Home Assistant.

Google Home and the TRÅDFRI apps work like they should.

litinoveweedle commented 3 years ago

Thank you for logs.

  1. Your initial problem is not related to the issue I patched.
  2. I patched missing credentials error and coap protocol recovery after it goes to shutdown state.

So if your integration worked after: 2020-12-09 20:16:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']> that patch worked as intended. ;-)

As previously after error coap protocol was not able to recover and only kept firing messages like: 2020-11-28 10:30:40 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65543]: {'15015': [{'5523': True}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://172.16.4.90:5684/15001/65543'))

litinoveweedle commented 3 years ago

If you ask what caused your issue I honestly do not know. But around the line which raise your error is written as comment:

 # FIXME verify that this loop actually ends iff the observation
 # was cancelled -- otherwise find out the cause(s) or make it not
 # cancel under indistinguishable circumstances

If I was one to judge it doesn't seems to be Tradri to blame, rather very patchy code of aiocoap library.

jonaslorander commented 3 years ago

Yeah, you are right, thanks for pointing it out. I agree the aiocoap seems a bit buggy, and it contains a lot of FIXME comments.

rubenbe commented 3 years ago

@litinoveweedle I'm pretty sure your proposed patch solves the bug (or at least very much improves situation). I applied your patch 15 days ago, and did not have any issue since then. [0] Today I upgrade to 2020.12.0 and guess what, the problem immediately re-appears.

I'd propose we make a pull request out of this? Unless other people in this thread have seen issues with that patch.

[0] https://github.com/home-assistant/core/issues/42563#issuecomment-735933905

litinoveweedle commented 3 years ago

@ggravlingen, would you be please so kind and propose as code owner best way to go? As it seems that that patch is working I would like to ask you to patch current HA code base - you can take all credit for it, I am just too lazy to do any administrative steps required for PR acceptance. ;-)

ggravlingen commented 3 years ago

Very good investigation and testing having been going on here. The steps required now are:

rubenbe commented 3 years ago

I can take this whole merging administration up if you don't have the time @ggravlingen

ggravlingen commented 3 years ago

@rubenbe yes please, that would be great. It's good for the HA project that there are more of us working on patches and fixes. :)

litinoveweedle commented 3 years ago

I can take this whole merging administration up if you don't have the time @ggravlingen

@rubenbe thank you, that would be great!

ginodp commented 3 years ago

How do I apply this patch? I don't have the "pytradfri/api/aiocoap_api.py" dir and files!

Do I need to add them myself?

Thanks in advance

ggravlingen commented 3 years ago

This is no answer to your question but the patch is in the next minor release: https://github.com/home-assistant/core/milestone/372?closed=1

No idea when it will be released though.

ginodp commented 3 years ago

Very nice that it will be patched. But I like to add it now to my config. Am reloading like way 2 many times for my taste a day. Are you on discord? Otherwise I'll figure it out.

Thanks

ggravlingen commented 3 years ago

Sorry, I haven’t done it myself but maybe this post above could be of help?

https://github.com/home-assistant/core/issues/42563#issuecomment-735452973

ginodp commented 3 years ago

Thanks. Exactly the info I needed. I must have scrolled past it.

rubenbe commented 3 years ago

Release 2020.12.2 contains the fix for this issue.

kjetilsn commented 3 years ago

Hi, I still have the same problem with version 2021.1.0

Unable to execute command <Command put ['15001', 65568]: {'3311': [{'5850': 0}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://10.0.0.133:5684/15001/65568'))

Protocol is shutdown, cancelling command: 10.0.0.133 <Command get ['15011', '15012']> Protocol is shutdown, cancelling command: 10.0.0.133 <Command put ['15001', 65570]: {'3311': [{'5850': 1}]}>

antonbo commented 3 years ago

I still have the same problem with version 2021.1.0

Also lost connection but due to Trådfri hub restart during its update. So I would say it is a different issue

rubenbe commented 3 years ago

@kjetilsn @antonbo thanks for reporting. It seems we've fixed only one root cause, but there are other(s?) remaining. I saw the issue once two days ago too (first time in weeks).

I do know there are some discussions & development regarding the libraries that implement the low level communication with the Tradfri gateway (libcoap & libtradfri).

litinoveweedle commented 3 years ago

Just some basic info as there are at least two issues:

Please try to distinguish between issues before you post something not related and potentially misleading for others.

rubenbe commented 3 years ago

It seems that there are no more exceptions (good!) But it didn't seem to have recovered automatically.

2021-01-11 21:14:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:14:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9107":0,"9023":"1.tradfri.pool.ntp.org","9059":1610399650,"9055":0,"9060":"2021-01-11T21:14:10.029640Z","9106":0,"9062":0,"9204":0,"9061":0,"9079":0,"9029":"1.12.34","9080":60,"9081":"7e11515204400072","9082":true,"9078":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9083":"827-73-893","9076":10,"9054":0,"9066":5,"9069":1608582533,"9072":3,"9071":1,"9073":28,"9075":0,"9074":1,"9077":31,"9092":1,"9093":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9105":0,"9118":0,"9201":1,"9202":1590231087,"9232":777310}
2021-01-11 21:15:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:15:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9107":0,"9023":"1.tradfri.pool.ntp.org","9059":1610399710,"9055":0,"9060":"2021-01-11T21:15:10.030640Z","9106":0,"9062":0,"9204":0,"9061":0,"9079":0,"9029":"1.12.34","9080":60,"9081":"7e11515204400072","9082":true,"9078":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9083":"827-73-893","9076":10,"9054":0,"9066":5,"9069":1608582533,"9072":3,"9071":1,"9073":28,"9075":0,"9074":1,"9077":31,"9092":1,"9093":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9105":0,"9118":0,"9201":1,"9202":1590231087,"9232":777370}
2021-01-11 21:16:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:16:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9107":0,"9023":"1.tradfri.pool.ntp.org","9059":1610399770,"9055":0,"9060":"2021-01-11T21:16:10.031640Z","9106":0,"9062":0,"9204":0,"9061":0,"9079":0,"9029":"1.12.34","9080":60,"9081":"7e11515204400072","9082":true,"9078":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9083":"827-73-893","9076":10,"9054":0,"9066":5,"9069":1608582533,"9072":3,"9071":1,"9073":28,"9075":0,"9074":1,"9077":31,"9092":1,"9093":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9105":0,"9118":0,"9201":1,"9202":1590231087,"9232":777430}
2021-01-11 21:17:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:17:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9107":0,"9023":"1.tradfri.pool.ntp.org","9059":1610399830,"9055":0,"9060":"2021-01-11T21:17:10.031640Z","9106":0,"9062":0,"9204":0,"9061":0,"9079":0,"9029":"1.12.34","9080":60,"9081":"7e11515204400072","9082":true,"9078":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9083":"827-73-893","9076":10,"9054":0,"9066":5,"9069":1608582533,"9072":3,"9071":1,"9073":28,"9075":0,"9074":1,"9077":31,"9092":1,"9093":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9105":0,"9118":0,"9201":1,"9202":1590231087,"9232":777490}
2021-01-11 21:18:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:18:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9107":0,"9023":"1.tradfri.pool.ntp.org","9059":1610399890,"9055":0,"9060":"2021-01-11T21:18:10.032640Z","9106":0,"9062":0,"9204":0,"9061":0,"9079":0,"9029":"1.12.34","9080":60,"9081":"7e11515204400072","9082":true,"9078":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9083":"827-73-893","9076":10,"9054":0,"9066":5,"9069":1608582533,"9072":3,"9071":1,"9073":28,"9075":0,"9074":1,"9077":31,"9092":1,"9093":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9105":0,"9118":0,"9201":1,"9202":1590231087,"9232":777550}
2021-01-11 21:19:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:19:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9107":0,"9023":"1.tradfri.pool.ntp.org","9059":1610399935,"9055":41,"9060":"2021-01-11T21:18:55.014248Z","9106":0,"9062":0,"9204":0,"9061":0,"9079":0,"9029":"1.12.34","9080":60,"9081":"7e11515204400072","9082":true,"9078":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9083":"827-73-893","9076":10,"9054":1,"9066":5,"9069":1610399933,"9072":3,"9071":1,"9073":28,"9075":0,"9074":1,"9077":31,"9092":1,"9093":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9105":0,"9118":0,"9201":1,"9202":1590231087,"9232":777590}
2021-01-11 21:19:34 INFO (MainThread) [root] AFSAPI Exception: Traceback (most recent call last):
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"kerstboom","5750":3,"9003":65550,"9002":1576443644,"9020":1578845404,"3312":[{"5850":0,"5851":0,"9003":0}],"9054":0,"9019":0,"3":{"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","3":"2.0.022","6":1}}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI on/off switch 2","5750":0,"9003":65551,"9002":1576860900,"9020":1590093008,"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI on/off switch","2":"","3":"2.2.010","6":3,"9":47},"15009":[{"9003":0}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI bulb E27 WS opal 980lm 4","5750":2,"9003":65547,"9002":1526119894,"9020":1610219003,"9054":0,"9019":0,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","3":"2.3.050","6":1},"3311":[{"5850":1,"5717":0,"5851":254,"5711":370,"5709":30138,"9003":0,"5710":26909,"5706":"f1e0b5"}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI remote control","5750":0,"9003":65537,"9002":1491674683,"9020":1610383303,"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","3":"2.3.014","6":3,"9":16},"15009":[{"9003":0}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"grote staanlamp","5750":2,"9003":65555,"9002":1606925163,"9020":1610372708,"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","3":"2.3.050","6":1},"3311":[{"5850":1,"5717":0,"5851":254,"5711":370,"5709":30015,"9003":0,"5710":26870,"5706":"f1e0b5"}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI control outlet","5750":3,"9003":65549,"9002":1546458241,"9020":1610372801,"3312":[{"5850":1,"5851":254,"9003":0}],"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","3":"2.0.024","6":1}}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"kleine staanlamp","5750":2,"9003":65544,"9002":1514401529,"9020":1610380117,"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","3":"2.3.050","6":1},"3311":[{"5850":1,"5717":0,"5851":254,"5711":378,"5709":30015,"9003":0,"5710":26870,"5706":"0"}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"tafel","5750":2,"9003":65545,"9002":1524246043,"9020":1610383084,"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","3":"2.3.050","6":1},"3311":[{"5850":1,"5717":0,"5851":254,"5711":376,"5709":30087,"9003":0,"5710":26909,"5706":"0"}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI wireless dimmer","5750":0,"9003":65536,"9002":1492247455,"9020":1512780287,"9054":1,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI wireless dimmer","2":"","3":"1.1.1.1-5.7.2.0","6":3,"9":0},"15009":[{"9003":0}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI bulb 5","5750":2,"9003":65554,"9002":30406,"9020":1608134400,"9054":0,"9019":0,"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","3":"2.3.050","6":1},"3311":[{"5850":0,"5717":0,"5851":0,"5711":454,"5709":0,"9003":0,"5710":0,"5706":"0"}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI motion sensor","5750":4,"9003":65543,"9002":1492350000,"9020":1537644068,"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI motion sensor","2":"","3":"1.2.214","6":3,"9":11},"3300":[{"9003":0}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI on/off switch 3","5750":0,"9003":65553,"9002":1577730415,"9020":1584609665,"9054":1,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI on/off switch","2":"","3":"2.2.008","6":3,"9":100},"15009":[{"9003":0}]}
2021-01-11 21:19:37 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI remote control 2","5750":0,"9003":65552,"9002":1577196464,"9020":1596601936,"9054":0,"9019":1,"3":{"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","3":"2.3.014","6":3,"9":100},"15009":[{"9003":0}]}
2021-01-11 21:20:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:20:14 INFO (MainThread) [coap] Retransmission, Message ID: 10742.
2021-01-11 21:20:20 INFO (MainThread) [coap] Retransmission, Message ID: 10742.
2021-01-11 21:20:32 INFO (MainThread) [coap] Retransmission, Message ID: 10742.
2021-01-11 21:20:56 INFO (MainThread) [coap] Retransmission, Message ID: 10742.
2021-01-11 21:21:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:21:43 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:21:46 INFO (MainThread) [coap] Retransmission, Message ID: 10743.
2021-01-11 21:21:51 INFO (MainThread) [coap] Retransmission, Message ID: 10743.
2021-01-11 21:22:00 INFO (MainThread) [coap] Retransmission, Message ID: 10743.
2021-01-11 21:22:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:22:20 INFO (MainThread) [coap] Retransmission, Message ID: 10743.
2021-01-11 21:22:58 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:23:01 INFO (MainThread) [coap] Retransmission, Message ID: 10744.
2021-01-11 21:23:07 INFO (MainThread) [coap] Retransmission, Message ID: 10744.
2021-01-11 21:23:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:23:18 INFO (MainThread) [coap] Retransmission, Message ID: 10744.
2021-01-11 21:23:41 INFO (MainThread) [coap] Retransmission, Message ID: 10744.
2021-01-11 21:24:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:24:26 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:24:29 INFO (MainThread) [coap] Retransmission, Message ID: 10745.
2021-01-11 21:24:33 INFO (MainThread) [coap] Retransmission, Message ID: 10745.
2021-01-11 21:24:42 INFO (MainThread) [coap] Retransmission, Message ID: 10745.
2021-01-11 21:25:00 INFO (MainThread) [coap] Retransmission, Message ID: 10745.
2021-01-11 21:25:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:25:35 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:25:38 INFO (MainThread) [coap] Retransmission, Message ID: 10746.
2021-01-11 21:25:43 INFO (MainThread) [coap] Retransmission, Message ID: 10746.
2021-01-11 21:25:53 INFO (MainThread) [coap] Retransmission, Message ID: 10746.
2021-01-11 21:26:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:26:14 INFO (MainThread) [coap] Retransmission, Message ID: 10746.
2021-01-11 21:26:55 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:26:58 INFO (MainThread) [coap] Retransmission, Message ID: 10747.
2021-01-11 21:27:03 INFO (MainThread) [coap] Retransmission, Message ID: 10747.
2021-01-11 21:27:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:27:14 INFO (MainThread) [coap] Retransmission, Message ID: 10747.
2021-01-11 21:27:35 INFO (MainThread) [coap] Retransmission, Message ID: 10747.
2021-01-11 21:28:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:28:18 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:28:20 INFO (MainThread) [coap] Retransmission, Message ID: 10748.
2021-01-11 21:28:25 INFO (MainThread) [coap] Retransmission, Message ID: 10748.
2021-01-11 21:28:34 INFO (MainThread) [coap] Retransmission, Message ID: 10748.
2021-01-11 21:28:52 INFO (MainThread) [coap] Retransmission, Message ID: 10748.
2021-01-11 21:29:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:29:28 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:29:31 INFO (MainThread) [coap] Retransmission, Message ID: 10749.
2021-01-11 21:29:36 INFO (MainThread) [coap] Retransmission, Message ID: 10749.
2021-01-11 21:29:47 INFO (MainThread) [coap] Retransmission, Message ID: 10749.
2021-01-11 21:30:00 INFO (MainThread) [homeassistant.components.automation.turn_off_the_lights_in_the_living_at_22h30] Turn off the lights in the Living at 22h30: Running automation actions
2021-01-11 21:30:00 INFO (MainThread) [homeassistant.components.automation.turn_off_the_lights_in_the_living_at_22h30] Turn off the lights in the Living at 22h30: Executing step activate scene
2021-01-11 21:30:00 WARNING (MainThread) [homeassistant.components.switch.reproduce_state] Invalid state specified for switch.iets: unavailable
2021-01-11 21:30:00 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command put ['15001', 65544]: {'3311': [{'5850': 0}]}>
2021-01-11 21:30:00 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command put ['15001', 65549]: {'3312': [{'5850': 0}]}>
2021-01-11 21:30:09 INFO (MainThread) [coap] Retransmission, Message ID: 10749.
2021-01-11 21:30:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:30:51 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:30:54 INFO (MainThread) [coap] Retransmission, Message ID: 10750.
2021-01-11 21:31:00 INFO (MainThread) [coap] Retransmission, Message ID: 10750.
2021-01-11 21:31:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:31:12 INFO (MainThread) [coap] Retransmission, Message ID: 10750.
2021-01-11 21:31:35 INFO (MainThread) [coap] Retransmission, Message ID: 10750.
2021-01-11 21:32:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:32:21 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:32:23 INFO (MainThread) [coap] Retransmission, Message ID: 10751.
2021-01-11 21:32:29 INFO (MainThread) [coap] Retransmission, Message ID: 10751.
2021-01-11 21:32:41 INFO (MainThread) [coap] Retransmission, Message ID: 10751.
2021-01-11 21:33:03 INFO (MainThread) [coap] Retransmission, Message ID: 10751.
2021-01-11 21:33:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:33:49 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:33:51 INFO (MainThread) [coap] Retransmission, Message ID: 10752.
2021-01-11 21:33:56 INFO (MainThread) [coap] Retransmission, Message ID: 10752.
2021-01-11 21:34:05 INFO (MainThread) [coap] Retransmission, Message ID: 10752.
2021-01-11 21:34:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:34:24 INFO (MainThread) [coap] Retransmission, Message ID: 10752.
2021-01-11 21:35:01 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:35:03 INFO (MainThread) [coap] Retransmission, Message ID: 10753.
2021-01-11 21:35:08 INFO (MainThread) [coap] Retransmission, Message ID: 10753.
2021-01-11 21:35:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:35:18 INFO (MainThread) [coap] Retransmission, Message ID: 10753.
2021-01-11 21:35:25 INFO (MainThread) [root] AFSAPI Exception: Traceback (most recent call last):
2021-01-11 21:35:38 INFO (MainThread) [coap] Retransmission, Message ID: 10753.
2021-01-11 21:36:11 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:18 INFO (MainThread) [coap] Exchange timed out
2021-01-11 21:36:21 INFO (MainThread) [coap] Retransmission, Message ID: 10754.
2021-01-11 21:36:25 INFO (MainThread) [coap] Retransmission, Message ID: 10754.
2021-01-11 21:36:34 INFO (MainThread) [coap] Retransmission, Message ID: 10754.
2021-01-11 21:36:51 INFO (SyncWorker_1) [homeassistant.loader] Loaded fireservicerota from homeassistant.components.fireservicerota
...
2021-01-11 21:36:51 INFO (SyncWorker_2) [homeassistant.loader] Loaded azure_devops from homeassistant.components.azure_devops
2021-01-11 21:36:51 INFO (MainThread) [coap] Retransmission, Message ID: 10754.
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Resetting protocol
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command put ['15001', 65544]: {'3311': [{'5850': 0}]}>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command put ['15001', 65549]: {'3312': [{'5850': 0}]}>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command put ['15001', 65555]: {'3311': [{'5850': 0}]}>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command put ['15001', 65549]: {'3312': [{'5850': 0}]}>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:36:57 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65555]: {'3311': [{'5850': 0}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://10.17.0.4:5684/15001/65555'))
2021-01-11 21:36:57 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65549]: {'3312': [{'5850': 0}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://10.17.0.4:5684/15001/65549'))
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command put ['15001', 65545]: {'3311': [{'5850': 0}]}>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command put ['15001', 65549]: {'3312': [{'5850': 1}]}>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9023":"1.tradfri.pool.ntp.org","9107":0,"9059":1610401016,"9060":"2021-01-11T21:36:56.048496Z","9083":"827-73-893","9073":28,"9062":0,"9093":0,"9232":970,"9061":0,"9071":1,"9202":1590231087,"9054":0,"9029":"1.13.19","9081":"7e11515204400072","9080":60,"9082":true,"9069":1610399933,"9055":100,"9066":5,"9072":3,"9076":10,"9074":1,"9075":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9208":0,"9077":31,"9078":1,"9079":0,"9106":0,"9209":0,"9092":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9105":0,"9118":0,"9204":0,"9211":0,"9201":1}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001']>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: [65536,65554,65547,65555,65549,65544,65545,65537,65550,65551,65543,65553,65552]
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65536]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65554]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65547]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65555]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65549]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65544]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65545]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65537]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65550]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65551]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65543]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65553]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15001', 65552]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI wireless dimmer","2":"","6":3,"3":"1.1.1.1-5.7.2.0","9":0},"9001":"TRADFRI wireless dimmer","9003":65536,"9002":1492247455,"9020":1512780287,"9054":1,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"TRADFRI bulb 5","9003":65554,"9002":30406,"9020":1610400098,"9054":0,"9019":1,"5750":2,"3311":[{"5850":1,"5717":0,"5851":254,"5711":376,"5709":30087,"5710":26909,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"TRADFRI bulb E27 WS opal 980lm 4","9003":65547,"9002":1526119894,"9020":1610219003,"9054":0,"9019":0,"5750":2,"3311":[{"5850":0,"5717":0,"5851":0,"5711":454,"5709":0,"5710":0,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"grote staanlamp","9003":65555,"9002":1606925163,"9020":1610400098,"9054":0,"9019":1,"5750":2,"3311":[{"5850":0,"5717":0,"5851":254,"5711":370,"5709":30015,"5710":26870,"5706":"f1e0b5","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","6":1,"3":"2.0.024"},"9001":"TRADFRI control outlet","9003":65549,"9002":1546458241,"3312":[{"5850":1,"5851":254,"9003":0}],"9020":1610400098,"9054":0,"9019":1,"5750":3}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"kleine staanlamp","9003":65544,"9002":1514401529,"9020":1610400098,"9054":0,"9019":1,"5750":2,"3311":[{"5850":0,"5717":0,"5851":254,"5711":378,"5709":30015,"5710":26870,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"tafel","9003":65545,"9002":1524246043,"9020":1610383084,"9054":0,"9019":0,"5750":2,"3311":[{"5850":0,"5717":0,"5851":0,"5711":454,"5709":0,"5710":0,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","6":3,"3":"2.3.014","9":16},"9001":"TRADFRI remote control","9003":65537,"9002":1491674683,"9020":1610383303,"9054":0,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","6":1,"3":"2.0.022"},"9001":"kerstboom","9003":65550,"9002":1576443644,"3312":[{"5850":0,"5851":0,"9003":0}],"9020":1578845404,"9054":0,"9019":0,"5750":3}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI on/off switch","2":"","6":3,"3":"2.2.010","9":47},"9001":"TRADFRI on/off switch 2","9003":65551,"9002":1576860900,"9020":1590093008,"9054":0,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3300":[{"9003":0}],"3":{"0":"IKEA of Sweden","1":"TRADFRI motion sensor","2":"","6":3,"3":"1.2.214","9":11},"9001":"TRADFRI motion sensor","9003":65543,"9002":1492350000,"9020":1537644068,"9054":0,"9019":1,"5750":4}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI on/off switch","2":"","6":3,"3":"2.2.008","9":100},"9001":"TRADFRI on/off switch 3","9003":65553,"9002":1577730415,"9020":1584609665,"9054":1,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","6":3,"3":"2.3.014","9":100},"9001":"TRADFRI remote control 2","9003":65552,"9002":1577196464,"9020":1596601936,"9054":0,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15004']>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: [135527,190498,149866,190496,190497,190494]
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15004', 135527]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15004', 190498]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15004', 149866]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15004', 190496]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15004', 190497]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15004', 190494]>
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI group 3","9108":0,"9002":1492247461,"9003":135527,"5850":0,"5851":0,"9039":208421,"9018":{"15002":{"9003":[65536]}}}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"SuperGroup","9108":2,"9002":1606298798,"9003":190498,"5850":0,"5851":0,"9039":228659,"9018":{"15002":{"9003":[65545,65555,65554]}}}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Living","9108":0,"9002":1491674695,"9003":149866,"5850":0,"5851":0,"9039":205195,"9018":{"15002":{"9003":[65537,65550,65545,65544,65552,65555,65554]}}}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI group 6","9108":0,"9002":1576860899,"9003":190496,"5850":0,"5851":0,"9039":228653,"9018":{"15002":{"9003":[65551]}}}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Slaapkamer","9108":0,"9002":1577730415,"9003":190497,"5850":0,"5851":0,"9039":228656,"9018":{"15002":{"9003":[65553,65549,65547]}}}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"TRADFRI group 4","9108":0,"9002":1492350010,"9003":190494,"5850":0,"5851":0,"9039":209125,"9018":{"15002":{"9003":[65543]}}}
2021-01-11 21:36:57 INFO (MainThread) [homeassistant.components.cover] Setting up cover.tradfri
2021-01-11 21:36:57 INFO (MainThread) [homeassistant.components.light] Setting up light.tradfri
2021-01-11 21:36:57 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.tradfri
2021-01-11 21:36:57 INFO (MainThread) [homeassistant.components.switch] Setting up switch.tradfri
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"TRADFRI bulb 5","9003":65554,"9002":30406,"9020":1610400098,"9054":0,"9019":1,"5750":2,"3311":[{"5850":1,"5717":0,"5851":254,"5711":376,"5709":30087,"5710":26909,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"TRADFRI bulb E27 WS opal 980lm 4","9003":65547,"9002":1526119894,"9020":1610219003,"9054":0,"9019":0,"5750":2,"3311":[{"5850":0,"5717":0,"5851":0,"5711":454,"5709":0,"5710":0,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"grote staanlamp","9003":65555,"9002":1606925163,"9020":1610400098,"9054":0,"9019":1,"5750":2,"3311":[{"5850":0,"5717":0,"5851":254,"5711":370,"5709":30015,"5710":26870,"5706":"f1e0b5","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"kleine staanlamp","9003":65544,"9002":1514401529,"9020":1610400098,"9054":0,"9019":1,"5750":2,"3311":[{"5850":0,"5717":0,"5851":254,"5711":378,"5709":30015,"5710":26870,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","6":1,"3":"2.3.050"},"9001":"tafel","9003":65545,"9002":1524246043,"9020":1610383084,"9054":0,"9019":0,"5750":2,"3311":[{"5850":0,"5717":0,"5851":0,"5711":454,"5709":0,"5710":0,"5706":"0","9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI wireless dimmer","2":"","6":3,"3":"1.1.1.1-5.7.2.0","9":0},"9001":"TRADFRI wireless dimmer","9003":65536,"9002":1492247455,"9020":1512780287,"9054":1,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","6":3,"3":"2.3.014","9":16},"9001":"TRADFRI remote control","9003":65537,"9002":1491674683,"9020":1610383303,"9054":0,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI on/off switch","2":"","6":3,"3":"2.2.010","9":47},"9001":"TRADFRI on/off switch 2","9003":65551,"9002":1576860900,"9020":1590093008,"9054":0,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3300":[{"9003":0}],"3":{"0":"IKEA of Sweden","1":"TRADFRI motion sensor","2":"","6":3,"3":"1.2.214","9":11},"9001":"TRADFRI motion sensor","9003":65543,"9002":1492350000,"9020":1537644068,"9054":0,"9019":1,"5750":4}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI on/off switch","2":"","6":3,"3":"2.2.008","9":100},"9001":"TRADFRI on/off switch 3","9003":65553,"9002":1577730415,"9020":1584609665,"9054":1,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","6":3,"3":"2.3.014","9":100},"9001":"TRADFRI remote control 2","9003":65552,"9002":1577196464,"9020":1596601936,"9054":0,"9019":1,"5750":0,"15009":[{"9003":0}]}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","6":1,"3":"2.0.024"},"9001":"TRADFRI control outlet","9003":65549,"9002":1546458241,"3312":[{"5850":1,"5851":254,"9003":0}],"9020":1610400098,"9054":0,"9019":1,"5750":3}
2021-01-11 21:36:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","6":1,"3":"2.0.022"},"9001":"kerstboom","9003":65550,"9002":1576443644,"3312":[{"5850":0,"5851":0,"9003":0}],"9020":1578845404,"9054":0,"9019":0,"5750":3}
2021-01-11 21:37:13 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command put ['15001', 65549]: {'3312': [{'5850': 0}]}>
2021-01-11 21:37:13 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-11 21:37:13 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"3":{"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","6":1,"3":"2.0.024"},"9001":"TRADFRI control outlet","9003":65549,"9002":1546458241,"3312":[{"5850":0,"5851":254,"9003":0}],"9020":1610400098,"9054":0,"9019":1,"5750":3}
2021-01-11 21:37:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:37:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9023":"1.tradfri.pool.ntp.org","9107":0,"9059":1610401077,"9060":"2021-01-11T21:37:57.024928Z","9083":"827-73-893","9073":28,"9062":0,"9093":0,"9232":1030,"9061":0,"9071":1,"9202":1590231087,"9054":0,"9029":"1.13.19","9081":"7e11515204400072","9080":60,"9082":true,"9069":1610399933,"9055":100,"9066":5,"9072":3,"9076":10,"9074":1,"9075":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9208":0,"9077":31,"9078":1,"9079":0,"9106":0,"9209":0,"9092":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9105":0,"9118":0,"9204":0,"9211":0,"9201":1}
2021-01-11 21:38:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:38:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9023":"1.tradfri.pool.ntp.org","9107":0,"9059":1610401137,"9060":"2021-01-11T21:38:57.040464Z","9083":"827-73-893","9073":28,"9062":0,"9093":0,"9232":1090,"9061":0,"9071":1,"9202":1590231087,"9054":0,"9029":"1.13.19","9081":"7e11515204400072","9080":60,"9082":true,"9069":1610399933,"9055":100,"9066":5,"9072":3,"9076":10,"9074":1,"9075":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9208":0,"9077":31,"9078":1,"9079":0,"9106":0,"9209":0,"9092":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9105":0,"9118":0,"9204":0,"9211":0,"9201":1}
2021-01-11 21:39:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 10.17.0.4 <Command get ['15011', '15012']>
2021-01-11 21:39:57 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9023":"1.tradfri.pool.ntp.org","9107":0,"9059":1610401197,"9060":"2021-01-11T21:39:57.041464Z","9083":"827-73-893","9073":28,"9062":0,"9093":0,"9232":1150,"9061":0,"9071":1,"9202":1590231087,"9054":0,"9029":"1.13.19","9081":"7e11515204400072","9080":60,"9082":true,"9069":1610399933,"9055":100,"9066":5,"9072":3,"9076":10,"9074":1,"9075":0,"9200":"a865a30a-d202-4690-bb4b-1947f48f24de","9208":0,"9077":31,"9078":1,"9079":0,"9106":0,"9209":0,"9092":1,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9105":0,"9118":0,"9204":0,"9211":0,"9201":1}
litinoveweedle commented 3 years ago

It seems that there are no more exceptions (good!) But it didn't seem to have recovered automatically.

That is rather strange, what I see is

  1. timeout (expected on network problem - BTW are you able to simulate it somehow?)
  2. retransmission (expected by coap design)
  3. protocol shutdown + pending messages destroy (as expected by pytradfri design)
  4. immediately two Missing Credentials (there should not be any, this is a bit confusing....., maybe observation threads?)
  5. BUT the I see normal communication to resume!

What is the behavior of HA/devices after such dialogue? As I see normal communication to resume I would expect at least either command (to command Tradfri device) or observation (to monitor Tradfri device state) should work!

rubenbe commented 3 years ago

Wrt simulation: I previously could simulate it by unplugging the GW right before giving the command (haven't tried again recently).

HA had the similar behavior as with the original issue. I expected an automation to turn off some lights, but that didn't happen. I don't remember for sure whether I could still toggle lights manually, but I don't think so. The integration worked again as expected after reloading the tradfri component. If you have ideas for extra prints to add, feel free to throw them in my direction.

pheelee commented 3 years ago

I also had the issue after upgrading to 2021.1.0 then I removed the tradfri integration, boot host and re-added it via web interface. Since ~6 days I didn't have issues anymore.

jonaslorander commented 3 years ago

So, I have had debugging on now for a couple of weeks. This last week I have had the integration stop every other day :( Unfortunately Iäm unable to see something that might be conencted to this issue, it just seems to stop...

When the integration is working as it should, I have these debug lines every minute:

2021-01-20 08:49:54 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9023":"0.tradfri.pool.ntp.org","9075":0,"9059":1611128994,"9029":"1.13.19","9060":"2021-01-20T07:49:54.027248Z","9062":0,"9200":"4e52858d-b2b2-41ca-8424-29260e9e3d4a","9061":0,"9081":"7e1c41520440000d","9077":31,"9082":false,"9107":0,"9083":"N/A","9054":0,"9076":10,"9055":0,"9073":28,"9066":5,"9092":1,"9093":0,"9069":1610640216,"9105":1,"9232":0,"9071":1,"9079":0,"9211":0,"9072":3,"9080":60,"9074":1,"9208":1616893200,"9078":1,"9209":1635642000,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9106":0,"9118":0,"9204":0,"9201":2,"9202":1580629287}
2021-01-20 08:50:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 08:50:47 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9023":"0.tradfri.pool.ntp.org","9075":0,"9059":1611129047,"9029":"1.13.19","9060":"2021-01-20T07:50:47.027248Z","9062":0,"9200":"4e52858d-b2b2-41ca-8424-29260e9e3d4a","9061":0,"9081":"7e1c41520440000d","9077":31,"9082":false,"9107":0,"9083":"N/A","9054":0,"9076":10,"9055":0,"9073":28,"9066":5,"9092":1,"9093":0,"9069":1610640216,"9105":1,"9232":0,"9071":1,"9079":0,"9211":0,"9072":3,"9080":60,"9074":1,"9208":1616893200,"9078":1,"9209":1635642000,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9106":0,"9118":0,"9204":0,"9201":2,"9202":1580629287}

When the integration fails, I have a few different log entries.

2021-01-20 09:23:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 09:24:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 09:24:56 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-20 09:25:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 09:25:28 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-20 09:26:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 09:26:25 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-20 09:27:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 09:27:26 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-20 09:28:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 09:29:07 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-20 09:29:24 WARNING (MainThread) [coap] Error received in UDP connection under DTLS: [Errno 111] Connection refused
2021-01-24 11:02:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 11:03:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 11:04:28 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-24 11:04:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 11:05:22 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-24 11:05:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 11:06:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 11:07:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 11:08:00 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-24 11:08:43 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: 
2021-01-24 11:08:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 11:09:31 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 5.00 Internal Server Error, Received: {"r":"01"}
2021-01-24 11:09:31 ERROR (MainThread) [homeassistant.components.tradfri] Keep-alive failed

The reason I think this is when the integration stops is because after these entries I have a couple of thousand of these:

2021-01-24 13:59:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 14:00:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 14:01:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 14:02:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>

Then, when I reload the integration, this happens:

2021-01-24 16:41:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:42:55 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:42:58 WARNING (MainThread) [homeassistant.components.light.reproduce_state] Invalid state specified for light.fonster_barnrum: unavailable
2021-01-24 16:42:58 WARNING (MainThread) [homeassistant.components.light.reproduce_state] Invalid state specified for light.fonster_matrum: unavailable
2021-01-24 16:42:58 WARNING (MainThread) [homeassistant.components.switch.reproduce_state] Invalid state specified for switch.lampa_fonster: unavailable
2021-01-24 16:43:08 WARNING (MainThread) [homeassistant.components.light.reproduce_state] Invalid state specified for light.fonster_matrum: unavailable
2021-01-24 16:43:08 WARNING (MainThread) [homeassistant.components.light.reproduce_state] Invalid state specified for light.fonster_barnrum: unavailable
2021-01-24 16:43:08 WARNING (MainThread) [homeassistant.components.switch.reproduce_state] Invalid state specified for switch.lampa_fonster: unavailable
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Resetting protocol
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, stopping observation

Then a couple of thousand of these (depending on how much time has passed until I reload the integration):

2021-01-24 16:43:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:43:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:43:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:43:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>

And then the usual tradfri debugging:

2021-01-24 16:43:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:43:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:43:20 WARNING (MainThread) [pytradfri.api.aiocoap_api] Protocol is shutdown, cancelling command: 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65563]: {'3312': [{'5850': 1}]}>
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65586]: {'3311': [{'5711': 370}]}>
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15011', '15012']>
2021-01-24 16:43:20 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65563]: {'3312': [{'5850': 1}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://192.168.0.131:5684/15001/65563'))
2021-01-24 16:43:20 ERROR (MainThread) [homeassistant.components.tradfri.base_class] Unable to execute command <Command put ['15001', 65586]: {'3311': [{'5711': 370}]}>: ('There was an error with the request.', CredentialsMissingError('No suitable credentials for coaps://192.168.0.131:5684/15001/65586'))
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65586]: {'3311': [{'5851': 215}]}>
2021-01-24 16:43:20 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65580]: {'3312': [{'5850': 1}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9080":60,"9023":"0.tradfri.pool.ntp.org","9083":"N/A","9059":1611502998,"9060":"2021-01-24T15:43:18.043248Z","9107":0,"9072":3,"9103":"a1nvlh0fc0asuq.iot.eu-central-1.amazonaws.com","9062":0,"9079":0,"9066":5,"9118":0,"9061":0,"9029":"1.13.19","9081":"7e1c41520440000d","9082":false,"9054":0,"9073":28,"9055":0,"9069":1610640216,"9092":1,"9209":1635642000,"9071":1,"9093":0,"9074":1,"9075":0,"9208":1616893200,"9077":31,"9076":10,"9078":1,"9106":1,"9232":0,"9200":"4e52858d-b2b2-41ca-8424-29260e9e3d4a","9105":1,"9204":0,"9211":0,"9201":2,"9202":1580629287}
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001']>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65571]: {'3311': [{'5851': 150}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65561]: {'3312': [{'5850': 1}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: [65566,65567,65585,65583,65574,65538,65556,65586,65561,65546,65580,65571,65573,65563,65590,65588,65582,65575,65581,65536,65562,65572]
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65566]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65567]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65585]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65583]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65574]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65538]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65556]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65586]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65561]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65546]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65580]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65571]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65573]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65563]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65590]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65588]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65582]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65575]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65581]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65536]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65562]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command get ['15001', 65572]>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65573]: {'3311': [{'5851': 200, '5708': 43620, '5707': 5181}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65563]: {'3312': [{'5850': 1}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Fjärr hall","9003":65566,"9002":1541947257,"9020":1608499423,"15009":[{"9003":0}],"9054":0,"3":{"6":3,"0":"IKEA of Sweden","1":"TRADFRI on/off switch","2":"","3":"2.2.010","9":16},"9019":1,"5750":0}
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Lampa fönster","9003":65567,"9002":1541947321,"9020":1609583337,"9054":0,"3":{"6":1,"0":"IKEA of Sweden","1":"TRADFRI control outlet","2":"","3":"2.0.024"},"9019":0,"5750":3,"3312":[{"5850":0,"5851":0,"9003":0}]}
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65538]: {'3311': [{'5711': 370}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Fönster barnrum","9003":65585,"9002":1575123645,"9020":1609583382,"9054":0,"3":{"6":1,"0":"IKEA of Sweden","1":"TRADFRI bulb E14 W op/ch 400lm","2":"","3":"1.2.214"},"9019":0,"5750":2,"3311":[{"5850":0,"5851":0,"9003":0}]}
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65538]: {'3311': [{'5851': 230}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Fönster matrum","9003":65583,"9002":1575122425,"9020":1609598322,"9054":0,"3":{"6":1,"0":"IKEA of Sweden","1":"TRADFRI bulb E14 W op/ch 400lm","2":"","3":"1.2.214"},"9019":0,"5750":2,"3311":[{"5850":0,"5851":0,"9003":0}]}
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65586]: {'3311': [{'5711': 370}]}>
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Jonas Fjärrkontroll","9003":65574,"9002":1550906205,"9020":1611495722,"15009":[{"9003":0}],"9054":0,"3":{"6":3,"0":"IKEA of Sweden","1":"TRADFRI remote control","2":"","3":"2.3.014","9":21},"9019":1,"5750":0}
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.05 Content, Received: {"9001":"Vitrinskåp","9003":65538,"9002":1521891386,"9020":1611496423,"9054":0,"3":{"6":1,"0":"IKEA of Sweden","1":"TRADFRI bulb E27 WS opal 980lm","2":"","3":"2.3.050"},"9019":1,"5750":2,"3311":[{"5850":0,"5851":230,"5717":0,"5706":"f1e0b5","5711":370,"5709":30015,"5710":26870,"9003":0}]}
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Status: 2.04 Changed, Received: 
2021-01-24 16:43:21 DEBUG (MainThread) [pytradfri.api.aiocoap_api] Executing 192.168.0.131 <Command put ['15001', 65586]: {'3311': [{'5851': 215}]}>

I hope this can help...!

PD75 commented 3 years ago

This integration is really hit and miss. Sometimes it will work for months, and then, like now; it works for a few hours only. I always remove and set-up integration when I have problems, but this is ridiculous right now. None of the automations have worked for the last few days.

chriscolden commented 3 years ago

This integration is really hit and miss. Sometimes it will work for months, and then, like now; it works for a few hours only. I always remove and set-up integration when I have problems, but this is ridiculous right now. None of the automations have worked for the last few days.

I'm also seeing this. I get a few hours, before I have to readd again.

HA 2021.1.5 Python Version | 3.8.7

litinoveweedle commented 3 years ago

Cool reports guys. Well screaming Me Too is utterly useless in FOSS concept. Even so more, when you are even not trying to describe your problems in any structured way, which could help others to troubleshoot this one. But as I have unlimited patience, I will try to help you. Disclaimer: I have no connection to HA or NabuCasa, just passing by.

Tradfri integration uses two libraries (one part of HA, second is 3rd party) which both lack proper handling of all possible error use cases. It is as it is and if you are not willing to help by yourself, you will have to patiently wait until someone will fix it for all of us.

Meanwhile, you can decrease possible chances for errors, especially ones cause by your network. So please spent your time on connecting your Tradfri GW to HA via Ethernet cable. I have my GW connected in this way and from bug fix which was delivered at the end of 2020 my integration is rock stable - except rare re-connection issues after GW is restarted.

manuelbernhardt commented 3 years ago

I'd just like to report the following:

In any case, great job for anyone who has helped. And to reiterate what has been said before: wired connection works a lot better for this integration

jonaslorander commented 3 years ago

What would be the best way to set up a development environment for HA? I would really like to help out with this. I will be moving in a few week and will be living in an other place temporarily, so this would be a good time to set up my Tradfri GW on a dev enviorment instead.

taarskog commented 3 years ago

Hei @jonaslorander. Head over to https://developers.home-assistant.io/ for dev info. On https://developers.home-assistant.io/docs/development_environment you get a guide on a setup with VS Code and dev on a container.

chriscolden commented 3 years ago

@litinoveweedle Thanks for the info, I'm currently fully ethernet and running HA in a virtual machine on a qnap. It was very stable, and I dont loose access in the tradfri app or via google homes. So I doubt its a gateway issue at this point.

I've turned logging on this morning, and will post the results. I'm not a developer by any means, so I'm trying to help where I can.

larsvinc commented 3 years ago

On a note, I have been reloading using the restful command, and made a template cover that wraps the ikea cover and runs the reload when necessary. Pasting it here in case someone needs the same (and for it to be used with the reload service if that makes it into main).

cover:

script: set_rullegardin_position: sequence:

LukasQ commented 3 years ago

After the Update to 2021.4.x it turns out to be even more unstable. At least here in my setup (ESXi-based, all GbE)

rubenbe commented 3 years ago

For those seeing this issue (and a bit experienced with python development) could you try to upgrade aiocoap to 0.4.1?

pip install aiocoap==0.4.1

Thanks for reporting back whether this makes any difference for you.

Sebazzz commented 3 years ago

@rubenbe I'd love to test that, but is that command applicable to the Home Assistant OS as well?