Unifi provide switches for POE ports

The Unifi support is really quite nice as it is. +1 for this work.

For the switches with PoE, it seems very appropriate to provide the PoE ports as switch items.

With IoT, I’ve been converting most of my devices over to PoE with PoW splitters from Wifi Texas. Using this I could control or reboot most of my smaller devices in my house.

Current unifi controller support is provided through unifi.py

It look like Unifi.py currently support get.client(currently implemented, get.stats, block/unblock client, get stats, get config and maybe few other things. You may ask developer there to add the support then try get HA dev to add support but not sure if it is even possible.

With that said, I found this script that allow you to do it via CLI but not sure how controller will react to CLI changes
Steps via CLI:

ssh into your switch [email protected]
US.v3.7.12# telnet localhost 2222
The changes may break controller settings and only be effective until reboot.
(UBNT) >
(UBNT) >en
(UBNT)# conf
(UBNT) (Config)# interface 0/2
(UBNT) (Config)#poe opmode shutdown
(UBNT) (Config)#exit

I do agree though.
This would be great if possible. Would be great to have indoor cam that turn OFF(hardware not software) when I am home or maybe just in room

Support seems implemented in this tool along with many other function. Maybe good reference.

I have a suspicion there’s an API for this on the controller, rather than talking to the switch directly

Did you ever git this to work? I have create a command line switch to do this but cannot get it to work even-though the ssh commands work prefect from the ubuntu server instance the my docker runs on where HA is installed as a container.

# Switch for Wifi control with PoE and Unifi
    platform: command_line
        command_on: ssh [email protected] '(echo "enable" ; echo "configure" ; echo "interface '0/7'" ; echo "poe opmode auto" ; echo "exit" ; echo "exit" ; echo "exit") | telnet localhost 23 ; exit;'
        command_off: ssh [email protected] '(echo "enable" ; echo "configure" ; echo "interface '0/7'" ; echo "poe opmode shutdown" ; echo "exit" ; echo "exit" ; echo "exit") | telnet localhost 23 ; exit;'
        friendly_name: Wifi PoE Switch

Old thread but here’s what I did to turn interior cameras on/off. I have a input.boolean switch to trigger several automation actions. Here’s example for a specific camera off/on.

  cam_gr_on: ssh -i /config/.ssh/switch_rsa [email protected] 'sh -s' < /config/bin/unifi_cam_on
  cam_gr_off: ssh -i /config/.ssh/switch_rsa [email protected] 'sh -s' < /config/bin/unifi_cam_off

Here is the unifi_cam_on:

echo enable
echo configure
echo "interface '0/8'"
echo "poe opmode auto"
sleep 1
} | telnet localhost

Here’s what I get in the log file:

2018-09-20 09:57:04 DEBUG (MainThread) [homeassistant.components.shell_command] Stdout of command: `ssh -i /config/.ssh/neattic_switch_rsa [email protected] 'sh -s' &lt; /config/bin/unifi_cam_gr_off`, return code: 0:
(UBNT) &gt;enable
(UBNT) #configure
(UBNT) (Config)#interface '0/8'
(UBNT) (Interface 0/8)#poe opmode shutdown
(UBNT) (Interface 0/8)#
Entering character mode

You could have templates and variables to reduce this but in the interest of security I avoided variables and eval in the shell scripts. Another thing I did is configure ssh on the homeassistant environment to set “strictHostKeyChecking no” to avoid the interactive “Host key verification”.

Edit: I used the log excerpt for shutdown while showing the cam_on script.