Community discussions

MikroTik App
 
vercetti
just joined
Topic Author
Posts: 3
Joined: Fri Jan 05, 2024 3:55 am

Sync interface ON\OFF with POE

Fri Jan 05, 2024 4:02 am

Hello guys!
Maybe someone can help with advice or script.
On the POE router, I need following: when the interface is turned off, POE is also turned off and vice versa.
Thanks!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Sync interface ON\OFF with POE

Fri Jan 05, 2024 12:18 pm

When the script disable/enable the interface, add a line for off/auto the poe...
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Sync interface ON\OFF with POE

Fri Jan 05, 2024 1:01 pm

Yep, this would be something *like*:
/interface ethernet disable <etherN>
or
/interface ethernet disable [find <some field>=<some value>]
and
/interface ethernet poe set <etherN> poe-out=off

but it is not clear how the OP intends to disable the interface (by script or manually) maybe what is asked for is a script running that every x seconds/minutes checks whether the interface is enabled or disabled and accordingly switches poe on or off.

@vercetti
Please explain/detail what you want to do.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Sync interface ON\OFF with POE

Fri Jan 05, 2024 2:19 pm

or
/interface ethernet disable [find <some field>=<some value>]
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Sync interface ON\OFF with POE

Fri Jan 05, 2024 2:59 pm

Why not? :-?

Just tested (example):
/interface ethernet disable [find mac-address=0C:10:7B:A0:00:01]

/interface ethernet enable [find mac-address=0C:10:7B:A0:00:01]
and they seem to work just fine.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Sync interface ON\OFF with POE

Fri Jan 05, 2024 5:14 pm

[find mac-address=

1 + 1 = 2
but also
1 + 88 - 99 + 12 = 2

The point is that do not have any sense if interface name (or default interface name) can be used directly...
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Sync interface ON\OFF with POE

Fri Jan 05, 2024 6:36 pm

[italian]
è come il pesce ratto, può piacere o non piacere, non discuto ...
[/italian]
:lol:
 
vercetti
just joined
Topic Author
Posts: 3
Joined: Fri Jan 05, 2024 3:55 am

Re: Sync interface ON\OFF with POE

Wed Jan 17, 2024 3:49 am

When the script disable/enable the interface, add a line for off/auto the poe...
The logic is as follows, only there is one nuance, I can’t get the current statuses of the interfaces lol
partially generated by chatgpt.....
  :local interfaces ("ether1", "ether2", "ether3", "ether4", "ether5")
  
  :foreach interfaceName in=$interfaces do={
    :local poeInterface [/interface find name=$interfaceName]
    
    :if ($poeInterface != "") do={
      :local linkState [/interface get $interfaceName link]
      
      :if ($linkState = "down") do={
        :local poeEnabled [/interface get $poeInterface poe-out]
        
        :if ($poeEnabled = "auto-on") do={
          /interface poe set $poeInterface poe-out=off
          :log info ("POE on interface $interfaceName has been disabled.")
        }
      } else={
        :local linkState [/interface get $interfaceName link]
        :if ($linkState = "up") do={
          :local poeDisabled [/interface get $poeInterface poe-out]
          
          :if ($poeDisabled = "off") do={
            /interface poe set $poeInterface poe-out=auto-on
            :log info ("POE on interface $interfaceName has been enabled.")          
          
        }
      }
    }
 
jaclaz
Long time Member
Long time Member
Posts: 667
Joined: Tue Oct 03, 2023 4:21 pm

Re: Sync interface ON\OFF with POE

Wed Jan 17, 2024 8:32 pm

Maybe try on command line:
/interface ethernet poe monitor [find]

https://wiki.mikrotik.com/wiki/Manual:P ... RouterOS_2
 
blingblouw2
just joined
Posts: 15
Joined: Thu May 18, 2023 4:35 pm

Re: Sync interface ON\OFF with POE

Wed Jan 17, 2024 9:29 pm

Maybe you’re going about this the wrong way. Not enough information provided

If all your end devices are power from the router/switch. Why not *just* turn off Poe. That will then in turn make the interface “not running”, and you can easily see/script based upon that if you have other things that depend on the interface status

Why would you go through all this effort?
 
vercetti
just joined
Topic Author
Posts: 3
Joined: Fri Jan 05, 2024 3:55 am

Re: Sync interface ON\OFF with POE

Thu Jan 18, 2024 1:27 am

Maybe you’re going about this the wrong way. Not enough information provided

If all your end devices are power from the router/switch. Why not *just* turn off Poe. That will then in turn make the interface “not running”, and you can easily see/script based upon that if you have other things that depend on the interface status

Why would you go through all this effort?
I use Mikrotik integration in Home Assistant, which expose ports, trafic sensors and many many another.
So i have POE router with cameras connected to it.
I have automation, which, in the event of a battery discharge (from which the entire infrastructure is powered), smoothly disconnects the consumers specified in the automation.
So, the switch, which can be controlled from the home assistant, turns off only ethernet, while the POE on the interface remains turned on and consumes electricity.
It’s actually for these purposes that I want to write a script to bind these events.
I hope I explained.
 
blingblouw2
just joined
Posts: 15
Joined: Thu May 18, 2023 4:35 pm

Re: Sync interface ON\OFF with POE

Thu Jan 18, 2024 10:48 am

Maybe you’re going about this the wrong way. Not enough information provided

If all your end devices are power from the router/switch. Why not *just* turn off Poe. That will then in turn make the interface “not running”, and you can easily see/script based upon that if you have other things that depend on the interface status

Why would you go through all this effort?
I use Mikrotik integration in Home Assistant, which expose ports, trafic sensors and many many another.
So i have POE router with cameras connected to it.
I have automation, which, in the event of a battery discharge (from which the entire infrastructure is powered), smoothly disconnects the consumers specified in the automation.
So, the switch, which can be controlled from the home assistant, turns off only ethernet, while the POE on the interface remains turned on and consumes electricity.
It’s actually for these purposes that I want to write a script to bind these events.
I hope I explained.
But i guess thats my point really.

Home Assistant is using ssh or api to disable a port by running something like

`/interface ethernet set disabled=yes ether24` for example can't you just change that to disable the poe instead? i.e. `interface ethernet poe set poe-out=off ethet24`

Who is online

Users browsing this forum: pav5 and 10 guests