[OpenHab] Basic Guide | Installing OpenHabian on ProxMox Virtual Machine

I wanted to do the install the OpenHABian on Virtual Machine running on the ProxMox; however, I could not find a step by step instruction for this. After more than a few trials and errors, I got it to work. So this is a step by step guide of how I achieved this.

History:

What you will learn in this article:

  • How to setup OpenHABian Virtual Machine on ProxMox

Who is and isn’t this guide for?

For

This guide is for those who wants to install OpenHABian on Virtual Machine setting like on ProxMox.

Not for

  • those who are familiar with docker setup e.g. know how to setup primary network IP, Samba setting etc. You can simply install official docker version of openHAB from official openHAB site or docker site.
  • those who already have Debian based system where you are ok installing the openHAB on it. You can follow official instruction.
  • those wanting to install OpenHABian on Rasberry Pi. You can follow official instruction.
  • those wanting to install OpenHABian in Container (LXC) setting. Please refer to the separate article.

Why OpenHABian?

From a novice user stand point of view, I see OpenHABian as a special type of OpenHAB.

The Raspberry Pi is quite a famous platform for openHAB. However, setting up a fully working Linux system with all recommended packages and openHAB recommendations is a boring task, takes a lot of time and Linux newcomers are challenged in a number of ways although all they want is to run openHAB and not some server.

A home automation enthusiast doesn’t have to be a Linux enthusiast!

openHABian is a self-configuring Linux system setup to meet the needs of every openHAB user. It provides:

– Complete SD-card images pre-configured with openHAB for the Raspberry Pi line of SBCs
– The openHABian configuration tool to set up and configure openHAB and many related things on any Debian based system

https://www.openhab.org/docs/installation/openhabian.html

The key here for new openHAB users like myself is that openHABian is a openHAB platform that have self-configuring capability, built in configuration tools and many related things e.g. Samba Share. This to me is analogous to Home Assistant OS as compared to Home Assistant Core/Docker.

Why Virtual Machine?

Primary reason is docker did not allow me to install OpenHABian. I am worried Rasberry Pi installation may quickly hit performance limitation due to the hardware, especially my Rasberry Pi is version 3B.

OpenHABian on ProxMox Virtual Machine Setup Guide

Pre-requisite

  • Running ProxMox server. Most likely other virtual machine setup should work in a similar fashion.

Overall Steps

The general step turned out to be simple.

The openHABian configuration tool to set up and configure openHAB and many related things on any Debian based system

As official site states, what we need is a Debian based system. So what we should be doing is create a Debian based virtual machine on ProxMox. Then install OpenHABian. Since this virtual machine will be used purely for OpenHABian, my preference is not install anything unnecessary component of Debian such as Debian GUI.

  1. Download Debian Linux Image
  2. Upload Debian Linux image to ProxMox server
  3. Create new Debian virtual Machine on ProxMox
  4. Setup command line input only Debian
  5. Install OpenHabian

Download Debian Linux Image

https://www.debian.org

Simply go to the official website and download the ISO file.

Upload Debian image to ProxMox Server

Go to your ProxMox server i.e. https://[ip-address]:8006

Datacenter > [Node] > [Storage] > ISO Image
Upload Debian ISO Image

What you have done here is you have placed Debian OS installation file on the ProxMox server itself. So when creating a new Virtual Machine, ProxMox will see the installer just as if you had bootable disc, SD card or USB.

Create New Debian Virtual Machine

Create VM

On this screen, I named my Virtual Machine as OpenHAB because that’s the only thing this will be doing. Make sure you have the Advanced setting checked.

On the OS setting, you want to use the Debian image file you uploaded. So choose Use CD//DVD disc image file (iso) and ISO image dropdown. For the rest I kept the default on this screen.

System setting was also kept default.

Hard Disk is also kept default but you can easily increase the disc size here (or later).

CPU setting is up to your choice and depends on your system. My system is NUC10i7. Considering OpenHabian is written for Rasberry Pi, I did not see much need of CPU here, so I chose 2 cores.

Memory is also your choice. I set mine to 4 GB as hardware recommendation by official openHABian is 2 or 4 GB on Rasberry Pi 4.

Network setting is kept default here.

Finally confirm the setting and Finish.

Setup Command Line Interface Only Debian

At this point, you have just created a virtual machine hardware that has Debian install disc inserted to it, but actually installation has not yet started/configured. So that is the next step.

Start newly created VM

Console

This will take you step by step installation.

Here I have to admit that today was my first day installing Debian OS so I may not be making the most wise decisions but nonetheless, followings are what I have done.

Choose Graphical Install

After selecting region, language, host name and root account password, you will see the following screen.

openHABian instructions are written with default user name openhabian. So I might as well make it here. For the password, be sure to choose secure password.

One point it will ask you to partition disks. I chose guided -use entire disc.

I am indeed new user so I chose all files in one partition.

This screen you must change to Yes to proceed to the next step. Now installation of base files starts.

Here we have nothing else to add, so keep the option “no” and continue. Next couple images will setup where you will be getting add-on packages on your system.

As suggested by the installer instruction, I kept the default deb.debian.org.

You will encounter the screen above. This is the key screen, in my opinion. By default it had Debian desktop environment, print sever and standard system utilities checked but since we are using this virtual machine only as openHABian system you won’t need anything extra, definitely you won’t need Debian desktop environment. One thing you want to check here is; however, SSH server. This will allow you to connect command line input of the virtual machine outside of ProxMox screen, which would be handy since ProxMox terminal window won’t allow copy&paste. So I recommend installing this.

The reason is we just want to have bare minimum Debian install so we can follow manual OpenHABian install instruction in the following step. Otherwise, I am afraid unnecessary system resource will be wasted.

Honestly, I have no clue what above step does, but I know I will just have the Debian OS and openHABian on it, but nothing else in this VM so I kept default “yes”.

Now the installation is completed and system will reboot.

Debian Add-ons

Optional add-ons

Besides SSH server, there are some add-on components that can be helpful if installed when following official openHABian instruction. These are entirely optional.

Sudo

The real openHABian does not use “root” access but rather use Sudo command. Sudo is a command that gives privilege to non-admin user to execute commands at administrator level when this command is added. This ensures only necessary codes will use administrator privilege; hence, more security. Default Debian does not come with this command line tool, so you need to install this.

General steps are followings:

  1. Log in as root account
  2. Run sudo tool install command
  3. Add user to the sudo group e.g. “openhabian”

Log in as root account

su

Above command will switch account to “root”. So you need to enter root password.

Install Sudo command tool

apt-get install sudo

Add user to the sudo group

File entry approach (Recommended)
nano /etc/sudoers

nano is a simple text editor tool. This should open a text file containing multiple lines as below.

*You must be logged in as “root” to be able to access this file.

Now you want to add following line under #User privilege specification section

username  ALL=(ALL) NOPASSWD:ALL

username is the name of user you have chosen i.e. in my case openhabian.

If you rather to enter password for each “sudo” command execution, you can delete “NOPASSWD:” part.

Ctrl-X to exit and confirm saving the file.

Command line approach

You can try adding user by command-line approach, but this did not work for me.

/sbin/adduser username sudo

In above case, user name is openhabian for my case.

Check

You can now exit root access, which should take you back to original account i.e. openhabian in my case. This is done by simply entering ‘exit’.

Then you can type following command to confirm the account indeed received sudo privilege.

sudo echo 'Hello, world!'

References:

Install OpenHABian

With command line only install of Debian, you will see screen above. (Debian is the name I kept for the system for this example). If you named it OpenHAB, it will say such.

Login here is the user name and password you created during the Debian installation setup. Since we want to install openHABian with master privilege i.e. root privilege, log in with root account here.

Now all we need to do is follow the official openHAB site’s Other Linux Systems openHABian installation instruction.

You need to enter following lines. I did one at a time.

# install git - you can skip this if it's already installed
apt-get update
apt-get install git

# download, link and create config file
git clone -b openHAB3 https://github.com/openhab/openhabian.git /opt/openhabian
ln -s /opt/openhabian/openhabian-setup.sh /usr/local/bin/openhabian-config
cp /opt/openhabian/openhabian.conf.dist /etc/openhabian.conf

For whatever reason VNC console screen of ProxMox did not allow me to copy and paste, so I had to manually type all of the above. Just make sure you don’t make typo. The last step is run the code below.

openhabian-config unattended

This code initiates automated openHABian installation just like if you were to insert bootable SD card into Rasberry Pi for the first time. You can actually watch command progress here, which was very exciting to me (seriously).

Upon completion, you have full openHABian running. Just access it by entering [ipaddress]:8080 on your browser and start manual configuration.

Additional Setups

I have both container and virtual machine versions setup with OpenHabian. I encountered, different minor issues for each version of the installation i.e. OpenHabian installation did not configure fully to its capacity on each platform in a different way. In this section, I will discuss about what I had to change to get those missing functionality work. This may get updates as I encounter and find solution for more issues.

Openhabian version switch

Situation

Missing binding, feature, or other issues.

Background

Openhabian is a handy command line input tool to help various parts of OpenHAB maintenance. One of the feature is easy switch/upgrade of OpenHAB Version. One potential source of confusion is openHAB and openHabian configuration tool are the separate entities and therefore each have their own versions. Think openHAB as the actual core software; whereas, openHabian configuration tool is handy tool for maintaining openHAB.

The default setup of openHABian instals openHAB3 stable version. openHAB has 3 versions as described below.

Stable versions are thoroughly tested semi-annual official releases of openHAB. Use the stable version for your production environment if you don’t need the latest enhancements and prefer a robust system.

Milestone versions are intermediary releases of the next openHAB version, released about once a month, and they include the new recently added features and bugfixes. They are a good compromise between the current stable version and the bleeding-edge and potentially unstable snapshot version.

Snapshot versions are at most 1 or 2 days old and include the latest code. Use a snapshot for testing out very recent changes, but be aware some snapshots might be unstable. Use in production at your own risk!

https://www.openhab.org/download/

Openhabian configuration tool has four version.

From the new user perspective, we should be looking at openHAB3 and main versions. Both are openHAB 3 but one sounds like a standard version while the other is presumably mile-stone equivalent.

Therefore, if open-habian configuration tool have issues, you want to update the open-habian configuration tool rather than openHAB (core). You might want to have Milestone version of openHAB core, but you may need to first up grade openhabian configuration tool to the latest before you an upgrade the core.

For example, myQ garage door system was supported on openHAB 2 but not on the current standard openHAB version, 3.0.2 at the time of this writing. However, this binding is available on the current milestone version, 3.1.0.M4.

Assessment

You want to check the current version of openHAB installation you have. This can be seen at the time of your logging into the command line input screen.

As you can see in my case, I currently have 3.1.0.M4 – Milestone build here.

Recommendation

I personally recommend at the least install the latest (main) openhabian-configuration tool.

Upgrade openhabian

Go to command line input on openHAB.

sudo openhabian-config 
Choose 01 | Select Branch
Switch to "main" and hit SPACE bar to move the "*" to the line. Enter
Switch OpenHAB Version

Now you are back at the top page of openHabian-config.

Select 40 | openHAB Related

Here you can choose version you like. I am using Milestone version myself.

SSH Server

Situation:

Default user ID and password for SSH connection to the OpenHABian server is openhabian:openhabian. So SSH connection to the openHABian server should be able to achieve by entering the following command.

sudo ssh openhabian@[ipaddress of OpenHABian]

*openhabian in above situation before @ mark indicates, user account name on the OpenHABian server.
**sudo command allows one to execute superuser or command using other user privilege. IP address is where you put IP address of the OpenHABian Virtual Machine server.

However, despite entering the user ID credential, connection fails. SSH connection to the openHabian Virtual Machine keeps failing i.e. connection refused error.

Background:

Although ProxMox provides console access for shell command inputs, Virtual Machine version of it does not provide copy & paste capability. This can be a handy feature for various reasons e.g. setting up cloud access requires you to type in a long cryptic user id and password. So one can try connecting to the OpenHAB via SSH. If you did to install SSH during the Debian setup, you need add this.

Assessment:

SSH server is not running on the Virtual Machine installation version OpenHabian.

Go to ProxMox > OpenHAB Virtual Machine > Open Console

You can enter following command to confirm ssh server is indeed not running/not installed.

systemctl status ssh

Recommendation:

Install SSH server and run it.

Go to ProxMox > OpenHAB Virtual Machine > Open Console

Enter following command one line at a time.

apt-get update
apt install openssh-server
systemctl status ssh

The last line confirms ssh server appropriately installed and running.

Reference: https://phoenixnap.com/kb/how-to-enable-ssh-on-debian

Broken Log Viewer link fix

Situation:

Log Viewer link is broken.

Background:

Log viewer normally runs on the http://[openhabian IP address]:9001. This link; however, appears to be hard coded within the OpenHabian at the time of installation of the log viewer; therefore, if you manually change IP address or local openhabian name (default: openhabian.local), the link may break. In fact, I wanted to set static IP in my case so I changed mine from original DHCP selected IP to different static IP, and that’s when the log viewer link broke.

Assessment:

First, you want to make sure Log viewer is actually running. The easiest way to check this is go to your browser and access OpenHabian e.g. http://openhabian.local:8080. Then change the port number from 8080 to 9001 i.e. http://openhabian.local:9001. If you are accessing openhabian by IP address, you can do the same. You should see Log Viewer with 9001. This confirms Log Viewer instance is proper learning and the issue is indeed the broken link.

Recommendation:

Change hard coded link manually.

Open OpenHabian SSH or Console/Shell

The file containing the hard coded link address is located in the /etc/openhab/services/runtime.cfg file. So you need to open the file.

pico /etc/openhab/services/runtime.cfg

You can go to the bottom of the file and find a line:

org.openhab.core.ui.tiles:frontail-link-url=http://[ipaddress]:9001

Replace the [ipaddress] with the correct one i.e. where current instant of openhabian is running.

Personally, recommend changing to http://openhabian.local:9001 rather than IP address so when you change IP address again for whatever reason, this should still work.

runtime.cfg

You can hit Ctrl-X to save and exit.

You need to reboot the system to see the change reflection. You can do this via command line.

reboot

*Reboot only works from direct shell/console access i.e. I opened it with ProxMox console, but it won’t work with SSH.