Integrating MikroTik routers with Home Assistant: A Step-By-Step Guide

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

In this guide, I will be showing you how to harmoniously integrate your MikroTik router with Home Assistant. This integration allows you not only to monitor the presence of people's devices, but also control things such as the physical interfaces, NAT rules, and filters. While MikroTik may not be the networking world's equivalent of the Beatles like Ubiquiti, Netgear, or D-Link, it does command a dedicated following with its enthusiast-grade networking gear that dances to the rhythm of the highly optimized RouterOS.

Contents

How MikroTik became the enthusiast's preferred choice

Originating from Latvia in 1996, MikroTik has evolved to become a global provider of routers and wireless ISP systems. Their products, including both hardware and software, facilitate Internet connectivity in a multitude of countries worldwide. Their product range is expansive, but the heart of their offerings lies in the powerful RouterOS. RouterOS is an operating system specifically designed for routers, based on the Debian GNU/Linux kernel. It's bursting with a wide range of features like routing, firewall, hotspot, VPN, bandwidth management, and web proxy. The list goes on, truly embodying the 'more the merrier' ethos.

Among MikroTik's extensive line-up, a few gems shine particularly brightly. The hAP ax² and hAP ax³ are two such shining stars. These powerful Wi-Fi 6 supporting access points have become a favourite among enthusiast. Then there are the L009UiGS-RM and L009UiGS-2HaxD-IN devices, providing a stable backbone for any network. The former is a no Wi-Fi device, while the latter supports 2.4 GHz Wi-Fi 6. Both devices feature robust dual-core ARM CPUs, 512 MB RAM, and a full-sized USB port, making them ideal for running custom container projects. And with a price tag of US$119 and US$129 respectively, they offer quite a bang for your buck.

Preparing your MikroTik router

Before we start setting up the integration in Home Assistant, we will want to make sure we can do while keeping our MikroTik devices as secure as possible. To achieve this, you will want to set up a new user, as the integration does not require the privileges the admin user has. While MikroTik routers do have a web interface, the easiest way of configuring them is by using WinBox, which can be downloaded directly from the MikroTik website. This is a portable application, so there is no need for an installation, and you can just launch the application.

With WinBox up and running, log into your MikroTik router using the admin account. Make a beeline for the user list, nestled within the system's settings. Before you add a user, let's create a new group with these policies on their checklist:

Next, create a user named homeassistant, assign it to the freshly minted group, and fortify it with a strong password. With that, the MikroTik router's configuration is all set, and we're ready to turn the page to the next chapter.

A screenshot of WinBox showing how to add a group to a MikroTik router
A screenshot of WinBox showing how to add a user to a MikroTik router

Installing the MikroTik Router custom integration

While Home Assistant does provide a native integration with MikroTik routers, its functionality is relatively limited, only tracking devices connected to your router. To overcome these shortcomings, consider utilizing the enhanced custom integration designed by Tomaae.

The recommended and most straightforward method to incorporate this custom component into Home Assistant is via the Home Assistant Community Store (HACS). A simple search for MikroTik should do the trick. If not, you can manually add the custom repository: https://github.com/tomaae/homeassistant-mikrotik_router (or use this link to have it set up). After installing the component, a swift system reboot will ensure everything's up and running like a well-oiled machine.

Adding the MikroTik integration to Home Assistant

Back in the Home Assistant Dashboard, navigate to the integration overview located in the settings. From there, add a new integration and search for MikroTik. You'll now have two options: the official MikroTik integration, which we're politely side-stepping, and the custom MikroTik Router integration we've just installed. Choose the latter, and you'll be prompted to name your integration and input your router's port (leave it set to zero to use the default port), username, and password. For the latter two, just enter the details you set up earlier.

Now, we hit a slight bump in the road. This custom integration is showing its age a bit. The most recent update was nearly a year ago, so it doesn't fully utilize the benefits of newer versions of Home Assistant. However, don't fret; the component is still under active development, and a significant update is expected in the foreseeable future.

A screenshot of Home Assistant showing a search for the MikroTik integration
A screenshot of Home Assistant showing the setup of a MikroTik router.
A screenshot of Home Assistant showing the integration entities of the MikroTik integration.

Configuring the MikroTik integration with Home Assistant

Instead of being greeted by a nice overview, with categorized entities already being enabled or disabled, you will need to click on the integration and then configure the router previously set up. The configurator allows you to set the scan interval and select the unit of measurement (bps, Kbps, Mbps, B/s, KB/s, or MK/s). You can also choose whether you want the client's MAC and IP addresses to be shown in the interface's properties. The final two options allow you to set the time a device has to be disconnected, to be considered away from home, and the location of the router itself.

On the subsequent page, you are prompted to enable the sensors and switches you wish to make use of. My recommendation is to enable everything and disable the entities you don't wish to have using Home Assistant. It's a much simpler and quicker process. I suggest enabling everything initially, then deactivating any entities you find unnecessary via Home Assistant. It's a more straightforward and efficient process this way. With the router configured and ready to go, the setup is now complete. One of the perks of this integration is its capacity to handle multiple MikroTik devices, so feel free to repeat the process for any additional routers in your smart home arsenal.

A screenshot of Home Assistant showing the available entities in the MikroTik integration
A screenshot of Home Assistant showing the available entities in the MikroTik integration

Unleash the Power of MikroTik Integration

Below is the list of MikroTik entities that the integration will grant you access to in Home Assistant. As with any other integration, you can use any of these in automations, scripts, or just display them in the Home Assistant Dashboard. Whether you're employing them in automations, integrating them into scripts, or showcasing them on your Home Assistant Dashboard, these entities are more than just tools – they are potential game-changers. They furnish you with comprehensive data, enabling you to troubleshoot your MikroTik routers with precision. Worried about system overheating? Stress no more. But it's not just about problem-solving. The MikroTik integration gives you peace of mind, ensuring your digital ecosystem operates at its optimal level.

Home Assistant Mikrotik Integration 09

Switches and buttons

The following actions are available to you, after having integrated your MikroTik router with Home Assistant. What exactly is displayed depends on your model and also the configuration of RouterOS.

A screenshot of the Home Assistant Dashboard showing a graph detailing a MikroTik router

Monitoring

Home Assistant Mikrotik Integration 07
A screenshot of Home Assistant showing how long a MikroTik router has been up
A screenshot of Home Assistant showing a tracked device through the MikroTik integration
A screenshot of the Home Assistant Dashboard showing a MikroTik router's CPU temperature
A screenshot of the Home Assistant Dashboard showing a MikroTik router's CPU load
A screenshot of the Home Assistant Dashboard showing a MikroTik router's memory usage

Updates

The MikroTik custom component will automatically check the firmware version for both RouterOS and the RouterBOARD, and inform you whenever there is a newer one available. You can start the update directly from the dashboard. This is the feature I, personally, make most use off, as I'm not constantly logging into my router's interface.

A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Leave a comment

Share to...