dwighthubbard / python-dlipower

Python modules to manage Digital Loggers Web Power Switch
Other
54 stars 35 forks source link

Login Issue #25

Closed sush35 closed 8 years ago

sush35 commented 8 years ago

Hi,

I just setup python module for the web power switch and wanted to run the sample code to turn off the a outlet. Following is the code I am using: from future import print_function import dlipower

print('Connecting to a DLI PowerSwitch') switch = dlipower.PowerSwitch(hostname="http://192.168.0.100/", userid="admin",password="1234")

print('Turning off the first outlet') switch.off(1)

And following is the error log:

$ python HelloWebPowerSwitch.py Connecting to a DLI PowerSwitch Turning off the first outlet Traceback (most recent call last): File "HelloWebPowerSwitch.py", line 8, in switch.off(1) File "/usr/local/lib/python2.7/dist-packages/dlipower-0.7.152-py2.7.egg/dlipower/dlipower.py", line 341, in off self.geturl(url='outlet?%d=OFF' % self.determine_outlet(outlet)) File "/usr/local/lib/python2.7/dist-packages/dlipower-0.7.152-py2.7.egg/dlipower/dlipower.py", line 311, in determine_outlet if outlet_int <= 0 or outlet_int > self.len(): File "/usr/local/lib/python2.7/dist-packages/dlipower-0.7.152-py2.7.egg/dlipower/dlipower.py", line 188, in len self.__len = len(self.statuslist()) TypeError: object of type 'NoneType' has no len()

I think the root cause it its unable to login the web power switch, hence erroring out when I try to access a outlet.

Kindly let me know, how I can fix this issue..

Thanks, Sushant

dwighthubbard commented 8 years ago

The hostname should be the hostname or ip address of the switch.

I.E. remove the http: and all of the / characters from the hostname.