Trying to Develop a Sub-Plugin for PSU Control for openHAB3

Dear Experts,

I've been running octopi for quite a while now and I came to the point, that I wanted to integrate OctoPi with an Open Source Smart Home Hub called openHAB3.

The Idea seems pretty easy, as there is already a similiar Sub-Plugin for a similiar Smart Home Software: The PSUControl HomeAssistant Subplugin. Both offer a REST-based API to switch on or off hardware and with a little tweeking it should be easy to integrate openHAB3.

As this is my first try on Github and developing on OpenSource-Software on my own, please do not kill me if I did anything wrong.
I forked the existing Sub-Plugin and made some Code-Adjustments to it, so that it should be working with openHAB instead of HomeAssistant.

But somehow, I'm struggling with the configuration.

I'm able to install the plugin via the gitHub URL. But afterwards it is not possible to do any changes and safe them in the settings menu. The Save button is permanently "rotating". When uninstalling the plugin, Octoprint works fine again. Logs do not display anything helpful...

I've go the feeling that something's wrong inside my psucontrol_openhab3_settings.jinja2 - I'm thinking Octoprint does not even pickup the settings there. Interaction on the configuration page is ot working at all - can be checked when selecting an Authorization Method - in theory the displayed fields on the page should change, but they don't.

You can have a look at the code here:

Am I missing something out? Do you have an idea?
Is there anywhere any documentation I can read regarding this?

It's my first GitHub Project like that, so sorry if there is something wrong with the fork/release/readme page, whatever...
Any feedback would be greatly appreciated!

Thank you!

Have you been through the 'Developing plugins' section of the docs? There's also a plugin tutorial if you want to learn how it all fits together.

https://docs.octoprint.org/en/master/plugins/index.html

PSU control sub-plugins are exactly the same as other plugins, with a few specific hooks. I'll take a look at the code later to see what jumps out, I'm not at my laptop now to have a look.

Two things stand out:

authorizationMethod isn't defined on the py side

Pretty sure the variables inside the ko if need ()

Thanks for pointing that out!
I released a version 1.0.1 containing your ideas - unfortunately, the problems stays the same - nothing changed.

First thing: thats because I added the authorizationMethod later and forgot about it...but now, I added it to the definition.

Second: funny thing: thats the only part I did not change from the fork :slight_smile:
I added the brackets () after the variable, but nothing changed.
I'll have some spare time tomorrow, I'll look into the docs @Charlie_Powell linked.
Thank you guys! :slight_smile: :grinning_face_with_smiling_eyes:

Dang it, there was a typo in the if clause for the authorizationMethod...fixed that and now the plugin seems to be loading.


Will test it and see if it works from a functional perspective now :grinning_face_with_smiling_eyes:

Looked right past that :slight_smile: