@@ -22,10 +22,10 @@ def __init__(self):
2222
2323 def get_settings_defaults (self ):
2424 return dict (
25+ ip = 'None' ,
2526 onCommand = 'None' ,
2627 offCommand = 'None' ,
2728 senseCommand = 'None' ,
28- enableSensing = False ,
2929 )
3030
3131
@@ -57,35 +57,35 @@ def on_startup(self, host, port):
5757 psucontrol_helpers ['register_plugin' ](self )
5858
5959 def turn_psu_on (self ):
60- if self .config ['onCommand' ] == 'None' or self .config ['offCommand' ] == 'None' :
60+ if self .config ['onCommand' ] == 'None' or self .config ['offCommand' ] == 'None' or self . config [ 'ip' ] == 'None' :
6161 self ._logger .warning ("Switching is not enabled" )
6262 return
6363 try :
64- requests .get (self .config ['onCommand' ])
64+ requests .get (self .config ['ip' ] + self . config [ ' onCommand' ])
6565 except Exception :
6666 self ._logger .exception ("Exception while Switching" )
6767
6868
6969
7070
7171 def turn_psu_off (self ):
72- if self .config ['offCommand' ] == 'None' or self .config ['onCommand' ] == 'None' :
72+ if self .config ['offCommand' ] == 'None' or self .config ['onCommand' ] == 'None' or self . config [ 'ip' ] == 'None' :
7373 self ._logger .warning ("Switching is not enabled" )
7474 return
7575 try :
76- requests .get (self .config ['offCommand' ])
76+ requests .get (self .config ['ip' ] + self . config [ ' offCommand' ])
7777 except Exception :
7878 self ._logger .exception ("Exception while Switching" )
7979
8080
8181 def get_psu_state (self ):
82- if self .config ['senseCommand' ] == 'None' :
82+ if self .config ['senseCommand' ] == 'None' or self . config [ 'ip' ] == 'None' :
8383 self ._logger .warning ("Sensing is not enabled" )
8484 return 0
8585
8686 r = 0
8787 try :
88- r = ET .fromstring (requests .get (self .config ['senseCommand' ]).text ).find ("datapoint" ).get ("value" )
88+ r = ET .fromstring (requests .get (self .config ['ip' ] + self . config [ ' senseCommand' ]).text ).find ("datapoint" ).get ("value" )
8989 except Exception :
9090 self ._logger .exception ("Exception while reading State" )
9191 return False
0 commit comments