Toggle POE State of UniFi Switch Ports WITH node-red-contrib-unifi-os

Hi all,

I would like to be able to toggle (On/Off POE) POE on unifi switch ports from Loxone commands (http or udp doesnt matter it is working for me).

I have POE Unifi switch US-8-60W. (1-4 port is without POE and ports 5-8 is POE ports).

I am using Node-RED v2.1.3.

I have found related nodes:
Toggle POE State of UniFi Switch Ports

I have installed node-red-contrib-unifi-os and imported Toggle POE State of UniFi Switch Ports and setup Unifi network Aplication in unifi-request node it is inicialized:

As you can see in above picture by default Endpoint was proxy/network/api/s/default/stat/device but there I was not able to get any data in browser:

So after some search I have found that correct Endpoint should be /api/s/vorj5idg/stat/device and there I am able to get data in browser:

an also in nodered see here::

But if try in Toogle POE port I always get this error:

Can you help me please?

I have read here in forum and it helped me due to @crxporter replies (Library - Node-RED) to find correct Endpoint but I am not able to get over :frowning:


Let me inform you that if I connect by putty (SSH) to me Unifi switch US-8-60W and send comand:
swctrl poe set auto id 5
POE on port 5 is switched on.
and if I send command:
swctrl poe set off id 5
POE on port 5 is switched Off
So switch is working correctly.

Many thanks for each help

1 Like

Yes this should be possible. You'll need to use an HTTP PATCH command sent to that same endpoint. Just send the JSON key and value that you notice changing.

The closest example I have documented is for toggling camera motion detection: Changing camera settings · NRCHKB/node-red-contrib-unifi-os Wiki · GitHub

I'll watch (also @marcus-j-davies will watch, we're together this week :wink: ) how things go and might have time this weekend to do a few quick tests if you need more help.

1 Like

Many many thanks @crxporter for your fast and reply and help!!!
I have read your post many times and also your example link and looks eassy but to be honest I dont want to kill me switch :slight_smile:

So at first I triggered unifi-request node and you can see response.

There is 4 array object:
I can see 4 object is 4 devices I have already connected.

I can see 0: object is my unifi switch:

meta: object
data: array[4]
0: object
_id: "645d722dabf5720019b938aa"
ip: ""
mac: "74:ac:b9:4d:96:44"
model: "US8P60"
model_in_lts: false
model_in_eol: false
type: "usw"
version: ""
adopted: true
site_id: "63c5c749a50c04001efb5388"
x_authkey: "a7dea8371734d783289b4169319935f4"
cfgversion: "13ee190b9c1a099e"
syslog_key: "6b62c90708da02852ddeae71254d1ecd7fc83d358da48fea5a92bdb5055a6850"

so I suppose first line is ID we are looking for:

_id: "645d722dabf5720019b938aa"

Little down in 0: object I have found port_table and I suppose it is 8 me port of the switch:

port_table: array[8]
0: object
1: object
2: object
3: object
4: object
5: object
6: object
7: object

and there I have found that POE port 5 is 4: object::

port_table: array[8]
0: object
1: object
2: object
3: object
4: object
port_idx: 5
media: "GE"
port_poe: true
poe_caps: 1
speed_caps: 1048623
op_mode: "switch"
portconf_id: "63c5c749a50c04001efb5486"
poe_mode: "auto"
anomalies: 0
autoneg: true
dot1x_mode: "unknown"
dot1x_status: "disabled"
enable: true
flowctrl_rx: false
flowctrl_tx: false
full_duplex: false
is_uplink: false
jumbo: false
mac_table: array[0]
poe_class: "Unknown"
poe_current: "0.00"
poe_enable: false
poe_good: false
poe_power: "0.00"
poe_voltage: "0.00"
rx_broadcast: 0
rx_bytes: 0
rx_dropped: 0
rx_errors: 0
rx_multicast: 0
rx_packets: 0
satisfaction: 100
satisfaction_reason: 0
speed: 0
stp_pathcost: 0
stp_state: "disabled"
tx_broadcast: 0
tx_bytes: 0
tx_dropped: 0
tx_errors: 0
tx_multicast: 0
tx_packets: 0
up: false
tx_bytes-r: 0
rx_bytes-r: 0
bytes-r: 0
name: "Port 5"
port_security_mac_address: array[0]
stp_port_mode: true
port_security_enabled: false
masked: false
aggregated_by: false

And there I can notice changing value:
If POE is ON:

poe_mode: "auto"

If POE is OFF:

poe_mode: "off"

So now I need to create 2 unifi-request nodes. One for Off and one for ON like this? :

Many thanks!!!

Sorry for the delay I've been busy.

First up: you won't kill the switch. Best case is the command works. Worst case it does nothing and you try another command.

I'm going to give it a try from my side - the thing missing from your PATCH command is the port index, this will have to be added. I'll return back soon with whatever I learn.

Alright. After a bit of testing - I have this working.

With your device as

"_id": "645d722dabf5720019b938aa"

and you want to change"port_idx": 5

You would do the following command:

Send a PUT command to this endpoint:


with this data:

    "port_overrides": [
            "port_idx": 5,
            "poe_mode": "off"

And of course change "off" to "auto" if you want to turn it back on.

Screenshots from my test:

I figured this out with help from @marcus-j-davies , this webpage, and safari debug while changing the PoE on one of my switches.

Many thanks for your famous reply and help mate and especially your lost time!
To be honest I was trying to find such solution for years!!!!
You are great I love you :slight_smile:
Also big thanks to @marcus-j-davies
I have already check and all is working as you sent exactly!
As you can see here in picture I am sending text commands by UDP from loxone and in the switch it is splited to your unifi request nodes (ON or OFF).


Is it ok or I should implement some more simple way...any advise from you please?

I have already give you stars in nodered page and also I have already registered in github and also there give you stars and how I should buy coffe please?
Many many thanks !!!!

1 Like

If the flow works and you know what it's doing - you're in great shape!

As for thanks, knowing you are happy is enough. I'm glad we could figure it out!

1 Like

Sorry for late reply.
At first let me say big thanks really you are owesome! Great job!!
To be honest, once all working, I went to test in real condition and I have found my switch doesnt support 24V POE where I want to use so I am considering to buy some new unifi switch currently....:frowning:
Just the question, this way it should be working in any Unifi switch ?
Thanks !

I would expect yes. But there may be more values for PoE mode to set it at 24v - since 24v mode will cook many devices if they aren't 24v PoE compatible.

Sorry I can't help, I don't have any of those switches. I can tell you what to look for though if you decide to get another switch.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.