openHAB ...quick and dirty

 

Format and Transform in rules

var formatted_item = MyDate.getState().format("[%1$tA, %1$td.%1$tm.%1$tY]")
var transformed_item = transform(“MAP”, “values.map”, MyItem.state.toString)

 

Colored values in sitemap

Text item=MyItem valuecolor=[>6000="red",>600="orange",<=600="green"]

 

HowTo: Change http/s listening ports (to 8000 and 8444)

This change can be done in /etc/defaults/openhab2

OPENHAB_HTTP_PORT=8000
OPENHAB_HTTPS_PORT=8444

 

Configure frontail to show more lines

vim /etc/systemd/system/frontail.service

Change "-l 2000" to something higher (be aware this might have an effect on the performance)

 

HowTo: Start openhab2 service after another service (here: mosquitto)

My Linux system uses openhab2 as systemd service, but mosquitto was run as a SysVinit script.

1. So first I needed to "convert" the mosquitto startup script from SysVInit to systemd

The required steps are described here: HERE

2. Then just edit the openhab service script...

/etc/systemd/system/multi-user.target.wants/openhab2.service

...and add the red colored text

[Unit]
Description=openHAB 2 - empowering the smart home
Documentation=https://www.openhab.org/docs/
Documentation=https://community.openhab.org
Wants=network-online.target mosquitto.service
After=network-online.target mosquitto.service

[Service]
Environment=OPENHAB_HOME=/usr/share/openhab2
Environment=OPENHAB_CONF=/etc/openhab2
Environment=OPENHAB_RUNTIME=/usr/share/openhab2/runtime
Environment=OPENHAB_USERDATA=/var/lib/openhab2
Environment=OPENHAB_LOGDIR=/var/log/openhab2
Environment=OPENHAB_STARTMODE=daemon
EnvironmentFile=-/etc/default/openhab2

User=openhab
Group=openhab

WorkingDirectory=/usr/share/openhab2
ExecStart=/usr/share/openhab2/runtime/bin/karaf $OPENHAB_STARTMODE
ExecStop=/usr/share/openhab2/runtime/bin/karaf stop

SuccessExitStatus=0 143
RestartSec=5
Restart=on-failure
TimeoutStopSec=120

LimitNOFILE=102642

[Install]
WantedBy=multi-user.target