Basic script needed, MQTT enable/disable wifi

Hi,

I’m looking for basic script to control my guest wifi. My idea is to have switch/button in Home Assistant so everybody could easily turn on/off guest wifi.

I have the infrastructure (broker, needed packages, etc..) but unfortunately also 0 experience with RouterOS scripting.

It should listen for some payload like “guest_wifi:on” and “guest_wifi:off” and made appropriate change for wifi3.

Any help will be appreciated..

http://forum.mikrotik.com/t/hap-ac2-mode-button-to-enable-disable-wifi/148133/1

MQTT is not Mode Button, though the actual ROS commands should be the same.

OP might try making use of this (no MQTT, rather “direct” Mikrotik API from Home Assistant).
https://github.com/pilotak/homeassistant-mikrotik-api

There is no real need of a script on the Mikrotik AFAICU, one can add a sequence of commands on the Home Assistant side.

Thank you guys. I was scared to do it by myself, anyway it turned out that it’s not that hard.

If anybody wonders how to do it by MQTT (JSON), it can be as easy as this:

:if ($msgData~"\\{\"guest_wifi\":\"disable\"\\}") do={/interface set wifi4  disable=yes}
:if ($msgData~"\\{\"guest_wifi\":\"enable\"\\}") do={/interface set wifi4  disable=no}

Anyway, while researching this topic, I found out that there is unofficial integration called Mikrotik - Router (that uses suggested API) and it does all I could ask for.