openHAB 4 on Termux on Android

I zip installed as I always do: unzip -d openhab-4 openhab-4.0.0-SNAPSHOT.zip

Java installed with Termux’s packet manager pkg.

Termux has an sshd, set up your keys as in Linux, and you’re good to ssh and scp.

Important: install Termux from F-Droid, not from Playstore.

It would be great if you could provide a brief tutorial. I’ve got an old Galaxy S8 that I could try this out on, but I’ve never used Termux or done a zip install of OH.

This could be a nice way to reuse old Android devices.

The hardest part is to install F-Droid, as it has to be installed via the .apk (Side-loaded)
From the browser on your Android device get the F-Droid.apk from [F-Droid - Free and Open Source Android App Repository] (the blue download button).

google how to side-load for your device.
for my Lenovo it is : find the .apk from Androids File Manager with settings - Memory - Files - Open with Files
You might have to allow install .apks.

See also the The Termux Wiki.

When the F-Droid is running search for Termux and install it. Then run the termux app.

Select AQUIRE WAKELOCK from the Termux notification panel from the top of your screen.

You are in bash now, the rest works as in Linux, but no need for root.

pkg upgrade
pkg install openssh curl unzip openjdk-17

sshd

ifconfig

curl -O https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab/4.0.0.M2/openhab-4.0.0.M2.zip

unzip -d openhab-4 openhab-4.0.0.M2.zip

cd openhab-4 && ./start.sh

After the ifconfig you have the IP of your device and you can ssh in from a computer with a keyboard:
ssh -p 8022 IP

you might also install the Termux:API app and get goodies like

termux-tts-speak "hello openHAB"

and this can be ssh’ed from an openHAB rule …
executeCommandLine(“/usr/bin/ssh”, “nexus9”, “termux-tts-speak hello”)

1 Like

Does this mean that this setup wouldn’t survive restarts? If the device restarts, you must start the termux app again, and restart openHAB again?

(Forgive me - I’ve got no experience in this field!)

Termux supports boot time scripts: Termux:Boot which can be used to start the crond, sshd …

There are people who code in Termux:

https://www.youtube.com/results?search_query=code+in+termux

2 Likes

Thanks for the details. I might spin it up on my old S8 and then use the Remote openHAB binding to control my existing server.

Looks like it would be tricky to get a Z-Wave USB controller working, but I suppose that could be offloaded to an RPi3 running openHAB (just for Z-Wave devices) or ZWaveJS.

my problems

ssh login problems
login - connection refused

http://localhost:8080 or 127.0.0.1:8080
ok administration panel

does java -version work and give 17 ?

You should try openhab 4.0.2

for ssh see Remote Access - Termux Wiki
Mind that the ssh port is 8022

Stable version?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
wget https://github.com/openhab/openhab-distro/releases/download/4.0.3/openhab-4.0.3.zip -not work (permission deined problem)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Yes install openjdk-17 termux (version 17.0.???)

termux not openjdk 17.0.5 to openhab required

Thank you for sharing your great experience,
so we can install Openhab server and dashboard on the same android device, right?

Yes, it’s possible. I have just done it.

Does homekit add on work with termux , and i am also having problem running mosquitto broker for termux , if anyone can help thanks in advance

And how to find the uuid for openhab cloud
Thanks for any help

On the web there are several tutorials for mosquitto under Termux.

Note that mosquitto by default only listens on localhost.

Remember to set the wake lock else Android will kill a server after some time.

2 Likes

Done the wakelock thing and openhab is working fine . But i want to use openhab cloud and i can’t find the uuid and secret!!

cloud addon is installed?

1 Like

Yes found uuid and secret

For uuid

nano userdata/uuid

For secret

nano userdata/openhabcloud/secret

Using a galaxy s8 korean version without a display to run the openhab server . Google home Amazon Alexa are working great but can’t get the apple home app working . Have anyone tried with apple home?

To prevent the battery from swelling hang it on a wifi socket. Cycle the battery between 20 and 80. Get the state with termux-battery-status.

See this post.

1 Like

Thanks for your suggestion, have already done that , but i am have problem with apple home app , the homekit bridge do connect with my home app ,i also added metadata to my items but my items isn’t showing in home app , do you have any clue?

Just updates to the openhab4.0.4 and the homekit problem was gone!!