Mikrotik Binding not working with newer devices that have no capsman commands

Is anyone getting this error message or any others when trying to setup a Mikrotik router with the binding? I seem to have tracked it down to my new AX3 router that does not support capsman commands and I am making some changes to the binding at the moment so would be great to hear if anyone has issue whilst I am the API docs open and fresh in my head.

I am getting this error that stops the bridge coming online.

2024-07-14 17:18:25.462 [ERROR] [andler.MikrotikRouterosBridgeHandler] - RouterOS cache refresh failed in mikrotik:routeros:22fb1c4dca due to Mikrotik API error

me.legrange.mikrotik.MikrotikApiException: no such command prefix

	at me.legrange.mikrotik.impl.ApiConnectionImpl$SyncListener.getResults(ApiConnectionImpl.java:482) ~[?:?]

	at me.legrange.mikrotik.impl.ApiConnectionImpl$SyncListener.access$100(ApiConnectionImpl.java:436) ~[?:?]

	at me.legrange.mikrotik.impl.ApiConnectionImpl.execute(ApiConnectionImpl.java:117) ~[?:?]

	at me.legrange.mikrotik.impl.ApiConnectionImpl.execute(ApiConnectionImpl.java:75) ~[?:?]

	at org.openhab.binding.mikrotik.internal.model.RouterosDevice.updateCapsmanRegistrations(RouterosDevice.java:263) ~[?:?]

	at org.openhab.binding.mikrotik.internal.model.RouterosDevice.refresh(RouterosDevice.java:163) ~[?:?]

	at org.openhab.binding.mikrotik.internal.handler.MikrotikRouterosBridgeHandler.performRefresh(MikrotikRouterosBridgeHandler.java:202) ~[?:?]

	at org.openhab.binding.mikrotik.internal.handler.MikrotikRouterosBridgeHandler.scheduledRun(MikrotikRouterosBridgeHandler.java:190) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]

	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]

	at java.lang.Thread.run(Thread.java:840) [?:?]

Caused by: me.legrange.mikrotik.impl.ApiCommandException: no such command prefix

	at me.legrange.mikrotik.impl.ApiConnectionImpl$Processor.run(ApiConnectionImpl.java:270) ~[?:?]

2024-07-14 17:18:25.467 [DEBUG] [krotik.internal.model.RouterosDevice] - Logging out of 192.168.10.1

2024-07-14 17:18:25.467 [DEBUG] [krotik.internal.model.RouterosDevice] - Closing connection to 192.168.10.1

==> /var/log/openhab/events.log <==

2024-07-14 17:18:25.468 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'mikrotik:routeros:22fa' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): no such command prefix

After fault finding and fixing the issue I found a number of users have had the same problem here:

The problem stems from:

The 'WiFi' configuration menu, introduced in RouterOS 7.13, is a RouterOS menu for managing Wi-Fi 5 wave2 and newer WiFi interfaces.

API command /interface/wireless/registration-table/print now needs to be /interface/wifi/registration-table/print and a number of other similar changes.

See WiFi - RouterOS - MikroTik Documentation

Need testers willing to trial a new JAR and some time to check if there are any other changes needed before making a PR.

Send a link to JAR
I use hAP ax3 (ROS 7.15.3) I can test it.

I think it’s not just a problem with capsman, there are more missing or new commands.
I found the solution here:
https://help.mikrotik.com/docs/display/ROS/MQTT
scrip (at the end) unfortunately didn’t work on the first run, after small modifications it works reliably for about 8 months.

Can you trial this new jar please? I also have a hap AX3 using default settings as much as possible so this should work for you.

http://pcmus.com/openhab/MikrotikBinding/

I have made a PR to get these changes merged.

Hi matt1,
I am also interested in testing the fix. Currently I have two devices configured in openHAB 4.2.2 with the bundle from marketplace:

  • 6.49 LTS: Works (I can read the uptime in openHAB for example) but this error is shown in the logs RouterOS device is null in scheduledRun
  • 7.12: Works not. Get this error: RouterOS cache refresh failed due to Mikrotik API error

I can confirm that with the org.openhab.binding.mikrotik-4.3.0-SNAPSHOT.jar from 2024-10-12 it works for both versions (I can read the uptime in openHAB). But the [ERROR] [andler.MikrotikRouterosBridgeHandler] - RouterOS device is null in scheduledRun is still there.

Have you restarted openHAB to see if its an old thread still running? I can not see how it can be null as this would be a config error and that should cause the thing to not come online. If a restart does not fix it, then you will need to provide TRACE level logs when you press PAUSE and then UNPAUSE the thing so it connects. That may provide a clue where to look.

Since I can not reproduce this and can not see an obvious bug this may be harder to track down so hopefully a restart fixes it.

A restart fixed it, I do not see RouterOS device is null in scheduledRun anymore. Thanks a lot for adopting this binding to Mikrotik 7.x!

Good my guess is it was a glitch from changing the jar over whilst the binding was running. If you notice anything is not working let me know whilst the code is fresh in my head. I had to make s
Changes to get the wifi signal strengths to show correct under v7 so other changes may be needed.