Raspberry Pi Zero W - Ha-bridge, run into issue...

Hello, I currently have Ha-bridge installed and setup on my Mac - and love the functionality. I just picked up a Raspberry Pi Zero W and I’m attempting to install Ha-bridge on it based on the instructions here: GitHub - bwssytems/ha-bridge: Home automation bridge that emulates a Philips Hue light system and can control other systems such as a Vera, Harmony Hub, Nest, MiLight bulbs or any other system that has an http/https/tcp/udp interface. This is a compact impl to run on small format computers. This is impl started from this project https://github.com/armzilla/amazon-echo-ha-bridge. but I’ve run into a few issues. I’m guessing that my issues stem from not having Java JDK 1.8? Doing command “java -version” returns java version “1.7.0_121”. Does this need to be updated and if so, how do I do this? Thanks!

You didn’t say what your issues are, so it’s hard to know if a newer Java version will help or not. There are some simple instructions to update in this post: Which JDK 8 binary should I install on Raspbian? - Raspberry Pi Forums

sudo apt-get update && sudo apt-get install oracle-java8-jdk
java -version

Do a Google search for more information on updating Java on the Raspberry Pi.

Also, you can ask questions directly on the github site that you mention below. Just start a new ‘issue’.

Thanks for the help. This is on a Raspberry Pi Zero W. That command states I’m already on the newest version, but is java version 1.7.0_121 and not 1.8. The issue I’m having is when I try to start the service using “sudo systemctl start habridge.service” I get the following error “Failed to start habridge.service: Unit habridge.service failed to load: Invalid argument. See system logs and ‘systemctl status habridge.service’ for details.” Thanks for any help!

Try starting it up, then look at /var/log/syslog to see what is there. Try “tail -n 50 /var/log/syslog” just after you start it. Also, try the command that it mentions and see what it says: “systemctl status habridge.service”. But I think the syslog will have the debug information you need.

This is what I get using “tail -f /var/log/syslog”
“Mar 13 19:19:30 raspberrypi org.gtk.Private.UDisks2VolumeMonitor[679]: index_parse.c:191: indx_parse(): error opening /media/pi/SETTINGS1/BDMV/index.bdmv
Mar 13 19:19:30 raspberrypi org.gtk.Private.UDisks2VolumeMonitor[679]: index_parse.c:191: indx_parse(): error opening /media/pi/SETTINGS1/BDMV/BACKUP/index.bdmv
Mar 13 19:19:43 raspberrypi systemd[1]: Starting Session c3 of user pi.
Mar 13 19:19:43 raspberrypi systemd[1]: Started Session c3 of user pi.
Mar 13 19:28:36 raspberrypi systemd[1]: Reloading.
Mar 13 19:28:36 raspberrypi systemd[1]: [/etc/systemd/system/habridge.service:10] Unknown lvalue ‘ExecStart’ in section ‘Install’
Mar 13 19:28:36 raspberrypi systemd[1]: habridge.service lacks ExecStart setting. Refusing.
Mar 13 19:29:10 raspberrypi systemd[1]: Reloading.
Mar 13 19:29:11 raspberrypi systemd[1]: [/etc/systemd/system/habridge.service:10] Unknown lvalue ‘ExecStart’ in section ‘Install’
Mar 13 19:29:11 raspberrypi systemd[1]: habridge.service lacks ExecStart setting. Refusing.”

I did get it running by using “sudo java -jar ha-bridge-4.1.4.jar” at one point but when I tried to make changes (e.g. add my Vera IP address) and it needed to save and restart, I was never able to get back in. Tried a bunch of things and was able to get it working and configured. Not sure I have it in me tonight to test if it will restart on its own if I restart the Raspberry Pi Zero W. I’ll save that for another day…

[quote=“avale, post:5, topic:195818”]Mar 13 19:28:36 raspberrypi systemd[1]: [/etc/systemd/system/habridge.service:10] Unknown lvalue ‘ExecStart’ in section ‘Install’
Mar 13 19:28:36 raspberrypi systemd[1]: habridge.service lacks ExecStart setting. Refusing.
Mar 13 19:29:10 raspberrypi systemd[1]: Reloading.
Mar 13 19:29:11 raspberrypi systemd[1]: [/etc/systemd/system/habridge.service:10] Unknown lvalue ‘ExecStart’ in section ‘Install’[/quote]
So that looks like you have an issue in your service file for habridge. You have exactly this? Do you have an extra “ExecStart” in the “[Install]” section?

[code][Unit]
Description=HA Bridge
Wants=network.target
After=network.target

[Service]
Type=simple

ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.2.1.jar

[Install]
WantedBy=multi-user.target[/code]

Also, you mention /home/pi, but the log shows “/media/pi”?

Yes, I can get it up and running with the java command but as soon as I close the terminal window, it stops running. I’ll take a look in the service file. I’ve tried a bunch of things and a bunch of times so there could be something extra floating around. I’ll confirm I only have a single “ExecStart” tonight.

Regarding the /media/pi, I wonder if that has something to do with the MicroSD card? I’ll see if that directory even exists. I do know that if I CD to /home/pi it resolves to /raspberrypi/ - but will have to look into the /media/… Thanks for all the help. Almost there!

If you want to run from a command line and not have it disappear later, do something like this:

nohup sudo java -jar ha-bridge-4.1.4.jar > /tmp/nohup.out 2>&1 <&- &

You may have to adjust this slightly, but it should be close. The “nohup” prevents the hang up signal from being sent when you close the terminal. Stdout is sent to the temp file and stderr goes there too, and the stdin is closed. That should keep it alive. At least as far as I remember…

But it is better to get the systemctl to work. That works across reboots and power cycles - the above nohup doesn’t help you there.

OK so my Raspberry Pi has /media/pi and in there are 2 files named SETTINGS and SETTINGS1. My Raspberry Pi also has /home/pi and that is the default directory and where my habridge folder is. Under /home/pi/habridge I have a starthabridge.sh that has the following…

cd /home/pi/habridge rm /home/pi/habridge/habridge-log.txt nohup java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.1.4.jar > /home/pi/habridge/habridge-log.txt 2>&1 &

chmod 777 /home/pi/habridge/habridge-log.txt


I notice that there is no “sudo” in the line with java.

Under /etc/systemd/system there is a habridge.service with the following…

[Unit] Description=HA Bridge Wants=network.target After=network.target

[Service]
Type=simple

[Install]
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-4.2.1.jar

[Install]
WantedBy=multi-user.target

My guess is that I tried two different approaches and only need the starthabridge.sh file OR the habridge.service file. Assuming this is correct, which do you suggest keeping? Also, while I do have a /media/pi folder, I have no idea how/why this is showing up in the logs.

I see I have an extra [Install] in my habridge.service file. I also found the article that suggested starting ha-bridge from the starthabridge.sh file because starting ha-bridge from rc.local on next gen systems will cause unexpected results and issues with discovering registered devices. I think I’ll fix the habridge.service file and delete the starthabridge.sh file for now.

Yes, no need for both rc.local and the .service file. You only want one and the .service is better.

FYI - there was no need for a ‘sudo’ in the starthabridge.sh script since that script runs as root at startup. If you run it manually as the user ‘pi’, you do need the sudo.

I can’t answer the /media/pi versus /home/pi. Not sure what that is about. You might check the Raspberry Pi forums. Just be sure to check the logs to make sure the bridge is finding what it needs.

Happy Pi Day!

Thank you very much! I ended up deleting everything and doing a clean setup. I have got it working nicely with my Google Home and confirmed that it still runs when I close my terminal. I’ll test restarting the Raspberry Pi another night as I want to end on a high note. Next I’m going to attempt to add Home Bridge with the Vera plugin to the Raspberry Pi too - so I can control my devices from Siri too.

To give back to this forum, here is how you get Java JDK 1.8 on the Raspberry Pi…

sudo apt-get update && sudo apt-get install oracle-java8-jdk
Then run:
sudo update-alternatives --config java
And select the JDK 8 version (/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java) - it was option 3 as of this writing
Then run:
java -version

jswim788, thanks for all your help! I have confirmed that Ha-bridge starts up automatically upon reboot. This would have been a lot more painful without your guidance - thanks! On a separate note, I have also added VeraHomeKitBridge to the Raspberry Pi Zero W and have it working when I manually start it. I just need to get that to automatically start up and I should be good for a while…