switch

powerswitchbase

class lvmnps.switch.powerswitchbase.PowerSwitchBase(name, config, log)[source]

Bases: object

Powerswitch class to manage the Digital Loggers Web power switch

Parameters
  • name (str) –

  • config ([]) –

  • log (sdsstools.logger.SDSSLogger) –

collectOutletsByNameAndPort(name, portnum=0)[source]
Parameters
  • name (str) –

  • portnum (int) –

config_get(key, default=None)[source]

DOESNT work for keys with dots !!!

findOutletByName(name)[source]
Parameters

name (str) –

abstract async isReachable()[source]

Verify we can reach the switch, returns true if ok

async setState(state, name='', portnum=0)[source]
Parameters
  • name (str) –

  • portnum (int) –

abstract async start()[source]
async statusAsJson(name='', portnum=0)[source]
Parameters
  • name (str) –

  • portnum (int) –

abstract async stop()[source]
abstract async switch(state, outlets)[source]
abstract async update(outlets)[source]

outlet

class lvmnps.switch.outlet.Outlet(swname, name, portnum, description, state)[source]

Bases: object

A power outlet class

isOff()[source]
isOn()[source]
isValid()[source]
static parse(value)[source]
setState(value)[source]
toJson()[source]

exceptions

exception lvmnps.switch.exceptions.PowerException[source]

Bases: Exception

An error occurred talking the the DLI Power switch

digital-loggers

lvmpower

class lvmnps.switch.dli.lvmpower.PowerSwitch(userid=None, password=None, hostname=None, name=None, port=None, use_https=False)[source]

Bases: object

async add_client()[source]

Access the url object

async close()[source]

Close the Connection with URL

async cycle(outlet_number)[source]

cycle power to an outlet

Parameters

outlet_number (int) –

async geturl(url='index.htm')[source]

Get a URL

load_configuration()[source]

Return a configuration dictionary

async login()[source]

Access plaintext URL logins

async off(outlet_number=0)[source]

Turn off power to an outlet

async on(outlet_number=0)[source]

Turn on power to an outlet

async onall()[source]

Turn on all outlets

async printstatus()[source]

Print the status off all the outlets as a table to stdout

async statusdictionary()[source]

Return the status of all outlets in a dictionary, each item will contain 2 items plugnumber, status

async statuslist()[source]

Return the status of all outlets in a list, each item will contain 3 items plugnumber, hostname and state

async verify()[source]

Verify we can reach the switch, returns true if ok

Powerswitch

class lvmnps.switch.dli.powerswitch.PowerSwitch(name, config, log)[source]

Bases: lvmnps.switch.powerswitchbase.PowerSwitchBase

Powerswitch class to manage the iboot power switch

Parameters
  • name (str) –

  • config ([]) –

  • log (sdsstools.logger.SDSSLogger) –

async cycle(name, portnum)[source]
async isReachable()[source]

Verify we can reach the switch, returns true if ok

async start()[source]
async stop()[source]
async switch(state, outlets)[source]
async update(outlets)[source]

iboot

iboot

Copyright (c) 2013, Luke Fitzgerald All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project.

class lvmnps.switch.iboot.iboot.ChangeRelayCommand(interface, relay, state)[source]

Bases: lvmnps.switch.iboot.iboot.RelayCommand

DESCRIPTOR = 'CHANGE_RELAY'
PAYLOAD_STRUCT = <Struct object>
class lvmnps.switch.iboot.iboot.ChangeRelaysCommand(interface, relay_state_dict)[source]

Bases: lvmnps.switch.iboot.iboot.RelayCommand

DESCRIPTOR = 'CHANGE_RELAYS'
PAYLOAD_STRUCT = <Struct object>
class lvmnps.switch.iboot.iboot.DXPCommand(interface)[source]

Bases: object

async do_request()[source]
COMMAND = None
DESCRIPTOR = None
DESCRIPTOR_MAP = None
PAYLOAD_STRUCT = None
class lvmnps.switch.iboot.iboot.GetRelaysRequest(interface)[source]

Bases: lvmnps.switch.iboot.iboot.IOCommand

async do_request()[source]
DESCRIPTOR = 'GET_RELAYS'
class lvmnps.switch.iboot.iboot.IOCommand(interface)[source]

Bases: lvmnps.switch.iboot.iboot.DXPCommand

COMMAND = 'IO'
DESCRIPTOR_MAP = {'CHANGE_RELAY': 1, 'CHANGE_RELAYS': 2, 'GET_INPUT': 5, 'GET_INPUTS': 6, 'GET_RELAY': 3, 'GET_RELAYS': 4, 'NULL': 0, 'PULSE_RELAY': 7}
class lvmnps.switch.iboot.iboot.PulseRelayRequest(interface, relay, state, width)[source]

Bases: lvmnps.switch.iboot.iboot.RelayCommand

DESCRIPTOR = 'PULSE_RELAY'
PAYLOAD_STRUCT = <Struct object>
class lvmnps.switch.iboot.iboot.RelayCommand(interface)[source]

Bases: lvmnps.switch.iboot.iboot.IOCommand

STATE_MAP = {True: 1, False: 0, 'NO_CHANGE': 2}
class lvmnps.switch.iboot.iboot.iBootInterface(ip, username, password, num_relays=3, log=None, port=9100)[source]

Bases: object

async connect()[source]
disconnect()[source]
async get_relays()[source]
get_seq_num()[source]
increment_seq_num()[source]
async pulse_relay(relay, on, length)[source]
async switch(relay, on)[source]

Switch the given relay on or off

async switch_multiple(relay_state_dict)[source]

Change the state of multiple relays at once

State dictionary should be of the form:

{1: True}

where the key is the relay and the value is the new state

Powerswitch

class lvmnps.switch.iboot.powerswitch.PowerSwitch(name, config, log)[source]

Bases: lvmnps.switch.powerswitchbase.PowerSwitchBase

Powerswitch class to manage the iboot power switch

Parameters
  • name (str) –

  • config ([]) –

  • log (sdsstools.logger.SDSSLogger) –

async isReachable()[source]

Verify we can reach the switch, returns true if ok

async start()[source]
async stop()[source]
async switch(state, outlets)[source]
async update(outlets)[source]