Install OpenHAB2 on emonSD / emonPi

sudo systemctl disable openhab.service

echo 'deb http://dl.bintray.com/openhab/apt-repo2 stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list
sudo apt-get update
sudo apt-get install openhab2
sudo apt-get install openhab2-addons

 

sudo nano /usr/lib/systemd/system/openhab2.service

    [Unit]
    Description=openHAB 2 - empowering the smart home
    Documentation=http://docs.openhab.org
    Documentation=https://community.openhab.org
    Wants=network-online.target
    After=network-online.target

    [Service]
    EnvironmentFile=/etc/default/openhab2
    User=openhab
    Group=openhab
    WorkingDirectory=/usr/share/openhab2
    PermissionsStartOnly=true
    ExecStartPre=/bin/mkdir -p /var/log/openhab2
    ExecStartPre=/bin/chown -R openhab:openhab /var/log/openhab2/
    ExecStartPre=/bin/sh -c '/usr/bin/test -d /var/lib/openhab2/cache || /bin/mkdir /var/lib/openhab2/cache'
    ExecStartPre=/bin/sh -c '/bin/mountpoint -q /var/lib/openhab2/cache || /bin/mount -t tmpfs tmpfs /var/lib/openhab2/cache'
    ExecStartPre=/bin/sh -c '/usr/bin/test -d /var/lib/openhab2/tmp || /bin/mkdir /var/lib/openhab2/tmp'
    ExecStartPre=/bin/sh -c '/bin/mountpoint -q /var/lib/openhab2/tmp || /bin/mount -t tmpfs tmpfs /var/lib/openhab2/tmp'
    ExecStart=/usr/share/openhab2/start.sh server
    ExecStop=/usr/share/openhab2/runtime/bin/stop
    # Shutdown delay in seconds, before process is tried to be killed with KILL (if configured)
    TimeoutStopSec=120
    Restart=on-failure

    [Install]
    WantedBy=multi-user.target

 

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

sudo systemctl stop openhab2.service

 

sudo nano ./var/lib/openhab2/etc/org.ops4j.pax.logging.cfg

    # File appender - openhab.log
    log4j.appender.out=org.apache.log4j.RollingFileAppender
    log4j.appender.out.layout=org.apache.log4j.PatternLayout
    log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
    log4j.appender.out.file=${openhab.logdir}/openhab.log
    log4j.appender.out.append=true
    log4j.appender.out.maxFileSize=5MB
    log4j.appender.out.maxBackupIndex=1

    # File appender - events.log
    log4j.appender.event=org.apache.log4j.RollingFileAppender
    log4j.appender.event.layout=org.apache.log4j.PatternLayout
    log4j.appender.event.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-26.26c{1}] - %m%n
    log4j.appender.event.file=${openhab.logdir}/events.log
    log4j.appender.event.append=true
    log4j.appender.event.maxFileSize=5MB
    log4j.appender.event.maxBackupIndex=1

sudo reboot

sudo systemctl enable openhab2.service
sudo systemctl start openhab2
    pi@emonpi(ro):~$ sudo systemctl status openhab2
    ? openhab2.service - openHAB 2 - empowering the smart home
       Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled)
       Active: active (running) since Sat 2017-03-11 19:29:17 UTC; 10min ago
         Docs: http://docs.openhab.org
               https://community.openhab.org
      Process: 930 ExecStartPre=/bin/sh -c /bin/mountpoint -q /var/lib/openhab2/tmp || /bin/mount -t tmpfs tmpfs /var/lib/openhab2/tmp (code=exited, status=0/SUCCESS)
      Process: 908 ExecStartPre=/bin/sh -c /usr/bin/test -d /var/lib/openhab2/tmp || /bin/mkdir /var/lib/openhab2/tmp (code=exited, status=0/SUCCESS)
      Process: 892 ExecStartPre=/bin/sh -c /bin/mountpoint -q /var/lib/openhab2/cache || /bin/mount -t tmpfs tmpfs /var/lib/openhab2/cache (code=exited, status=0/SUCCESS)
      Process: 877 ExecStartPre=/bin/sh -c /usr/bin/test -d /var/lib/openhab2/cache || /bin/mkdir /var/lib/openhab2/cache (code=exited, status=0/SUCCESS)
      Process: 862 ExecStartPre=/bin/chown -R openhab:openhab /var/log/openhab2/ (code=exited, status=0/SUCCESS)
      Process: 844 ExecStartPre=/bin/mkdir -p /var/log/openhab2 (code=exited, status=0/SUCCESS)
     Main PID: 938 (karaf)
       CGroup: /system.slice/openhab2.service
               +- 938 /bin/bash /usr/share/openhab2/runtime/bin/karaf server
               +-1622 /usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.logdir=/var...

    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:318)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.container.Module.doStart(Module.java:571)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.container.Module.start(Module.java:439)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    Mar 11 19:29:40 emonpi start.sh[938]: at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

It is working right now. But looks like I need to put the FS in RW mode when installing bindings or UI/Actions etc. Otherwise they end op in an infinite loop.

And all of a sudden it stopped working. Didn’t change a thing, just left it for a week.

pi@emonpi(ro):~$ sudo service openhab2 status
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled)
   Active: deactivating (stop) (Result: exit-code) since Sun 2017-03-19 14:07:56 UTC; 1s ago
     Docs: http://docs.openhab.org
           https://community.openhab.org
  Process: 10664 ExecStart=/usr/share/openhab2/start.sh server (code=exited, status=255)
  Process: 10658 ExecStartPre=/usr/share/openhab2/start_pre.sh (code=exited, status=0/SUCCESS)
 Main PID: 10664 (code=exited, status=255);         : 10826 (karaf)
   CGroup: /system.slice/openhab2.service
           └─control
             ├─10826 /bin/bash /usr/share/openhab2/runtime/bin/karaf stop
             └─10982 /usr/lib/jvm/java-8-oracle/jre/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime ...

Mar 19 14:07:54 emonpi systemd[1]: Started openHAB 2 - empowering the smart home.
Mar 19 14:07:54 emonpi start.sh[10664]: Launching the openHAB runtime...
Mar 19 14:07:56 emonpi start.sh[10664]: Unable to update instance pid: /usr/share/openhab2/runtime/instances/instance.properties (Read-only file system)
Mar 19 14:07:56 emonpi start.sh[10664]: /var/log/openhab2/openhab.log (No such file or directory)
Mar 19 14:07:56 emonpi start.sh[10664]: Unable to update instance pid: /usr/share/openhab2/runtime/instances/instance.properties (Read-only file system)
Mar 19 14:07:56 emonpi systemd[1]: openhab2.service: main process exited, code=exited, status=255/n/a
Mar 19 14:07:56 emonpi stop[10826]: stop: Ignoring predefined value for KARAF_HOME





pi@emonpi(ro):~$ sudo service openhab2 stop
pi@emonpi(ro):~$ rpi-rw
Filesystem is unlocked - Write access
type ' rpi-ro ' to lock
pi@emonpi(rw):~$ sudo service openhab2 start
pi@emonpi(rw):~$ sudo service openhab2 status
● openhab2.service - openHAB 2 - empowering the smart home
   Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled)
   Active: deactivating (stop) (Result: exit-code) since Sun 2017-03-19 14:08:53 UTC; 1s ago
     Docs: http://docs.openhab.org
           https://community.openhab.org
  Process: 14848 ExecStart=/usr/share/openhab2/start.sh server (code=exited, status=255)
  Process: 14842 ExecStartPre=/usr/share/openhab2/start_pre.sh (code=exited, status=0/SUCCESS)
 Main PID: 14848 (code=exited, status=255);         : 15010 (karaf)
   CGroup: /system.slice/openhab2.service
           └─control
             ├─15010 /bin/bash /usr/share/openhab2/runtime/bin/karaf stop
             ├─15152 /bin/bash /usr/share/openhab2/runtime/bin/karaf stop
             ├─15153 /usr/lib/jvm/java-8-oracle/jre/bin/java -version
             ├─15154 grep -E "([0-9].[0-9]\..*[0-9]).*"
             ├─15155 awk {print substr($3,2,length($3)-2)}
             ├─15156 awk {print substr($1, 3, 3)}
             └─15157 sed -e s;\.;;g

Mar 19 14:08:51 emonpi systemd[1]: Started openHAB 2 - empowering the smart home.
Mar 19 14:08:51 emonpi start.sh[14848]: Launching the openHAB runtime...
Mar 19 14:08:53 emonpi start.sh[14848]: /var/log/openhab2/openhab.log (No such file or directory)
Mar 19 14:08:53 emonpi systemd[1]: openhab2.service: main process exited, code=exited, status=255/n/a
Mar 19 14:08:54 emonpi stop[15010]: stop: Ignoring predefined value for KARAF_HOME

@glyn.hudson Have you had succes with Matthew’s steps?

Learnt last night that the repository on GitHub is work-in-progress, rather a working solution. Silly me!

I’ve just deployed a solution loosely based upon the steps on the GitHub page into an emonpi image with most of emoncms moved away. I’ve added symbolic links to /etc/openhab2 and /var/lib/openhab2 to move those files into the data partition so all the config files sit in the same place and I don’t need to repeatedly change into RW mode whenever I edit. I haven’t put /var/lib /openhab2 into tmpfs.
I tried the manual install into a folder in the data partition which didn’t work, before I installed with apt-get and then added the links.
Everything is good and a little bit faster than OH 1.8 so far. The rules needed minor tweaks, and the GPIO binding didn’t work reliably, so I switched to calling wiringPi from a rule. The GPIO problem may be down to the read only file system as it kept complaining about a “lock,” but as I only operate relays with GPIO its easy to do that another way.
I’ll update this thread as I go, and once I’ve had chance to prove its reliability.
@fluppie007 have you tried scheduling a regular reboot to get around the problems? My OpenHAB 1.8 needed to be booted twice a week to prevent errors in the user interface, usually at a bad time, so as I’ve got a LOT of items I just scheduled a regular reboot. My other V1.8 Pi which doesn’t get much user interface use didn’t seem to have the problem.
Interestingly the file OH2 was complaining about in the post above references /var/lib/openhab2, and I think that’s rerouted to tmpfs? could that folder be full and its trying to move it elsewhare but can’t due to the read only file system?
Interestingly enough mine has the access date of right now on that file, even though the FS is mounted RO, so perhaps I will get the problem after a few days despite the reboots.
My /usr/share/openhab2/runtime/instances/instance.properties contains

count = 1
item.0.name = main
item.0.loc = /var/lib/openhab2
item.0.pid = 0
item.0.root = true

and I reboot with this rule

rule "Reboot downstairs Pi"
when Time cron "0 50 3 ? * WED,SAT" then	{	executeCommandLine('"sudo" "reboot"', 5000)	}
end

I can’t get openHab2 running. I’ve removed openHab and followed fluppie007 and Glyn’s advice above to install openHab2, but it is still not working. I’m not clear on what ‘install via deb:’ means, or how to load that code starting with ‘mount’.
Thanks in advance.

@mattwire
I am a user of openHAB2 for a year now, and i am interested in including energy monitoring, both usage and solar pannel output (SolarEdge). So i am following this thread for some time and waiting for a solution befor aquireing an emonPI. (I definately do not want to go back to OH1 anymore and do not have the time to troubleshoot this problem myself.)

Can you please tell me what the status is of an emonSD image with openhab2 included?
Kind regards, Bert

@deltabert I don’t know what the official stance is and Openhab2 has been somewhat of a moving target. I am running openhab2 (snapshot 2.2.0) daily on a Pi controlling my home, it’s installed roughly according to the instructions I posted but they have changed a little bit and I haven’t got around to documenting what has changed.

Thanks for your reply @mattwire.
I’m hung up on implementing the code you posted on Dec. 16
As follows: (the mount commands are hanging me up)

mount -t tmpfs tmpfs /var/lib/openhab2/cache
mount -t tmpfs tmpfs /var/lib/openhab2/tmp
mount -t tmpfs tmpfs /var/lib/openhab2/log
rm /var/lib/openhab2/port && ln -s /var/lib/openhab2/tmp/port /var/lib/openhab2/port
rm -rf /var/lib/openhab2/lock && ln -s /var/lib/openhab2/tmp/lock /var/lib/openhab2/lock
rm -rf /var/lib/openhab2/persistence && ln -s /mnt/rwdata/openhab2/persistence /var/lib/openhab2/persistence
mv /var/lib/openhab2/etc /etc/openhab2/etc
ln -s /etc/openhab2/etc /var/lib/openhab2/etc
mv /var/lib/openhab2/jsondb /etc/openhab2/jsondb
ln -s /etc/openhab2/jsondb /var/lib/openhab2/jsondb

Thank you for the work you’ve done so far. My partner and I ran openhab2 for a couple of days and got to see PaperUI. It takes about 5 minutes to start from the point of running the oh2 service to seeing something on IP:8080 and from there we ran into trouble with installing the rf 433 binding.

Openhab2 is now at that point where staying on oh1 will stagnate and be too hard for most of us to incorporate new devices and systems as all the devices work for us has been on oh2 and dropped for a long time for oh1. Additionally a kit if the online documentation for cli configuration of rules etc is oh2 specific.

In spite of this we’ve rolled back to oh1 on the basis that we haven’t managed to get this working properly by ourselves on the emonpi.

Can I buy anyone a coffee (or beer) to help us get this working for the masses? :slight_smile:

Can you expand on what you are trying to do?

Is this “rf 433 binding” intended to connect directly with an rf(m) module/device?

The RFM module in the emonpi is installed on the emonpi add-on board, the emonpi add-on board has it’s own “Arduino like” MCU and it processes the data received by the RFM before passing it to emonHub via the RPi’s GPIO serial port. Since the serial port can only be used by any one software, only emonHub handles control and communication with the RFM module. It then publishes that data on MQTT and also send it to remote emoncms via http(s).

To get “rf 433” data into openHab(2) on an emonPi (emonSD image) would be through subscribing to the MQTT published by emonHub unless you install another 433 device for exclusive use by openHab(2) or significantly change the way both the emonSD and emonpi add-on board are intended to work.

An update. I’m currently running openhab 2.2.0 snapshot #1070 (there’s issues with #1077+ currently).

Install via packages on debian (don’t install openhab2-offline as that will cause issues on subsequent restarts, you must use the online version).

systemctl disable openhab2.service

  • I have installed config in /etc/openhab2/conf and userdata in /etc/openhab2/userdata. You’ll have to move the default installed data from /etc/openhab2 (for conf) and /var/lib/openhab2 (for userdata) to the new dirs manually.
  • tmp, cache and persistence are mounted as ramdisks. I have a persistent data store (ie. disk/network mount) mounted on /mnt/store/openhab which stores persistence data at openhab startup/shutdown.
  • When restarting openhab after upgrading/changes clean out tmp/cache directories. It will take 5 mins or so to startup the first time but then will be much quicker on subsequent restarts.

/etc/default/openhab2:

EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/zwave:/dev/zwaveplus:/dev/cul:/dev/rfxtrx:/dev/weatherstationfsk" 
OPENHAB_HOME=/usr/share/openhab2
OPENHAB_CONF=/etc/openhab2/conf
OPENHAB_RUNTIME=/usr/share/openhab2/runtime
OPENHAB_USERDATA=/etc/openhab2/userdata
OPENHAB_LOGDIR=/var/log/openhab2

Here is my /etc/systemd/system/openhab-custom.service:

[Unit]
Description=openHAB 2 - custom
Documentation=http://docs.openhab.org
Documentation=https://community.openhab.org
Wants=network-online.target
After=network-online.target

[Service]
Environment=OPENHAB_STARTMODE=daemon
EnvironmentFile=/etc/default/openhab2
User=openhab
Group=openhab

PermissionsStartOnly=true
#ExecStartPre=/usr/share/openhab/bin/setpermissions.sh
ExecStartPre=/bin/mkdir -p /var/log/openhab2
ExecStartPre=/bin/chown -R openhab:openhab /var/log/openhab2/
ExecStartPre=/bin/sh -c '/bin/mountpoint -q /etc/openhab2/userdata/cache || /bin/mount -t tmpfs tmpfs /etc/openhab2/userdata/cache'
ExecStartPre=/bin/sh -c '/bin/mountpoint -q /etc/openhab2/userdata/tmp || /bin/mount -t tmpfs tmpfs /etc/openhab2/userdata/tmp'
ExecStartPre=/bin/sh -c '/bin/mountpoint -q /etc/openhab2/userdata/persistence || /bin/mount -t tmpfs tmpfs /etc/openhab2/userdata/persistence'
ExecStartPre=/bin/sh -c '/bin/cp -a /mnt/store/openhab2/persistence/* /etc/openhab2/userdata/persistence'
ExecStartPre=/bin/sh -c 'setcap "cap_net_raw,cap_net_admin=+eip cap_net_bind_service=+ep" $(realpath /usr/bin/java)'

WorkingDirectory=/usr/share/openhab2
ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE

ExecStop=/usr/share/openhab2/runtime/bin/karaf stop
ExecStop=/bin/sh -c '/bin/cp -a /etc/openhab2/userdata/persistence/* /mnt/store/openhab2/persistence'

SuccessExitStatus=0 143
RestartSec=5
Restart=on-failure
TimeoutStopSec=120

LimitNOFILE=102642

[Install]
WantedBy=multi-user.target

Hi Paul,

Sure thing, I’d be glad to elaborate.

Our EmonPi was using the RFXCOM binding for the RFXtrx433e usb device.

We got this because in the early days we wanted flexibility and compatibility, not having much time or knowledge in the smart things area (that’s still true lol). We had OpenHab running on a VM on our ESX hype and because that was in a really bad place for having any kind of trasnsmission signal or reception we pop’d the RFXtrx433e onto a RaspberryPi we had in the house doing other things and used USBIP to hook up the RFXtrx433e to the Hype as though it was physically present.

The RFXtrx433e has great compatibility with a plethora of different brands so this is why we are still using it on the EmonPi. Didn’t manage to work out how to get it to function with MQTT though, as good as this would have been.

I think it’s possible that we may need to try some more things as Matt has just given a nice update with some changes since earlier in this thread.

We don’t have a staging environment for any of this as it’s our home… So I will just give it a test tonight on our EmonPi and hope for the best!

Matt, Paul, thanks for chiming in - I will report on how it goes :slight_smile:

@m31d4ri0n Forgot to mention that I’m using an RFXtrx433 connected (directly) via USB on openhab2 with a raspberryPi. It works well - you will need to make sure you get the serial permissions correct (see my EXTRA_JAVA_OPTS in /etc/default/openhab2) for Java otherwise it won’t work. I also recently switched to “Zulu” embedded java (Installation Overview - openHAB 2 - Empowering the Smart Home) which seems to work well.

Hey Matt,

Thanks for your updates. I didn’t have much time tonight to have a proper go at it. I installed Zulu and purge/reinstalled oh2 with your environment variables / systemctl service but hit a snag.

pi@emonpi(ro):~$ sudo systemctl status openhab2
● openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; disabled)
Active: deactivating (stop) (Result: exit-code) since Wed 2017-11-15 22:11:37 GMT; 565ms ago
 Docs: http://docs.openhab.org
       https://community.openhab.org
Process: 1852 ExecStart=/usr/share/openhab2/start.sh server (code=exited, status=1/FAILURE)
Main PID: 1852 (code=exited, status=1/FAILURE);         : 1960 (stop)
CGroup: /system.slice/openhab2.service
       └─control
         ├─1960 /bin/sh /usr/share/openhab2/runtime/bin/stop
         ├─2019 /bin/sh /usr/share/openhab2/runtime/bin/stop
         ├─2020 /usr/bin/java -version
         ├─2021 grep -E "([0-9].[0-9]\..*[0-9]).*"
         ├─2022 awk {print substr($3,2,length($3)-2)}
         ├─2023 awk {print substr($1, 3, 3)}
         └─2024 sed -e s;\.;;g

Nov 15 22:11:36 emonpi systemd[1]: Started openHAB 2 - empowering the smart home.
Nov 15 22:11:36 emonpi start.sh[1852]: Launching the openHAB runtime...
Nov 15 22:11:37 emonpi start.sh[1852]: karaf: KARAF_ETC is not valid: /var/lib/openhab2/etc
Nov 15 22:11:37 emonpi systemd[1]: openhab2.service: main process exited, code=exited, status=1/FAILURE

At first sight it looks like the start script is still looking to /var/lib/openhab and that’s where it’s failing; looked at start.sh and it didn’t give me any clues. I did consider trying to use symlinks to make things happier but thought i’d check in with you

Looks like you’re still using the systemd service openhab2.service. You need to disable that and replace it with my openhab-custom.service (done because openhab2.service is overwritten on future openhab upgrades). openhab-custom.service does not use start.sh.

Hey,

Home sick and having a play. Just wanted to chime in and say OH2 is now up and running, thank you for your help. It’s sometimes the really obvious things you (I) miss.

Hi Matt,

Brand new OpenHAB user here and first time using Linux for many, many years.

I now have the following:

/etc/openhab2/conf with all the folders from /etc/openhab2 moved there.
/etc/openhab2/userdata with all the folders from /var/lib/openhab2 moved there.

I added the code for /etc/default/openhab2 as above. I also created the openhab-custom.service as above.

This is what i get when I enter sudo systemctl start openhab-custom.service:

**Job for openhab-custom.service failed. See 'systemctl status openhab-custom.service' and 'journalctl -xn' for details.**

Any help would be greatly appreciated, sorry for the stupid questions.

This is from sudo journalctl -xn:

-- Logs begin at Fri 2018-05-04 13:54:34 UTC, end at Tue 2018-05-15 04:18:26 UTC. --
May 15 04:18:23 emonpi karaf[30366]: at java.lang.Thread.run(Thread.java:748)
May 15 04:18:25 emonpi systemd[1]: openhab-custom.service holdoff time over, scheduling restart.
May 15 04:18:25 emonpi systemd[1]: Stopping openHAB 2 - custom...
-- Subject: Unit openhab-custom.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit openhab-custom.service has begun shutting down.
May 15 04:18:25 emonpi systemd[1]: Starting openHAB 2 - custom...
-- Subject: Unit openhab-custom.service has begun with start-up
-- Defined-By: systemd
--
-- Unit openhab-custom.service has begun starting up.
May 15 04:18:25 emonpi sh[4981]: /bin/cp: cannot stat ‘/mnt/store/openhab2/persistence/*’: No such file or directory
May 15 04:18:25 emonpi systemd[1]: openhab-custom.service: control process exited, code=exited status=1
May 15 04:18:25 emonpi systemd[1]: Failed to start openHAB 2 - custom.
-- Subject: Unit openhab-custom.service has failed
-- Defined-By: systemd
--
-- Unit openhab-custom.service has failed.
--
-- The result is failed.
May 15 04:18:25 emonpi systemd[1]: Unit openhab-custom.service entered failed state.
May 15 04:18:26 emonpi sudo[4987]: pi : TTY=pts/0 ; PWD=/ ; USER=root ; COMMAND=/bin/journalctl -xn
May 15 04:18:26 emonpi sudo[4987]: pam_unix(sudo:session): session opened for user root by pi(uid=0)

Additionally, the logs for sudo systemctl status openhab-custom.service -l

● openhab-custom.service - openHAB 2 - custom
   Loaded: loaded (/etc/systemd/system/openhab-custom.service; enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2018-05-15 04                                                                                                                                                             :29:53 UTC; 955ms ago
     Docs: http://docs.openhab.org
           https://community.openhab.org
  Process: 12150 ExecStartPre=/bin/sh -c /bin/cp -a /mnt/store/openhab2/persiste                                                                                                                                                             nce/* /etc/openhab2/userdata/persistence (code=exited, status=1/FAILURE)
  Process: 12146 ExecStartPre=/bin/sh -c /bin/mountpoint -q /etc/openhab2/userda                                                                                                                                                             ta/persistence || /bin/mount -t tmpfs tmpfs /etc/openhab2/userdata/persistence (                                                                                                                                                             code=exited, status=0/SUCCESS)
  Process: 12142 ExecStartPre=/bin/sh -c /bin/mountpoint -q /etc/openhab2/userda                                                                                                                                                             ta/tmp || /bin/mount -t tmpfs tmpfs /etc/openhab2/userdata/tmp (code=exited, sta                                                                                                                                                             tus=0/SUCCESS)
  Process: 12138 ExecStartPre=/bin/sh -c /bin/mountpoint -q /etc/openhab2/userda                                                                                                                                                             ta/cache || /bin/mount -t tmpfs tmpfs /etc/openhab2/userdata/cache (code=exited,                                                                                                                                                              status=0/SUCCESS)
  Process: 12135 ExecStartPre=/bin/chown -R openhab:openhab /var/log/openhab2/ (                                                                                                                                                             code=exited, status=0/SUCCESS)
  Process: 12132 ExecStartPre=/bin/mkdir -p /var/log/openhab2 (code=exited, stat                                                                                                                                                             us=0/SUCCESS)

May 15 04:29:53 emonpi systemd[1]: Unit openhab-custom.service entered failed st                                                                                                                                                             ate.

May 15 04:18:25 emonpi sh[4981]: /bin/cp: cannot stat ‘/mnt/store/openhab2/persistence/*’: No such file or directory

I have a USB stick/SSD mounted read/write at /mnt/store with the directory openhab2/persistence created on it. So the persistence data can be saved/loaded between restarts. That is the cause of your failure.

Thanks for the reply, Matt. After posting this I saw that and mounted a USB. Even after giving them read/write access I’m still coming up with the same error. So you don’t think I’m crazy here’s the evidence:

pi@emonpi(rw):~$ ls -la /mnt/store/
total 32
drwxrwxrwx 5 root root  4096 May 16 12:09 .
drwxrwxrwx 4 root root  4096 May 15 07:51 ..
drwxrw-rw- 2 root root 16384 May 15 07:47 lost+found
drwxrwxrwx 3 root root  4096 May 15 08:49 openhab2
drwxrwxrwx 2 root root  4096 May 15 08:49 persistence

I do apologise, I’ve no doubt I’m doing something completely stupid but I cannot for the life of me see what it is.