I would like to create a plugin to dim my printbed led_strip light from the octoprint control tab.
I looked at the already existing plugins and found the fanslider plugin from @ntoff looking like a simple and elegant solution.
So I tried to reverse engineer based on the fanslider plugin a "lightslider" plugin.
My idea is to use a pwm signal from a gpio pin to control a mosfet which will then dim my led strip.
The hardware part is already setup and working like a charm with a standalone python script executed directly on the pi.
The final part would be to incorporate said script/commands into the lightslider plugin.
I found out that, in order to pass the value from the slider, I would need to use the SimpleApiPlugin. And incorporated that functionality with the help of this post https://discourse.octoprint.org/t/help-how-to-call-python-func-from-js/3728 .
After adding a variable for the settings page (wanted to make the gpio pin for the pwm user configurable) and renaming the variables (from fan -> to light) i tried my luck on a spare Rpi with a fresh octopi installation.
But the big bang integration did not go so well (as usual )
I found some typo's and mistakes, but finally got the plugin running without any error's in the octoprint.log.
Problem is, it isn't doing much...
I managed to add the slider and two buttons to the control tab, but they do not seem to do anything.
The tab in the octoprint settings plugin page is blank, no fields, no text, nothing.
I checked the naming conventions (since I renamed all variables containing "fan") as far as I could, to no avail.
Could somebody take a look at the code and see if he find's anything obvious? I got it sitting in front of me for three days, I feel like I can't see the wood for the trees.
The files can be found here: https://github.com/cutnicace/octoprint_lightintensityslider
Or help me by giving an example how to setup an IDE which can run the plugin embedded into the octoprint server. It would help me immensely if I could step through the single function call's for debugging.
I tried with the IDE Setup description in the Development section but got frustrated after a while, finding out the education version of PyCharm I installed did not correlate with the writeup. The community version on the other hand looks pretty much overloaded with features. I could replicate parts of the howto, but not to the extend of a running plugin in the octoprint server instance.
As a starting point for the code review, I am wondering if this is correct (it seems to work with the original plugin) but all other plugins I looked at had just a single
"__plugin_implementation__ = pluginname()" declaration.
def __plugin_load__(): global __plugin_implementation__ __plugin_implementation__ = __plugin_implementation__ = FanSliderPlugin()
Also I ask myself how the layout file for the setup tab is referenced. The .css and .js files are hardcoded into the get_assets function but the .jinja2 file is just matched by the filename containing the plugin name?
Thanks in advance