Suggestions to automate switching on and off POE IP cameras

Hi,
I have about 16 IP cameras on a brocade ICX6450 POE switch. I would like to power off certain cameras on a schedule.
Is there anyway i can make this automation?

If so, how?

Any suggestions appreciated

If they are run off a managed POE switch, you could script it fairly easily to disable / enable certain ports.

Sorry but I am quite new at this. How exactly do you do this?

First question, and without me personally googling it for you, is the Brocade ICX6450 a managed switch? In other words, can you telnet or ssh too it and logon with username and password? If so, then you can usually disable or enable certain switch ports via config commands. You would work out what the commands are, then add to a script file which would be called by the exec binding. You would need a switch item configured per port, that turns the port on or off. The on or off would call the script, which would connect to the switch, execute the enable or disable command on a certain port, then exit.

Yes, the ICX6450 is a level 3 managed switch, which I can SSH to.
So there is a way to load a script in the switch upon start up?

This will allow OpenHAB to disable a port, done on your Raspberry pi that OpenHAB runs on (not done ‘on the switch itself’). I can’t tell you exact commands, as I don’t usually manage Brocade, I usually use Extreme, Juniper or Cisco. But this should give you an idea. Create a script file on your OpenHAB Raspberry pi home folder. Say, call it ‘disableport.sh’. Edit the file and add contents that perform the desired commands to disable an interface. Eg, assuming these were the commands:

#!/bin/bash
echo config interface > portscript
echo edit port 1>> portscript
echo set disable >> portscript
echo end >> portscript
echo exit >> portscript
sshpass -p SwitchPassword ssh -T -o StrictHostKeyChecking=no admin@1.2.3.4 < portscript
echo “Port 1 Disabled”
rm portscript

Where ‘SwitchPassword’ is the password to the switch, admin@1.2.3.4 is the username and IP address.

You would add an Exec thing and set the command to point to the disableport.sh script, so /home/pi/disableport.sh probably. You’ll need to chmod the file to be rwxrwx— and probably chown to be openhab:pi I think.

You could use say, $1 in the script which is called from the Exec binding, to specify disable or enable on the port. You’d need to use a transform to pass this correctly, but for now you could test it simply to confirm it works. You’ll probably need to install sshpass, I think ‘sudo apt-get install sshpass’ (can’t recall exactly)

Anyways, that should give you the general idea!

1 Like

This might also work for you?

I never got around to trying it but I purchased a switch that had the SNMP feature and openHAB has a binding for this protocol. I believe you can use that to turn POE on and off on ports but as mentioned I never have the time to try it out yet and a lot of switches do not have that support.

Another option is to buy a multiport poe injector and place those cameras on that one. Then you can buy any smartplug (zwave,zigbee wifi or similar) to turn those cameras off by cutting power to the poe injector.

I turn on and off some poe devices, I use an expect script to do so. I find it a lot easier to use expect rather than bash when connecting to various clis.

Regards S

Hi Seaside,

My POE IP cameras are on a separate vlan. Would this multiport poe injector work and still allow me to view and record the footages?
Can you share exactly how you did your script? are you also using a brocade or ruckus POE switch?

Which vlan it is on won’t matter, the poe injector will only provide it with power (instead of the switch). No you can’t record or view footage on the specific cameras you put on the inject those will be powered down when you cut power (which I guess was the idea in the first place)
If you have cameras that should not be powered off or a NVR you don’t put it on the same poe injector, better put those on your Brocade switch.

Other options if you still want to view and record footage is to disable recording depending on what type of camera you are running. Or add some sort of privacy filter that you can enable and disable (possible on some cameras).

For turning off poe I use something like this on my juniper switches:

#!/usr/bin/expect
set username [lindex $argv 0]
set password [lindex $argv 1]
set host [lindex $argv 2]
set port [lindex $argv 3]
set interface [lindex $argv 4]
spawn ssh $username@$host -o StrictHostKeyChecking=no
expect "Password:"
send "$password\r"
expect "root@*:RE:0%"
send "cli\r"
expect "root@*>"
send "configure\r"
expect "root@*#"
send "set poe interface $interface disable\r"
send "commit"
send "exit\r"
send "exit\r"
expect "Connection to $host closed."
1 Like

Would something like this work?

Without knowing if your cameras work with 802af

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