New to docker containers and OpenHAB and java and that sort of scripting and rule creating. I am leaving my LMCE now and venture what is out there. And despite my fear of java I just couldnt stop thinking about openhab… Feels more like home…
Though I was almost put off by the fact that there was not even a “tool” for creating rules (sunset, sunrise basic stuff) until I found the experimental one
I had a few issues just getting openhab seeing my usb port hence you will see that the container I run now is using sudo and two device links.
I also do start the container as a oneliner as I want to make sure I have all the options and switches properly set before letting systemd help me.
My question is where my config that I create using the PaperUI ends up? Especially the rules that I created with the awesome Rule add_on ?
Experimental indeed but I would have assumed they end up in the
“/home/openhab/conf/rules” directory. But there is nothing there…
I am abit afraid now to do more stuff as I don’t want to loose the progress…
I am running the Ubuntu 18.04 server with “default docker”
sudo docker run --name openhab -p 5080:8080 -p 5443:8443 -p 5081:8081 --device=/dev/serial/by-id/usb-0658_0200-if00 --device=/dev/ttyACM0 -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -v /home/openhab/addons:/openhab/addons -v /home/openhab/conf:/openhab/conf -v /home/openhab/userdata:/openhab/userdata -v /home/openhab/.java:/openhab/.java -d -e USER_ID=998 -e GROUP_ID=997 -e EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/serial/by-id/usb-0658_0200-if00" -e EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyACM0" --restart=always openhab/openhab:2.4.0
Indeed there they are. Though the format is “json” hmm… But I think I can use the thoughts from there and create my own rules.
As eventhough there where Many threads of rules regarding sunset,lights etc I never quite understood the different elements of the rule as such. Like the item, if it was the name, alias or id… I see now it’s the Id…
Need to read up on the design guidelines first. Maybe copy a few of your rules also that you posted
Regarding the user its strange. Are you running bionic beaver and the included Docker from standard repo? I found one thread or Blog where a guy had my exact issues and he had to change to a different docker as there apparently some bug regarding exposing serials to the container.
To me it seems(I have stopped playing, it works… dont touch haha!) that what made it work was me doing a chmod 777 of the /dev/ttyACM0.
This is really bad I know, though my openhab user belongs to the dialout group.
“openhab : openhab tty dialout audio”
and from what I have read I do specify in my docker run command that the user should be openhab, so it must be that bug.
Though changing docker is not something I will do now. But I think it’s time to make sure this thing starts when the server is rebooted and what not…
Thank you once again for the quick reply!
That change will almost certainly become unmade the next time you reboot the machine. Files in /dev/ttyAMCM0 are not “true” files in that they exist somewhere on your hard drive.
Notice above that I do not specify that the user to run under is openhab. I think the entrypoint.sh that kicks everything off needs to start as root but then it su openhab to actually start openHAB running. That same script also makes sure that the uid/gid of the user it starts openHAB running under matches those passed in as those environment variables. The important thing is that the UID and GID passed in to the container are for a user (doesn’t matter what it’s called) on your host that is allowed to read/write to the serial device files. On an Ubuntu machine that is usually done by adding the user to the dialout group. On an RPi that group may be something else like “tty”.
Wow! Thank you! so many new things, “rules DSL” and JSR223 has flown by when scanning the threads, never really thought I would have to dig into that as well haha!
Ansible task sounds neat, will google this as the “–restart=always” didn’t do much in the last reboot. Systemd works for my other container but maybe I shall try the ansible.
indeed, having to change the rights for the /dev/ after every reboot really is suboptimal.