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.
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