Community discussions

MikroTik App

MQTT functionality in routerOS to enable IoT like operation

Poll ended at Sat Jun 15, 2019 3:27 pm

3 (50%)
yes, with the ability to have multiple instances that subscribe different brokers/topics
2 (33%)
no, i use scripting and/or blood magic to mimic the functionality
No votes
no, i got everything sorted out with API
No votes
no, i don't need anything like this
1 (17%)
Total votes: 6
User avatar
Topic Author
Posts: 565
Joined: Mon Oct 08, 2012 8:39 pm
Location: Hungary

MQTT client in routerOS

Thu May 16, 2019 3:27 pm

I created an environment in routerOS, that enables IoT-like (i.e. the server doesn't talk to the router, but the router talks to the server) operation. it works in a reasonable way, but i'd think i'd be better of with a proper MQTT client implementation in the device, that enables subscribing and posting to topics:
- performance data, state, logs, idk - so in general "a routerOS variable"
- trigger a script / feed the input of an event that is sent to a subscribed topic

i might say, this shouldn't be a big performance issue as teeny-tiny micros can accommodate one and live on, so i thought i might ask the scripting community whether it would spark some ideas/interest on someone else's side, and create a demand so the next minor release of RouterOS (or maybe #RouterOS7) will suddenly include this functionality.
my explanation for it is that i don't want to track devices, i might not will be able to talk to them (behind nat, behind firewall), but in many cases they could just talk to my server. this would also enable some sort of ZTP/ZTO environment as well.

imagine something like
/system script
add name=handler1 source=":log info message=\"received: $mqtt_input on $mqtt_topic\""
/mqtt brokers
add name=broker1 port=6969
add name=broker2 port=1183
/mqtt topics
add name=topic1 broker=broker1 mode=publish topic=topicname
add name=topic2 broker=broker2 mode=subscriber topic=controller script=handler1
and you'll be able to use a script to write a routerOS variable or just a string to a publish-mode topic:
/mqtt post topic="topic1" message=$myvar
just joined
Posts: 7
Joined: Sat Dec 29, 2018 9:15 pm

Re: MQTT client in routerOS

Fri May 17, 2019 10:37 am

MQTT support would be great. A definite requirement would be SSL/TLS connections for each broker.
just joined
Posts: 2
Joined: Fri Apr 27, 2018 12:43 am

Re: MQTT client in routerOS

Mon May 11, 2020 9:37 pm

As a Smart Home user and possibly enthusiast and a multiple Mikrtik user this would be very useful. IE the ability to interact with my MQTT server running elsewhere and subscribe to topics that are being used in our Smart Home. Mikrotik anybody .... ?
Posts: 46
Joined: Mon Oct 17, 2011 4:07 am

Re: MQTT client in routerOS

Tue May 12, 2020 6:37 am

+1 for this feature. Would love to be able to have Mikrotik devices subscribe to a central MQTT server over TLS/SSL to trigger scripts on topic updates. Perfect for doing lightweight automation and control and not need to poke any inbound holes through firewalls! We currently do this through some script magic but it only checks for updates once a day to keep traffic low...
User avatar
Forum Veteran
Forum Veteran
Posts: 713
Joined: Sat Mar 03, 2018 1:12 am
Location: Moscow, Russia

Re: MQTT client in routerOS

Sat Jun 27, 2020 12:27 pm

+1 for MQTT client

Who is online

Users browsing this forum: lmcarriles and 19 guests