tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
292 stars 48 forks source link

Problem after HA 2023.9.0 upgrade [Bug] #304

Open PetrP2B opened 11 months ago

PetrP2B commented 11 months ago

When switching both WLAN1 and WLAN2 enable/disable it ends up with this error. If I switch one, wait for a response and then switch next one, everything seems fine. In HA version 2023.8 everything worked fine.

HA: 2023.9.2 component Mikrotik router: master version Mikrotik version: 7.11.2

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/mikrotik_router/mikrotikapi.py:228 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 14:55:44 (1 occurrences) Last logged: 14:55:44

[140554354164160] timed out Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 227, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1969, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2006, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/homeassistant/init.py", line 130, in async_handle_turn_service await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/core.py", line 1969, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2006, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 898, in entity_service_call task.result() # pop exception if have ^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1197, in async_request_call return await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call result = await task ^^^^^^^^^^ File "/config/custom_components/mikrotik_router/switch.py", line 155, in async_turn_on self.coordinator.set_value(path, param, value, mod_param, False) File "/config/custom_components/mikrotik_router/coordinator.py", line 440, in set_value return self.api.set_value(path, param, value, mod_param, mod_value) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/mikrotik_router/mikrotikapi.py", line 228, in set_value for tmp in response: File "/usr/local/lib/python3.11/site-packages/librouteros/api.py", line 107, in iter yield from self('print') File "/usr/local/lib/python3.11/site-packages/librouteros/api.py", line 110, in call yield from self.api( File "/usr/local/lib/python3.11/site-packages/librouteros/api.py", line 35, in call yield from self.readResponse() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/librouteros/api.py", line 67, in readResponse reply_word, words = self.readSentence() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/librouteros/api.py", line 53, in readSentence reply_word, words = self.protocol.readSentence() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/librouteros/protocol.py", line 187, in readSentence sentence = tuple(word for word in iter(self.readWord, '')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/librouteros/protocol.py", line 187, in sentence = tuple(word for word in iter(self.readWord, '')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Logger: custom_components.mikrotik_router.mikrotikapi Source: custom_components/mikrotik_router/mikrotikapi.py:183 Integration: Mikrotik Router (documentation, issues) First occurred: 14:56:13 (1 occurrences) Last logged: 14:56:13

Mikrotik Reconnected to 192.168.2.6^^^ File "/usr/local/lib/python3.11/site-packages/librouteros/protocol.py", line 203, in readWord word = self.transport.read(length) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/librouteros/connections.py", line 25, in read data += self.sock.recv((length - len(data))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: timed out

tomaae commented 11 months ago

I have to inquire HA dev with this. Cant figure out how/if new coordinator handles conflict with switch queries.

tomaae commented 11 months ago

So coordinator does not handle outgoing conflits at all, will have to come up with something custom.

PetrP2B commented 11 months ago

It must have something to do with the HA update to 2023.9 because it worked reliably before that.

tomaae commented 11 months ago

not really, its related to integration being rewritten for HA coordinator

fusionstream commented 4 months ago

Following