Skip to content

Commit

Permalink
Minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
kantlivelong committed Apr 3, 2021
1 parent 67de0cd commit ef3a107
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions octoprint_psucontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ def _check_psu_state(self):

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))
self._event_bus.fire(event, payload=dict(isPSUOn=self.isPSUOn))

if (old_isPSUOn != self.isPSUOn) and self.isPSUOn:
self._start_idle_timer()
Expand Down Expand Up @@ -613,6 +614,10 @@ def turn_psu_off(self):
time.sleep(0.1)
self.check_psu_state()


def get_psu_state(self):
return self.isPSUOn

def on_event(self, event, payload):
if event == Events.CLIENT_OPENED:
self._plugin_manager.send_plugin_message(self._identifier, dict(hasGPIO=self._hasGPIO, isPSUOn=self.isPSUOn))
Expand Down Expand Up @@ -814,9 +819,6 @@ def get_update_information(self):
)
)

def get_psu_state(self):
return self.isPSUOn

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

Expand All @@ -839,4 +841,4 @@ def __plugin_load__():
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 ef3a107

Please sign in to comment.