Skip to content

Commit 43bf804

Browse files
authored
Merge pull request #12 from OctoPrint/fix/issue11
🐛 Properly honor disabled check Fixes #11
2 parents 793e00d + a93ae1e commit 43bf804

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

octoprint_pi_support/__init__.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,17 @@ def __init__(self):
277277
self._throttle_check = None
278278
self._throttle_undervoltage = False
279279
self._throttle_overheat = False
280-
self._throttle_functional = True
280+
self._throttle_check_enabled = True
281+
self._throttle_check_functional = True
282+
283+
def initialize(self):
284+
self._throttle_check_enabled = self._settings.get_boolean(
285+
["vcgencmd_throttle_check_enabled"]
286+
)
287+
if not self._throttle_check_enabled:
288+
self._logger.warning(
289+
"Throttle check via vcgencmd disabled by user. Potential undervoltage or overheating issues will not be detected."
290+
)
281291

282292
# Additional permissions hook
283293

@@ -311,7 +321,9 @@ def get_additional_environment(self):
311321
result = {"model": get_proc_dt_model()}
312322

313323
self._check_throttled_state()
314-
if self._throttle_functional:
324+
result["throttle_check_enabled"] = self._throttle_check_enabled
325+
result["throttle_check_functional"] = self._throttle_check_functional
326+
if self._throttle_check_enabled and self._throttle_check_functional:
315327
result["throttle_state"] = self._throttle_state.raw_value_hex
316328

317329
if is_octopi():
@@ -331,8 +343,9 @@ def on_api_get(self, request):
331343
result = self.get_additional_environment()
332344
result.update(
333345
{
346+
"throttle_enabled": self._throttle_check_enabled,
347+
"throttle_functional": self._throttle_check_functional,
334348
"throttle_state": self._throttle_state.as_dict(),
335-
"throttle_functional": self._throttle_functional,
336349
"model_unrecommended": is_model_any_of(
337350
result.get("model"), *_UNRECOMMENDED_MODELS
338351
),
@@ -445,19 +458,22 @@ def _check_throttled_state_interval(self):
445458
return _CHECK_INTERVAL_OK
446459

447460
def _check_throttled_state_condition(self):
448-
return self._throttle_functional
461+
return self._throttle_check_enabled and self._throttle_check_functional
449462

450463
def get_throttle_state(self, run_now=False):
451464
"""Exposed as public helper."""
452465
if run_now:
453466
self._check_throttled_state()
454467

455-
if not self._throttle_functional:
468+
if not self._throttle_check_enabled or not self._throttle_check_functional:
456469
return False
457470

458471
return self._throttle_state.as_dict()
459472

460473
def _check_throttled_state(self):
474+
if not self._throttle_check_enabled:
475+
return
476+
461477
command = self._settings.get(["vcgencmd_throttle_check_command"])
462478

463479
self._logger.debug('Retrieving throttle state via "{}"'.format(command))
@@ -472,7 +488,7 @@ def _check_throttled_state(self):
472488
getuser()
473489
)
474490
)
475-
self._throttle_functional = False
491+
self._throttle_check_functional = False
476492
return
477493

478494
if self._throttle_state == state:

octoprint_pi_support/templates/pi_support_settings.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<label class="checkbox">
3838
<input type="checkbox" data-bind="checked: settings.plugins.pi_support.vcgencmd_throttle_check_enabled"> {{ _('Enable under voltage and overheat detection via <code>vcgencmd get_throttled</code>') }}
3939
</label>
40-
<span class="help-block">{{ _('This will regularly check with the Pi if something is amiss either with power regulation or CPU/GPU temperature.') }}</span>
40+
<span class="help-block">{{ _('This will regularly check with the Pi if something is amiss either with power regulation or CPU/GPU temperature. Disable at your own risk. You will have to re-enable this when getting assistance on the forums or Discord. Changes require a restart of OctoPrint.') }}</span>
4141
</div>
4242
</div>
4343

0 commit comments

Comments
 (0)