After few tens of minutes after restart of HA some entities can no longer be controlled. UI returns Failed to call service light/turn_off. Method Not Allowed
.
Adding a debugging line to pytradfri/api/aiocoap_api.py
renders the following in the logs:
2019-10-04 23:14:13 INFO (MainThread) [pytradfri.api.aiocoap_api] pytradfri Response Executing 10.0.1.209 coaps://10.0.1.209:5684/15004/None get ['15004', None]: None (True) => <aiocoap.protocol.BlockwiseRequest object at 0x7f3ac9602160> | <aiocoap.Message at 0x7f3ac9653390: Type.ACK 4.04 Not Found (ID 15316, token b'\x00\x01\x02\x16') remote <aiocoap.transports.tinydtls.DTLSClientConnection object at 0x7f3ac95fd0b8>, 9 byte(s) payload>
2019-10-04 23:14:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.o1_ikea fails
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 261, in async_update_ha_state
await self.async_device_update()
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 439, in async_device_update
await self.async_update()
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/light.py", line 146, in async_update
await self._api(self._group.update())
File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 156, in request
result = await self._execute(api_commands)
File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 149, in _execute
api_command.result = _process_output(res, parse_json)
File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 220, in _process_output
raise ClientError(output)
pytradfri.error.ClientError: Not Found
and
2019-10-04 23:14:29 INFO (MainThread) [pytradfri.api.aiocoap_api] pytradfri Executing 10.0.1.209 coaps://10.0.1.209:5684/15004/None put ['15004', None]: {'5850': 1} (True)
2019-10-04 23:14:29 INFO (MainThread) [pytradfri.api.aiocoap_api] pytradfri Response Executing 10.0.1.209 coaps://10.0.1.209:5684/15004/None put ['15004', None]: {'5850': 1} (True) => <aiocoap.protocol.BlockwiseRequest object at 0x7f3ac82ca470> | <aiocoap.Message at 0x7f3ac95d6198: Type.ACK 4.05 Method Not Allowed (ID 15317, token b'\x00\x01\x02\x17') remote <aiocoap.transports.tinydtls.DTLSClientConnection object at 0x7f3ac95fd0b8>, 18 byte(s) payload>
2019-10-04 23:14:29 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.139890463255856] Method Not Allowed
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1234, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 1259, in _execute_service
await handler.func(service_call)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 310, in async_handle_light_on_service
await light.async_turn_on(**pars)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/tradfri/light.py", line 111, in async_turn_on
await self._api(self._group.set_state(1))
File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 156, in request
result = await self._execute(api_commands)
File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 149, in _execute
api_command.result = _process_output(res, parse_json)
File "/srv/homeassistant/lib/python3.6/site-packages/pytradfri/api/aiocoap_api.py", line 220, in _process_output
raise ClientError(output)
pytradfri.error.ClientError: Method Not Allowed
Are we looking at a race condition in the client?
Restarting HA resolves the problem for some time.
HA 0.99.3
Installed through PIP on Ubuntu 16.04.6 LTS