Skip to content

Commit

Permalink
Implement atcommands support
Browse files Browse the repository at this point in the history
  • Loading branch information
RoboMagus committed Oct 18, 2024
1 parent 81c7bc9 commit 8dda617
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion octoprint_LightControls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,25 @@ def get_update_information(self):
}
}


##~~ Atcommand hook

def atcommand_handler(self, _comm, _phase, command, parameters, tags=None, *args, **kwargs):
if command != "LIGHTCONTROL":
return

[light, value, *_] = parameters.split() + ["", ""]
self._logger.debug(f"@Command. Light: '{light}', Value: {value}")

if light and value:
pinNumber = self.LightName2PinNumber(light)
self.gpio_set_value(pinNumber, clamp(int(value), 0, 100))
else:
self._logger.warning("@Command incomplete! Needs format '@LIGHTCONTROL [LightName] [LightValue]'")

return None # No further actions required


##~~ Helper functions

def ext_get_light_names(self):
Expand Down Expand Up @@ -480,5 +498,6 @@ def __plugin_load__():

global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information,
"octoprint.comm.protocol.atcommand.sending": __plugin_implementation__.atcommand_handler
}

0 comments on commit 8dda617

Please sign in to comment.