I’m trying to develop new rules wth Jython on OH3 GUI (3.1.1) and I don’t find the way to install libraries.
For example requests is not present and I need it.
I’ve searched pip and I find it only for py3.9 (pf OpenHABian) when in the GUI the displayed version of Python is 2.7.
First of all, I assume you have the correct helper libraries installed.
You’ll need to install Python 2.7 to get access to pip2. Make sure it doesn’t take over your Python 3 as the default. Note, Python 2.7 has been end of life for a couple years now so it may not be available in the packages.
From there you can use pip2 to install the library in a folder and pass a command line argument to openHAB to tell it to look in that folder for libraries. See Adding python modules to jython.
Personally, given the state of Jython I’m not sure I would spend too much time on this. Until such time that someone builds support for GraalVM Python 3 in openHAB you would better off switching to HABApp (if you want to stick with Python) or JSScripting if you are willing to change languages. JSScripting supports installing third party libraries using npm in a standard way without a lot of these work arounds.
Usualy I develop in Python so I think HABApp should be the best approch for me (and if I can stay away of the 2.7 it’s much better ^^)
But I’ve in another hand the automation to deploy and provision OH3 where currently I use the OH3 API (GUI is nice for one shot but I’m a DevOps XD).
At this time I’ve not learnt a lot about HABApp so I think it will be my next doc with the priority to check if it can be deployed and maintain with a nice fashion (API is the must of course but I don’t have find it during my first reading).
Any guidance is really appreciate, thanks again!
I understand well the concept of the local files but not sure it fit with my needs:
if I’ve understood well, OH3 has switched on GUI approch, replacing the local files by json doc objects reachable by API (the std way of developping srv app in 2021 ^^). I presume the futur will be more and more on this way (and so with more API path to allow more jobs ).
the automation can easily handle these two kinds of job which are deployment and update but it’s a longuer process than an app (in Py for ex ^^) which drive the conf through the API. Additionnaly we split clearly the infrasctruture and application installation (generic) vs the configuration (specific).
a small thing depending of your infra/network/secu, deploying local files implies to open a TCP port to allow the connexion on the FS, may be not applicable on some context
The HABApp on container seams interesting and, to keep aligned the techno, OH3 (+RaspAP in my case) must be migrated also on container. So to keep the same flexibility on the file mgt we’re reaching EKS (on Rpi in my case) losing the easy way of using OpenHABian.
So at the end and to Keep It Simple & Stupid, I’ll be back on the std Jython rules like @JimT said (at least to check what I can do with til the blocking point and take decision when I’ll be on ^^)
So sorry to be picky , I’ve bad habit to think industrialization but it’s also an opportunity for me to grow on OH
No OH 3 added support for a UI approach. Text files for just about everything except MainUI Widgets are and will remain supported through text files. Local files have not been replaced and probably never will be replaced. However, new features that are added to OH may not get a text file equivalent config going forward. For example, there is no text file format where one can define UI widgets. There is no text file equivalent for Rule Templates (yet, I expect and will push for that though to aide in development and testing of templates.