[Documentation] [TitleIndex] [WordIndex

Installing the openhab_static_examples

Before you start this chapter, look at the previous chapter Understanding the openHAB Event Bus.

The openhab_static_examples are an example of items that can be used in openHAB without any binding. These are referred to as unbound items. In the openhab_static_examples, an example is therefore generated for each item type, independent of physical devices. This makes it ideal to write test programs for openHAB, which later refer to real items and thus elements from a device/thing.

Explanation

The static examples are in items/static.items. With the rule file rules/static.rules all items which are null or empty will be populated by a rule. The file rules/cron.rules will update this items every minute. With this rule it is possible to receive changes (ItemStateEvent). Please make sure that in both files you should change the ip address in the URL for the static image. This static image is in html/webapps/Image.jpg. The URL should be http://<your_ip>:8080/static/webapps/Image.jpg.

Installation

With git you have to clone this repository and copy it to the configuration directory of openHAB. If you are using Ubuntu and have installed openHAB with apt, the directory is located in /etc/openhab.

git clone https://github.com/Michdo93/openhab_static_examples
cd openhab_static_examples
sudo cp -r * /etc/openhab
cd ..
sudo rm -r openhab_static_examples
sudo chown -R openhab:openhab /etc/openhab

In the configuration directory of openHAB, you have the following directory structure:

/etc/openhab
 |-html
 |-icons/classic
 |-items
 |-persistence
 |-rules
 |-scripts
 |-services
 |-sitemaps
 |-sounds
 |-things
 |-transform

To shorten it: You can create items, rules or things text-based. This is done in the respective subfolder from this directory. For this reason, we have also been able to copy data from a GitHub repository. Or you can create these configurations via the MainUI of openHAB.

An Items file ends with the .items file extension, a Rules file with the .rules file extension, and a Things file with the .things file extension. For example, we do not need a Things file. During the runtime of openHAB these files are read and loaded into the cache of openHAB. If a file is changed, this file is read in again.

Result

If you go to http://<your_ip>:8080/basicui/app?w=0000&sitemap=Sitemap, you could see something similar to this:

https://raw.githubusercontent.com/Michdo93/openhab_static_examples/master/sitemap.png

The next chapter continues with Examining the openhab_static_examples.


2024-04-27 13:00