Community discussions

MikroTik App
 
neki
newbie
Topic Author
Posts: 33
Joined: Thu Sep 07, 2023 10:20 am

Basic script needed, MQTT enable/disable wifi

Mon Mar 04, 2024 9:58 pm

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..
 
UkRainUa
newbie
Posts: 27
Joined: Sun Mar 10, 2024 3:10 am

Re: Basic script needed, MQTT enable/disable wifi

Tue Mar 12, 2024 4:00 pm

 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Basic script needed, MQTT enable/disable wifi

Tue Mar 12, 2024 6:14 pm

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.
 
neki
newbie
Topic Author
Posts: 33
Joined: Thu Sep 07, 2023 10:20 am

Re: Basic script needed, MQTT enable/disable wifi  [SOLVED]

Thu Mar 21, 2024 8:52 pm

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.

Who is online

Users browsing this forum: No registered users and 1 guest