Power Strip¶
Class PowerStrip¶
-
class
power_strip.power_strip.PowerStrip¶ This class provides the Interface for the basic functions to manage the power strip.
-
create_command(port_id: int, on_or_off: bool) → str¶ Generates the command to set the selected port to up or down.
Parameters: - port_id – Port to be set
- on_or_off – Turn on or off
Returns: Command as string to set power on port
-
port_status(port_id) → str¶ Returns the status of the requested port.
Parameters: port_id – port to be checked Returns: Command to query port status
-
Class PowerStripControl¶
-
class
power_strip.power_strip_control.PowerStripControl(router: router.router.Router, power_strip: power_strip.ubnt.Ubnt, on_or_off: bool, port: int)¶ This class controls the power strip. It can switch the power on a port. It also checks if the power was actually turned on/off.
-
create_command(on_or_off: bool, port: int)¶ Creates the command to turn the power on the given port on or off.
Parameters: - on_or_off – ‘True’ for on, ‘False’ for off
- port – ID of the port
Returns: Command as a str to control the power on the port given
-
run()¶ Sets the power on the port to on/off. Also checks if the power is truly on/off.
-
-
class
power_strip.power_strip_control.PowerStripControlJob(router: router.router.Router, on_or_off: bool, port: int)¶ Encapsulate PowerStripControl as a job for the Server.
-
post_process(data: {}, server) → None¶ Updates the router in the Server with the new information.
Parameters: - data – Result from run()
- server – The Server
-
run()¶ Starts PowerStripControl in a new thread.
Returns: Powerstrip-Obj and Router-Obj in a dictionary
-
Class Ubnt¶
-
class
power_strip.ubnt.Ubnt(sid: int, vlan_iface_name: str, vlan_iface_id: int, ip: str, ip_mask: int, usr_name: str, usr_password: str, n_ports: int)¶ This class implements an API for the Ubiquiti mPower 6-Port mFi Power Strip running on Firmware version 2.1.11. Different ports can be turned on or off, each port corresponds to a Router.
-
create_command(port_id: int, on_or_off: bool)¶ Switches the power on the given port.
Parameters: - port_id – ID of port to be switched
- on_or_off – Switch power to: ‘True’ for on, ‘False’ for off
-
id¶ ID of power strip.
Returns: ID as int
-
ip¶ IP of power strip.
Returns: IP number as string
-
ip_mask¶ IP mask.
Returns: ip mask
-
n_ports¶ Number of Ports.
Returns: number of ports
-
namespace_name¶ Name of namespace.
Returns: namespace name
-
port_status(port_id)¶ Checks if power on port is on or off.
Parameters: port_id – ID of power strip port Returns: ‘1’ for on or ‘0’ for off, ‘2’ for error
-
usr_name¶ Username.
Returns: user name
-
usr_password¶ User password.
Returns: user password
-
vlan_iface_id¶ VLAN ID of power strip.
Returns:
-
vlan_iface_name¶ Used VLAN name from server for this power strip.
Returns:
-