tomaae / homeassistant-mikrotik_router

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

Integration problems after HA 2023.9.0 upgrade [Bug] #299

Closed BluThunder2k closed 11 months ago

BluThunder2k commented 11 months ago

Describe the issue

Things worked fine under 2023.8.x, however upgrading to 2023.9.x, none of the entities appear with the following error. Not sure if this is a Mikrotik integration issue or a problem with a change in 2023.9.

Logger: homeassistant.components.sensor Source: helpers/entity_platform.py:621 Integration: Sensor (documentation, issues) First occurred: 5:13:56 PM (339 occurrences) Last logged: 5:24:53 PM

mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.x.x', 'connections': {('mac', '18:FD:74:xx:xx:xx')}, 'default_manufacturer': 'MikroTik', 'default_model': 'CCR2004-16G-2S+', 'default_name': 'CoreRouter ether12', 'identifiers': {('mac', '18:FD:74:xx.xx.xx')}, 'sw_version': '7.11 (stable)', 'via_device': ('mikrotik_router', 'HDCxxxxxxxx')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

How to reproduce the issue

In my testing, upgrade to 2023.9.x and configure for a router. In my case, for this example, a CCR2004-16G-2S+ with 7.11 (stable) Router OS.

You'll get an entry in your logs for every entity that exists in your configuration. In this case of the log, just my ether12 interface.

tomaae commented 11 months ago

Can you try with master?

wirszews commented 11 months ago

HI, unfortunately I have the same after upgrading to HA version

Home Assistant 2023.9.0 Supervisor 2023.08.3

BluThunder2k commented 11 months ago

Can you try with master?

Not sure exactly what master is? I just tried adding on a RB450 on my bench and it's throwing the same log entries.

aurelmarius commented 11 months ago

Can you try with master?

It is fixed in master. Thanks.

BluThunder2k commented 11 months ago

Ah, misunderstood. I just grabbed the master branch in hacs and it works again!

Thanks!!!

tomaae commented 11 months ago

excellent

PetrP2B commented 11 months ago

The connection with the master version works, but when controlling the ports (on/off) it writes these errors in the HA log.

Source: custom_components/mikrotik_router/mikrotikapi.py:228
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 08:45:10 (4 occurrences)
Last logged: 08:50:35
[140036044918848] 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 177, in async_turn_off
    self.coordinator.set_value(path, param, value, mod_param, True)
  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 <genexpr>
    sentence = tuple(word for word in iter(self.readWord, ''))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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
lakofsth commented 11 months ago

Correction - filter rules are there, but the names are changed. OK. It's working in master.

(earlier I wrote: I have no switch entities for firewall rules even with master. Rolled back to 8.4)

sebastienwarin commented 11 months ago

Hi there.

After upgrading to HA 2023.9.0 + master branch, I have no more RX/TX traffic per interface.

Seb,

dvoijen commented 11 months ago

When using Master it has some connection but no mangle routes switches are not named anymore they appear as switch.mikrotik_mangle_4 etc...

sagitt commented 11 months ago

same here

tomaae commented 11 months ago

guys, we need separate issues for separate problems. mixing it like this will just create chaos and things get missed.

EvgveneSV commented 11 months ago

Same issues. No info from Mikrotik after upgrade to 2023.9.0. Have few devises with ROS 7.11.2 and 7.9.1

hectork2 commented 11 months ago

I have the same problem , after upgrade to HA 2023.9.1 dont work

mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://...', 'connections': {('mikrotik_router', 'D5030D9FC7C7')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hEX', 'default_name': 'Mikrotik hEX', 'identifiers': {('mikrotik_router', 'D5030D9FC7C7')}, 'sw_version': '7.7 (stable)', 'via_device': ('mikrotik_router', 'D5030D9FC7C7')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://...', 'connections': {('mikrotik_router', 'Script')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hEX', 'default_name': 'Mikrotik Script', 'identifiers': {('mikrotik_router', 'Script')}, 'sw_version': '7.7 (stable)', 'via_device': ('mikrotik_router', 'D5030D9FC7C7')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

tomaae commented 11 months ago

yes, everyone will have this issue. install master to get integration working if you need it right away. there is still need for some work on it before it can be released properly.

HA-TB303 commented 11 months ago

For me it does not work using the master branch.

germaguire commented 11 months ago

Hi, I removed and reinstalled with the master and its working again now after upgrade to 2023.9.1 but I have an issue with the filers now being named filter-1 instead of it naming them based on the comment, any idea how to check this ?

Thanks for the addon also, great work !

buzzzzer commented 11 months ago

Master branch work for me.

tomaae commented 11 months ago

v2.1.3 released

PetrP2B commented 11 months ago

Hi, 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 nex one, everything seems fine. HA 2023.9.1

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, '')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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

PetrP2B commented 11 months ago

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

tomaae commented 11 months ago

could be a limitation or issue with ha coordinator. but it is not related to this issue, open a new issue for this