Community
OpenEnergyMonitor

Community

Installing OpenHAB2 on the new EmonSD30Oct18

openhab2
Tags: #<Tag:0x00007f16c8c7e328>

(Ernest) #1

Hi folks,

I updated to the new EmonSD30Oct18, and I have emoncms working well with all my data.
But now I amb trying to install openhab2 and I can’t. I followed the installation guide but openhab2 don’t start. I want to install emonhab2 to get z-wave sensors data to emoncms. I installed razberry2 hardware to my pi… Here is the error I get:

[email protected]:~ $ sudo systemctl status openhab2.service
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Thu 2018-12-06 10:15:13 UTC; 3min 33s ago
     Docs: https://www.openhab.org/docs/
           https://community.openhab.org
 Main PID: 4946 (code=exited, status=1/FAILURE)

Dec 06 10:15:12 emonpi systemd[1]: openhab2.service: Failed with result 'exit-code'.
Dec 06 10:15:13 emonpi systemd[1]: Stopped openHAB 2 - empowering the smart home.

(Brian Orpin) #2

A search on “openhab” revealed this thread Install OpenHAB2 on emonSD / emonPi Does it help?


(Glyn Hudson) #3

The only thing I can think of is that OH2 requires /var/log/openhab2/ folder created. Since the emonSD has the log dir mounted as tempfs the log folders need to be created manually at startup. I’ve just modified rc.local to add openhab2 to the list of log files it creates on startup:

Try pulling in my changes by running $ git pull on your ~/emonpi folder. Then rebooting

You may also need to add OH2 to the list of services rc.local restarts at startup after the folder has been created.

This existing thread is regarding installing OH2 on our older Jessie SD card image with a read-only data partition.


(Ernest) #4

Thanks Glyn,

I followed yout instructions without luck.
-Created openhab2 directory
-Modified rc.local with you new code.
-git pull on emonpi directory, with this error:

[email protected]:~/emonpi $ git pull
Updating eca5446..ac0846f
error: Your local changes to the following files would be overwritten by merge:
        stretch/rc.local
Please commit your changes or stash them before you merge.
Aborting

-Reboot pi

After this I installed openhab2 without errors, but it don’t load.
If I test openhab2 service:

[email protected]:~ $ sudo systemctl status openhab2.service
openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; disabled; vendor preset: enabled)
Active: inactive (dead)

If I force the service to start…

[email protected]:~ $ sudo systemctl start openhab2.service
[email protected]:~ $ sudo systemctl status openhab2.service
openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; disabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2018-12-07 16:01:13 UTC; 2s ago
  Process: 1360 ExecStop=/usr/share/openhab2/runtime/bin/karaf stop (code=exited, status=1/FAILURE)
  Process: 1340 ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE (code=exited, status=1/FAILURE)
 Main PID: 1340 (code=exited, status=1/FAILURE)

Dec 07 16:01:13 emonpi systemd[1]: openhab2.service: Failed with result 'exit-code'.

Maybe can I use openhabian SD and install emoncms on it??
Thanks for your help.


(Brian Orpin) #5

Have you installed Java?

A search on the phrase openhab2.service: Failed with result 'exit-code' throws up a few alternatives for fixing.


(Ernest) #6

:hushed: Thanks Brian!!

It was the Java! I followed openhab install instructions and I readed that Java was included with raspbian, but perhaps it’s not included with raspbian lite of the emonsd.

I got it running, thanks!

This is the code for install it:
sudo apt-get install oracle-java8-jdk

Edited:
To get Openhab2 running at startup, I used this code:

sudo systemctl start openhab2.service
sudo systemctl status openhab2.service
sudo systemctl daemon-reload
sudo systemctl enable openhab2.service

(Brian Orpin) #7

For reference,

statemctl start starts a service once
systemctl status simply outputs the status of a service
systemctl daemon-reload reloads any services that may have been changed since they were enabled.
systemctl enable enables a service to be started at boot.

To set a new service to start at boot you simply require

sudo systemctl enable openhab2.service

If it had not been previously started, you would at this point need to reboot or start the service.

The remaining commands are superfluous to this task.

HTH