Mikrotik router integration for Home Assistant
Find a file
2020-04-13 12:24:51 +02:00
.github excluded W503,E722 and raised complexity in flake8 workflow 2020-04-13 12:24:51 +02:00
custom_components/mikrotik_router added support for virtual interfaces #12 2020-04-13 09:16:33 +02:00
docs/assets/images/ui updated docs 2020-04-10 11:01:13 +02:00
.gitattributes initial commit 2019-12-02 01:13:28 +01:00
hacs.json updated hacs.json 2019-12-04 16:12:48 +01:00
LICENSE Create LICENSE 2019-12-02 01:24:37 +01:00
README.md updated docs #29 2020-04-13 12:10:37 +02:00
requirements.txt added workflows 2020-04-12 08:45:50 +02:00
setup.cfg change lib exclude for flake8 2019-12-08 18:13:46 +01:00
sonar-project.properties added workflows 2020-04-12 08:45:50 +02:00

Mikrotik Router

GitHub release (latest by date) hacs_badge Project Stage

GitHub commits since latest release GitHub commit activity

Tracker and sensors

Monitor and control your Mikrotik device from Home Assistant.

Features:

  • Interfaces:
    • Enable/disable interfaces
    • Monitor RX/TX traffic per interface
    • Monitor device presence per interface
    • IP, MAC, Link information per interface for connected devices
  • Enable/disable NAT rule switches
  • Enable/disable Simple Queue switches
  • Device tracker for hosts in network
  • System sensors (CPU, Memory, HDD)
  • Check firmware update
  • Execute scripts
  • Configurable update interval
  • Configurable traffic unit (bps, Kbps, Mbps, B/s, KB/s, MB/s)
  • Supports monitoring of multiple mikrotik devices simultaneously
  • RX/TX WAN/LAN traffic sensors per hosts from Mikrotik Accounting feature

Integration preview

Tracker and sensors

Interface Info Interface Switch

Interface Sensor Script Switch

NAT switch Queue switch

Host tracker Accounting sensor

Install integration

This integration is distributed using HACS.

You can find it under "Integrations", named "Mikrotik Router"

Setup integration

Create user for homeassistant on your mikrotik router with following permissions:

  • read, write, api, test

If you want to be able to execute scripts on your mikrotik router from HA, script needs to have only following policies:

  • read, write, test or check "Don't Require Permissions" option

Setup this integration for your Mikrotik device in Home Assistant via Configuration -> Integrations -> Add -> Mikrotik Router. You can add this integration several times for different devices.

NOTE: Do not mistake "Mikrotik Router" integration with HA build-in integration named "Mikrotik".

Add Integration

  • "Name of the integration" - Friendly name for this router
  • "Host" - Use hostname or IP
  • "Port" - Leave at 0 for defaults

Configuration

Integration options

  • "Scan interval" - Scan/refresh time in seconds. HA needs to be reloaded for scan interval change to be applied.
  • "Unit of measurement" - Traffic sensor measurement (bps, Kbps, Mbps, B/s, KB/s, MB/s)
  • "Show client MAC and IP on interfaces" - Display connected IP and MAC address for devices connected to ports on router.
  • "Track network devices" - Enable device tracker
  • "Track network devices timeout" - Tracked devices will be marked as away after timeout (does not apply to Mikrotik wireless and caps-man)

Accounting

For per-IP throughput tracking Mikrotik's accounting feature is used.

Mikrotik support page

Feature will be automatically used if accounting is enabled in Mikrotik. Feature is present in Winbox IP-Accounting. Make sure that threshold is set to reasonable value to store all connections between user defined scan interval. Max value is 8192 so for piece of mind I recommend setting that value. Web Access is not needed, integration is using API access.

Integration will scan DHCP Lease table and ARP table to generate all known hosts. For every host aleast two sensors for WAN traffic (mikrotik-XXX-wan-rx and mikrotik-XXX-wan-tx) are created. If the parameter account-local-traffic is set in Mikrotik's accounting configuration it will also create two sensors for LAN traffic (mikrotik-XXX-lan-rx and mikrotik-XXX-lan-tx).

Enabling debug

To enable debug for Mikrotik router integration, add following to your configuration.yaml:

logger:
  default: info
  logs:
    custom_components.mikrotik_router: debug