[SOLVED] Openhab Docker or not?

For simple use cases this might be true. But if you try rule inheritance, scheduling function calls, rule creation on the fly, rule parametrization through yml files etc. it gets ugly rather quickly.
Maybe you can try it out and we’ll discuss your experiences ? I’d be really happy about it.

To get back to topic:
@goodfore:
It’s super easy to spin up an HABApp container alongside an Openhab container.
Maybe give it a try - migrating your python script should be effortless.
Use a python IDE and you get syntax highlighting. You might even like it :wink:

That is luckily not correct :slight_smile: You can use pip when you use the full jython-installer.jar.

Assuming Jython is installed in /openhab/conf/automation/jython you can exec bash in the running container.

Then go to and execute /openhab/conf/automation/jython/bin/jython -m pip install <package(s) to install>

For example to install the python-dateutil package:

root@marcel-desktop:/openhab/conf/automation/jython/Lib/site-packages# /openhab/conf/automation/jython/bin/jython -m pip install python-dateutil
Downloading/unpacking python-dateutil
  Downloading python_dateutil-2.8.0-py2.py3-none-any.whl (226kB): 226kB downloaded
Downloading/unpacking six>=1.5 (from python-dateutil)
  Downloading six-1.12.0-py2.py3-none-any.whl
Installing collected packages: python-dateutil, six
Successfully installed python-dateutil six
Cleaning up...
root@marcel-desktop:/openhab/conf/automation/jython/Lib/site-packages# ls
 certifi		       dateutil		    _markerlib		     python_dateutil-2.8.0.dist-info   setuptools			  six.py
 certifi-2019.6.16.dist-info   easy_install.py	    pip			     README			       setuptools-14.3.2.dev0.dist-info   urllib3
 chardet		       idna		    pip-1.6.dev1.dist-info   requests			      'six$py.class'			  urllib3-1.25.3.dist-info
 chardet-3.0.4.dist-info       idna-2.8.dist-info   pkg_resources	     requests-2.22.0.dist-info	       six-1.12.0.dist-info
root@marcel-desktop:/openhab/conf/automation/jython/Lib/site-packages# 

I haven’t tried actually using them, but the installation of packages using pip seems to work fine.

2 Likes

Interesting. Is that a limitation for using Jython in Openhab? or Jython can’t use pip at all? I read somewhere that Jython does support ensurepip, or at the very least, you can easysetup pip for Jython.

The answer is beyond my expertise.

Spaceman_Spiff:

For simple use cases this might be true. But if you try rule inheritance, scheduling function calls, rule creation on the fly, rule parametrization through yml files etc. it gets ugly rather quickly.
Maybe you can try it out and we’ll discuss your experiences ? I’d be really happy about it.

Well, none of those things are possible in Rules DSL and none of those are things I would expect even the typical OH user to ever do. So it’s kind of a false comparison.

  • rule inheritance: for the “average” user moving from Rules DSL, they would be expected to use Rule Templates rather than inheritance. Inheritance as a concept is already too complicated for the average user.
  • scheduling function calls: Creating timers using OH Timers or Python timers is equally as easy as is done in Rules DSL
  • rule creation on the fly: I’ve not done this myself yet but all indications are this too is very easy. And you can disable Rules programatically as well so instead of needing an (if some Item is of state X) in a Rule, you can just disable the Rule.
  • Rules DSL also works in Python IDEs, I use VSCode with the most popular Python extension.

Spaceman_Spiff:

Maybe you can try it out and we’ll discuss your experiences ? I’d be really happy about it.

I’m unlikely to try it out because my main focus is on supporting new and non-technical users. As such, even my experiments with JSR223 Jython Rules is a stepping stone to UI created Rules (i.e. Rules that get stored in the JSONDB). When the new UIs get released with the graphical rule builder this is how most new/non-technical users will be developing their rules so that is where I need to have expertise and knowledge. I can and will continue to tell people about your HABApp but for me it would be a dead end.

marcel_erkel:

but the installation of packages using pip seems to work fine.

Cool. I remember seeing Scott post a reply to a thread that it wasn’t possible. I’ve not the experience or expertise to verify that and I may be completely miss remembering the post.

I’m with you - HABApp is not for non-technical users.
It’s an automation solution for users who want to write rules in python (3).

Ah - is there also something with auto-complete for functions and type hints?
This was not possible when I was playing around with jsr223. I had to inspect every java object through a rule and then make calls accordingly.

That’s a shame but I understand. :slight_smile:

I believe so but honestly, I’ve lately been doing most of my coding over ssh using vim because the VNC server on my desktop VM isn’t working right now. I’m pretty sure that, for example, when I type in DateTime.now(). I get all the Joda DateTime methods in a list.

It doesn’t have Item name awareness though which is a big difference from Rules DSL.

I thought I’d step in here for a moment and be the naysayer…

I find Docker really hard to deal with. Everything is at least one level removed from where it’s running, and I’ve found building and maintaining containers to be a huge hassle. It’s like building a ship in a bottle instead of just making a model.

At work, we have huge servers, and we need to move things from server to server quickly. Docker helps there, and is worth both the minor overhead (compared to our huge servers) and the effort of maintaining the containers.

For OH, especially on a dedicated system like an RPI, I don’t see it as worth the effort. It just makes everything harder and makes diagnosing problems that much more difficult.

I would suggest you spend time more on a build tool like Ansible, and on having good backups than struggling to get OH to run in Docker.

But, others here seem to find it easy and manageable, so maybe I’m a luddite or missing some docker-savvy and doing things the hard way. It wouldn’t be the first time. :slight_smile:

But for a small, dedicated host, I don’t see how Docker is much of a win.

User Ansible to manage your Docker images and containers. I personally find Dinner really ready to deal with but with one exception, I only use unmodified official images. The one I build myself, Calibre, is because there is no official container for that.

Now I will say, there are programs that I wouldn’t touch on Docker at home (I’m looking at you Alfresco) but for everything else is been really simple and I don’t run into any conflicts on ports, libraries, files, or anything like that.

Most of the things you site are mostly problems for people building images. And that use indeed more challenging. But once built, it’s super easy for the users of there image, and that’s part of the point. Let the experts deal with all the new of dealing with dependencies and such, just give be an image that works.

And then, part of what I think Markus is after, you have something you can much more easily user in automated testing and to give developers a single Bob l boob that just works.

I agree, but how many people, even those running on RPis are truly running on a dedicated host. Almost everyone is running a host of services in that host.

raises hand

No frontail, no Mosquitto, no InfluxDB and Grafana, no Amanda?

Nope.
apcupsd & nginx reverse proxy. Will likely look at Jython.
I primarily use Z-Wave devices.
Don’t forget I am still a newbie.

I’m also running a dedicated rpi for openhab. Will probably run mosquitto server there in the future, but have it on my main server for now. I prefer to not use docker for openhab, but I use docker for almost everything else, both at home and professionally.

I agree with adding an additional layer, docker, when running on a dedicated host is not beneficial enough for me. I have a dedicated pfsense box as well, but all my other services are run in docker containers.

I guess it is a matter of taste.

/S

1 Like

Hi, I’m very new to Openhab, I’ve just got an install working using openhabian, and before I go in too deep am wondering whether to install openhab in docker or whether openhabian is the way to continue.

I’ve currently got openhabian running on a Raspberry Pi 4. I’m not after advice on how to get it to work in docker, I’ll happily read up on it, but I guess I just want to know what justification people have for using docker and how many of you do and don’t use it over say openhabian or openhab on another OS.

Hey @Jorggs you could try my eze-openHab-docker setup

for example why I use docker see:

https://community.openhab.org/t/the-openhab-2-5-0-update-process-my-experience

Hi, thanks for that, do you use docker rather than openhabian for a particular reason? I know it makes swapping in and out versions easier and allows easier backups, but a single install running on a raspberry pi that I can regularly back up and restore from seems fine to me. I honestly don’t know if I’m missing something. I’m also a bit long in the tooth and I suppose I’m not sure I need another learning curve going on, but will adopt docker if I am convinced!

If you are running OH on a dedicated machine or VM than choose openHABian. If you are running OH on a machine that is also running lots of other services that are not related to openHAB choose Docker. If you are using an RPi, you are probably better off dedicating that RPi to openHABian rather than messing with Docker.

Personally, I run Docker because I have lots of services that I run and I like the freedom I have to move services around as I need to very easily when I redo my VMs. I also configure everything using Ansible and pulling and running Docker images is often much easier to write a playbook to do than a direct installation.

If you are not already using Docker for other stuff or you don’t have a reason to isolate OH from other services running on the same machine, there is no reason to choose Docker over openHABian. And don’t forget, openHABian gives you a near turn-key solution that includes openHAB and a bunch of other related services like databases, Grafana charting, Mosquitto, FronTail to see the logs in the browser, etc. With a Docker install all you get is OH. If you want those other services you need to download, configure,and run the Docker images for those yourself.

2 Likes

Many thanks for that, I think I will continue with openhabian for the time being. It does seem to offer exactly what I’m after in the most simple of formats. Being new to all this it’s difficult to know the best approach. I really appreciate the support from the community. I’ve now got my Niko Home control setup working through openhab along with some ESPEasy devices and MQTT so I’m sure you’ll be hearing more from me seeking advice in the near future!

Hey, my openhab 3 is running in a docker container (managed by portainer). Now I wanted to use the ip camera binding where I need to install FFmpeg. I installed it on the rpi via “sudo apt install ffmpeg” but it seems not to work… I am not sure, but maybe the problem is that ffmpeg was installed outside the docket and not inside the oh3 docker? I am right? Sorry, I am not the specialist here…

Yes, of course. That’s the whole point of containers. Nothing on the host is available inside the container unless you explicitly make it available. You need to install ffmpeg inside the container.

Can you give me a hint how I can do it? I use this image Docker Hub. Can I somehow login with SSH/putty with a openhab user directly on the container??

The " Executing shell scripts before openHAB is started" of the docs on Docker look like they could be relevant.

You can also build your own custom image based off the openHAB one.

1 Like