Skip to content

Commit cb8073f

Browse files
authored
Update
1 parent d5eda4f commit cb8073f

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

octoprint_psucontrol_raspberrymatic/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

octoprint_psucontrol_raspberrymatic/templates/psucontrol_raspberrymatic_settings.jinja2

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,33 @@
33
<!-- /ko -->
44

55
<form class="form-horizontal">
6+
<h4>General</h4>
7+
<div class="control-group">
8+
<div class="controls">
9+
<label class="control-label">HM-IP<br/><span class="help-inline">IP of raspberrymatic with "http(s)://"</span></label>
10+
<input type="text" class="input-mini" data-bind="value: settings.plugins.psucontrol_raspberrymatic.ip"> <input type="checkbox" data-bind="checked: settings.plugins.psucontrol_raspberrymatic.enableSensing"> Enable
11+
</div>
12+
</div>
613
<h4>Switching</h4>
714
<div class="control-group">
815
<label class="control-label">On Command<br/><span class="help-inline">None to disable</span></label>
916
<div class="controls">
10-
<input type="text" class="input-mini" data-bind="value: settings.plugins.psucontrol_raspberrymatic.onCommand">
17+
<textarea rows="1" class="block" data-bind="value: settings.plugins.psucontrol_raspberrymatic.onCommand"></textarea>
1118
</div>
1219
</div>
1320
<div class="control-group">
1421
<label class="control-label">Off Command<br/><span class="help-inline">None to disable</span></label>
1522
<div class="controls">
16-
<input type="text" class="input-mini" data-bind="value: settings.plugins.psucontrol_raspberrymatic.offCommand">
23+
<textarea rows="1" class="block" data-bind="value: settings.plugins.psucontrol_raspberrymatic.offCommand"></textarea>
1724
</div>
1825
</div>
1926
<br />
2027

2128
<h4>Sensing</h4>
2229
<div class="control-group">
23-
<label class="control-label">Pin<br/><span class="help-inline">Zero to disable</span></label>
2430
<div class="controls">
25-
<input type="text" class="input-mini" data-bind="value: settings.plugins.psucontrol_raspberrymatic.sensingCommand"> <input type="checkbox" data-bind="checked: settings.plugins.psucontrol_raspberrymatic.enableSensing"> Enable
31+
<label class="control-label">Sensing Command<br/><span class="help-inline">None to disable</span></label>
32+
<input type="text" class="input-mini" data-bind="value: settings.plugins.psucontrol_raspberrymatic.sensingCommand">
2633
</div>
2734
</div>
2835
</form>

0 commit comments

Comments
 (0)