Unifi network application port management not working

Hello everyone,

having read that I can control individual ports for the ubiquiti flex, I decided to buy on to control my cameras.

Boy, did I underestimate the set up.

Having finally finished to adopt the Flex into my synology container unifi network application, I cannot control the ports.

When I click on a port switch and turn it off, it jumps back to the “on” position. After like 30s it goes back to the off position and both, the switch and the port are turned off.
When trying to turn it back on, the toggle always jumps back to the “off” position and can’t be convinced to stay on.

On top of that, the network application gives contradicting info as well. The ports are greyed out or white, while the settings says they’d be active.

If I switch them to “disabled” and then back to “active”, it takes around a minute or so, the switch seems to disconnect for a moment and then, after some time, the ports come back online and HomeAssistant adjusts accordingly.

Has anyone dealt with that problem before as well and can help me what the hell is going on?

The network application I run is Network 10.1.89.
I am running HA Core 2026.3.4

If specific logs are required, I am happy to provide those.

Thank you.

For anyone else struggling, I build a node red flow to deal with this and ignore the integration.

[{"id":"72cf42be9319366f","type":"function","z":"2d6abcf995d5eea9","name":"Build unifi login","func":"msg.headers = {\n    \"Content-Type\": \"application/json\"\n};\n\nmsg.payload = {\n    username: \"USER\",\n    password: \"PASSWORD\",\n    remember: true,\n    strict: true\n};\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":900,"wires":[["2f3100d880c83a94"]]},{"id":"2f3100d880c83a94","type":"http request","z":"2d6abcf995d5eea9","name":"Unifi login","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://<IP>:8443/api/login","tls":"52b62f6280207d9c","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":500,"y":900,"wires":[["f803d5530fa9c1e3"]]},{"id":"f803d5530fa9c1e3","type":"function","z":"2d6abcf995d5eea9","name":"Extract cookies","func":"const hdrs = msg.headers || msg.responseHeaders;\nif (!hdrs) {\n    node.error(\"No response headers found\", msg);\n    return null;\n}\n\nconst setCookie = hdrs[\"set-cookie\"];\nif (!setCookie) {\n    node.error(\"No set-cookie header in login response\", msg);\n    return null;\n}\n\nconst cookies = Array.isArray(setCookie) ? setCookie : [setCookie];\n\nlet unifises = null;\nlet csrf = null;\n\nfor (const c of cookies) {\n    if (c.startsWith(\"unifises=\")) {\n        unifises = c.split(\";\")[0].split(\"=\")[1];\n    }\n    if (c.startsWith(\"csrf_token=\")) {\n        csrf = c.split(\";\")[0].split(\"=\")[1];\n    }\n}\n\nif (!unifises || !csrf) {\n    node.error(\"Could not extract unifises or csrf_token\", msg);\n    return null;\n}\n\nmsg.unifi_auth = {\n    cookie: `unifises=${unifises}; csrf_token=${csrf}`,\n    csrf: csrf\n};\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":900,"wires":[["6a9c14be513c2fdf"]]},{"id":"c9844850713fa87c","type":"function","z":"2d6abcf995d5eea9","name":"Build Ports 2&3 on","func":"msg.headers = {\n    \"accept\": \"application/json, text/plain, */*\",\n    \"content-type\": \"application/json;charset=UTF-8\",\n    \"cookie\": msg.unifi_auth.cookie,\n    \"x-csrf-token\": msg.unifi_auth.csrf\n};\n\nmsg.payload = {\n    port_overrides: [\n        {\n            port_idx: 2,\n            setting_preference: \"auto\",\n            name: \"Port 2\",\n            poe_mode: \"auto\",\n            autoneg: true,\n            egress_rate_limit_kbps_enabled: false,\n            forward: \"all\",\n            isolation: false,\n            native_networkconf_id: \"69d0471d73f80b4934324003\",\n            port_security_enabled: false,\n            port_security_mac_address: [],\n            tagged_vlan_mgmt: \"auto\"\n        },\n        {\n            port_idx: 3,\n            setting_preference: \"auto\",\n            name: \"Port 3\",\n            poe_mode: \"auto\",\n            port_poe: true,\n            autoneg: true,\n            egress_rate_limit_kbps_enabled: false,\n            excluded_networkconf_ids: [],\n            isolation: false,\n            native_networkconf_id: \"69d0471d73f80b4934324003\",\n            port_security_enabled: false,\n            port_security_mac_address: [],\n            tagged_vlan_mgmt: \"auto\"\n        }\n    ]\n};\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1190,"y":880,"wires":[["83b93f43b6a4b057"]]},{"id":"83b93f43b6a4b057","type":"http request","z":"2d6abcf995d5eea9","name":"Ports 2&3 on","method":"PUT","ret":"txt","paytoqs":"ignore","url":"https://192.168.178.209:8443/api/s/default/rest/device/69d0e6896f4045fbb6e372bb","tls":"52b62f6280207d9c","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1370,"y":880,"wires":[[]]},{"id":"4ca4e4b55f6ccc13","type":"function","z":"2d6abcf995d5eea9","name":"Build Ports 2&3 off","func":"msg.headers = {\n    \"accept\": \"application/json, text/plain, */*\",\n    \"content-type\": \"application/json;charset=UTF-8\",\n    \"cookie\": msg.unifi_auth.cookie,\n    \"x-csrf-token\": msg.unifi_auth.csrf\n};\n\nmsg.payload = {\n    port_overrides: [\n        {\n            port_idx: 2,\n            setting_preference: \"auto\",\n            name: \"Port 2\",\n            poe_mode: \"auto\",\n            autoneg: true,\n            egress_rate_limit_kbps_enabled: false,\n            forward: \"disabled\",\n            isolation: false,\n            native_networkconf_id: \"\",\n            port_security_enabled: true,\n            port_security_mac_address: [],\n            tagged_vlan_mgmt: \"block_all\"\n        },\n        {\n            port_idx: 3,\n            setting_preference: \"auto\",\n            name: \"Port 3\",\n            poe_mode: \"auto\",\n            port_poe: true,\n            autoneg: true,\n            egress_rate_limit_kbps_enabled: false,\n            isolation: false,\n            native_networkconf_id: \"\",\n            port_security_enabled: true,\n            port_security_mac_address: [],\n            tagged_vlan_mgmt: \"block_all\"\n        }\n    ]\n};\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1190,"y":920,"wires":[["964870e1a878fb6c"]]},{"id":"964870e1a878fb6c","type":"http request","z":"2d6abcf995d5eea9","name":"Ports 2&3 off","method":"PUT","ret":"txt","paytoqs":"ignore","url":"https://192.168.178.209:8443/api/s/default/rest/device/69d0e6896f4045fbb6e372bb","tls":"52b62f6280207d9c","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1370,"y":920,"wires":[[]]},{"id":"75aa8d8cdcf7676d","type":"server-state-changed","z":"2d6abcf995d5eea9","name":"Camera state","server":"3e4d51f1.af843e","version":6,"outputs":1,"exposeAsEntityConfig":"","entities":{"entity":["input_boolean.cameras"],"substring":[],"regex":[]},"outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"state","propertyType":"msg","value":"string","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":900,"wires":[["72cf42be9319366f"]]},{"id":"3ea9aec28edf361f","type":"switch","z":"2d6abcf995d5eea9","name":"","property":"state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1010,"y":900,"wires":[["c9844850713fa87c"],["4ca4e4b55f6ccc13"]]},{"id":"6a9c14be513c2fdf","type":"delay","z":"2d6abcf995d5eea9","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":840,"y":900,"wires":[["3ea9aec28edf361f"]]},{"id":"52b62f6280207d9c","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false,"alpnprotocol":""},{"id":"3e4d51f1.af843e","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":[],"connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false},{"id":"bc20057f4fc4b9ba","type":"global-config","env":[],"modules":{"node-red-contrib-home-assistant-websocket":"0.80.3"}}]
1 Like