Skip to content

Commit

Permalink
Merge branch 'edekeijzer-helpers' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
kantlivelong committed Apr 3, 2021
2 parents 0238f16 + a741f0c commit 67de0cd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion octoprint_psucontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ def _check_psu_state(self):

self._logger.debug("isPSUOn: %s" % self.isPSUOn)

if (old_isPSUOn != self.isPSUOn):
self._logger.debug("PSU state changed, firing psu_state_changed event.")
event = Events.PLUGIN_PSUCONTROL_PSU_STATE_CHANGED
self._event_bus.fire(event, payload=dict(psu_state=self.isPSUOn))

if (old_isPSUOn != self.isPSUOn) and self.isPSUOn:
self._start_idle_timer()
elif (old_isPSUOn != self.isPSUOn) and not self.isPSUOn:
Expand Down Expand Up @@ -809,6 +814,12 @@ def get_update_information(self):
)
)

def get_psu_state(self):
return self.isPSUOn

def register_custom_events(self):
return ["psu_state_changed"]

__plugin_name__ = "PSU Control"
__plugin_pythoncompat__ = ">=2.7,<4"

Expand All @@ -819,5 +830,13 @@ def __plugin_load__():
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.comm.protocol.gcode.queuing": __plugin_implementation__.hook_gcode_queuing,
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information,
"octoprint.events.register_custom_events": __plugin_implementation__.register_custom_events
}

global __plugin_helpers__
__plugin_helpers__ = dict(
get_psu_state = __plugin_implementation__.get_psu_state,
turn_psu_on = __plugin_implementation__.turn_psu_on,
turn_psu_off = __plugin_implementation__.turn_psu_off
)

0 comments on commit 67de0cd

Please sign in to comment.