Add a Logviewer to HabPanel
This is optional. But; why we are starting with such a feature, that isn’t really related to Smart Home and automation and so on? The answer is: This will make the troubleshooting in case of any errors much easier. Also if we are starting to create some rules later on, we can use this feature to see what is going on and maybe also what went wrong. If you want to skip this chapter for now, feel free to do so and come back when you have some trouble.
To realize this feature, we will install a software called Frontail. It is nothing that is special for OpenHab but it is used to show Logs in Linux in general on a website. To start we need to connect to the Raspberry Pi via SSH using Putty.
Execute the following commands to install the components used by Frontail and Frontail itself:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm i frontail -g
sudo nano /lib/systemd/system/frontail.service
Now the Linux texteditor “Nano” will open. Copy this configuration parameters into the opened editor. Copy the text below (Ctrl+C) and paste it into the Putty session by performing a right mouseclick.
Attention! On some systems the line breaks are gone after pasting it to Nano. To avoid this, paste the text to a notepad (press Windows-Key+R, type “notepad” and press enter). Copy the text from the notepad window again and it will work!
ExecStart=/usr/bin/frontail --ui-highlight -t dark /var/log/openhab2/openhab.log /var/log/openhab2/events.log
Your Putty session should look like this after you pasted the text:
Press Ctrl+O and enter to write the changes to the new file. Press Ctrl+X to leave the editor.
After this, we need to make the file we created executable and reload the service deamon of the operating system. Execute the following commands:
sudo chmod 644 /lib/systemd/system/frontail.service
sudo systemctl daemon-reload
sudo systemctl enable frontail.service
sudo systemctl start frontail.service
Finally you can access the OpenHab logs via browser by browsing to the URL http://<ip-of-raspberry>:9001. In our demo environment the link is http://192.168.0.144:9001.
After installing and configuring Frontail, we need to add it to the HabPanel. HabPanel is a customizable UI of OpenHab. I will go into more details in a different chapter. For now, just follow this advices:
- Go to http://<raspberry-ip>:8080 (i.e. http://192.168.0.144:8080)
- Click on the “HABPANEL” tile
- Click at the gear at the top right corner
- Click on “Add new dashboard”
- Name the new dashboard “System” and click “OK”
- Click on the big tile called “System” on the next screen
- Move your mouse over the “System” text at the top. A small pencil will appear at the right next to the text. Click the pencil to edit the dashboard.
- At the top right click “Add Widget” and select “Frame”.
- A new big tile will appear at the dashboard. Click the three dots at the top right corner of the tile and select “Edit…”.
- In the “Frame Settings” dialog enter “OpenHab Logs” in the Name-field, select “Static URL” in the URL Source-field and enter “http://<Raspberry-IP>:9001” (i.e. “http://192.168.0.144:9001”) in the URL-Field. Leave the Refresh Interval field empty and click “Save”.
- Optional: if you like to stretch the tile that will include the logs a little bit, you can hover over the tile and drag the bottom right corner to change the size of the tile. I personally like it if the tile is a little bit wider to make it easier to read long log lines.
- In the top left corner click on “Save” and after that on “Run”.
- Now you should see the running System-Dashboard that includes the logs of OpenHab. Here you can see what is going on and/or what is wrong in your configuration. Right now there should not be much in the logs and no or not much activity. In the next chapter we will add view to system resources (Memory, CPU, Disk use) of the Raspberry Pi to this dashboard.