tips:openhab2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tips:openhab2 [2016/11/05 10:59] – [Programming] scipiotips:openhab2 [2021/11/01 08:47] (current) – removed scipio
Line 1: Line 1:
-====== OpenHAB2 ====== 
  
-  * https://mysmarthomeweb.wordpress.com 
-  * http://www.makeuseof.com/tag/getting-started-openhab-home-automation-raspberry-pi/ 
-===== Install ===== 
- 
-==== containers lxd ==== 
- 
-device USB container 
-<code bash> 
-lxc config device add openhab2 rfxcom unix-char path=/dev/ttyACM0 
-lxc config device set openhab2  rfxcom  mode 666 
-</code> 
- 
-==== rasbian ==== 
- 
-<code bash> 
-apt install apt-transport-https 
-</apt> 
- 
-==== common ==== 
- 
-<file txt /etc/apt/sources.list.d/openhab2.list>  
-cat > /etc/apt/sources.list.d/openhab2.list <<EOF 
-deb  [trusted=yes] https://openhab.ci.cloudbees.com/job/openHAB-Distribution/ws/distributions/openhab-offline/target/apt-repo/ / 
-deb  [trusted=yes] https://openhab.ci.cloudbees.com/job/openHAB-Distribution/ws/distributions/openhab-online/target/apt-repo/ / 
-EOF 
-</file> 
- 
-<code bash> 
-wget -qO - 'http://www.openhab.org/keys/public-key-snapshots.asc' | sudo apt-key add - 
-sudo apt update 
-# apt install openjdk-8-jre 
-apt install oracle-java8-jdk # much better for openhab speed 
-</code> 
- 
-<code bash> 
-apt install openhab2-online 
- 
-sudo systemctl enable openhab2.service 
-sudo systemctl start openhab2.service 
-sudo systemctl status openhab2.service 
-</code> 
- 
-=====  WEB GUI ===== 
- 
-  * http://localhost:8080 
- 
-===== CLI ===== 
- 
-<code bash> 
-/usr/share/openhab2/runtime/karaf/bin/client 
-</code> 
- 
-==== Manage configuration ==== 
- 
-<code bash> 
-config:list "(service.pid=org.openhab.addons)" 
-</code> 
- 
-change params 
-<code bash> 
-config:property-set -p org.openhab.addons legacy true 
-config:property-set -p org.openhab.addons remote true 
-config:property-set -p org.openhab.addons experimental true 
-</code> 
- 
-==== Install features ==== 
- 
-show features 
-<code bash> 
-feature:list | grep network 
-</code> 
- 
-interesting features 
-<code bash> 
-feature:install openhab-runtime-compat1x 
- 
-feature:install openhab-transformation-regex 
-feature:install openhab-binding-exec 
-feature:install openhab-persistence-rrd4j 
-config:property-set -p org.openhab.addons persistence rrd4j 
-config:property-set -p org.eclipse.smarthome.persistence default rrd4j 
- 
-feature:install openhab-ui-habmin 
-feature:install openhab-ui-habpanel 
- 
-feature:install openhab-action-telegram 
- 
-feature:install openhab-binding-network 
-# feature:install openhab-binding-lgtv 
-</code> 
- 
-==== Introspection ==== 
- 
-<code bash> 
-openhab> things list 
-yahooweather:weather:158197f6007 (Type=Thing, Status=ONLINE, Label=Weather Information, Bridge=null) 
- 
-openhab> items list 
-yahooweather_weather_158197f6007_temperature (Type=NumberItem, State=2, Label=Temperature, Category=Temperature) 
-yahooweather_weather_158197f6007_humidity (Type=NumberItem, State=77, Label=Humidity, Category=Humidity) 
-yahooweather_weather_158197f6007_pressure (Type=NumberItem, State=30308.19, Label=Pressure, Category=Pressure) 
- 
-openhab> links list 
-yahooweather_weather_158197f6007_temperature -> yahooweather:weather:158197f6007:temperature 
-yahooweather_weather_158197f6007_humidity -> yahooweather:weather:158197f6007:humidity 
-yahooweather_weather_158197f6007_pressure -> yahooweather:weather:158197f6007:pressure 
-</code> 
- 
-==== Log ==== 
- 
-console 
-<code bash> 
- 
-# change log level 
-log:set DEBUG 
- 
-# clear  
-log:clear 
- 
-# show continuos tail 
-log:tail 
-</code> 
- 
-===== Persistence ===== 
- 
-  * https://github.com/openhab/openhab/wiki/Persistence 
- 
-Enable rrd4j binding 
- 
-<file txt /etc/openhab2/services/rrd4j.cfg> 
-ctr5min.def=COUNTER,900,0,U,300 
-ctr5min.archives=AVERAGE,0.5,1,365:AVERAGE,0.5,7,300 
-# ctr5min.items=systeminfo_computer_15819c96492_cpu_load,yahooweather_weather_158197f6007_temperature,yahooweather_weather_158197f6007_humidity,yahooweather_weather_158197f6007_pressure 
-</file> 
- 
- 
-<file txt /etc/openhab2/persistence/rrd4j.persist> 
-// persistence strategies have a name and a definition and are referred to in the "Items" section 
-Strategies { 
-    everyMinute : "0 * * * * ?" 
-    everyHour : "0 0 * * * ?" 
-    everyDay  : "0 0 0 * * ?" 
- 
-    // if no strategy is specified for an item entry below, the default list will be used 
-    default = everyChange 
-} 
- 
-/*  
- * Each line in this section defines for which item(s) which strategy(ies) should be applied. 
- * You can list single items, use "*" for all items or "groupitem*" for all members of a group 
- * item (excl. the group item itself). 
- */ 
-Items { 
-    // persist all items once a day and on every change and restore them from the db at startup 
-    * : strategy = everyChange, everyHour, restoreOnStartup 
- 
-    // additionally, persist all temperature and weather values every hour 
-    Temperature*, Weather* : strategy = everyHour 
-} 
-</file> 
- 
-===== demo mode ===== 
- 
-<file txt /etc/openhab2/services/addons.cfg> 
-package = demo 
-</file> 
- 
-===== z-wave ===== 
- 
-<code bash> 
-feature:install binding-zwave 
-</code> 
- 
-===== Programming ===== 
- 
-==== items ==== 
- 
-<file txt items/cpu.items> 
-// create an item from another channel item "items list" 
-Number Cpu "Cpu [%.0f]" (signal) { channel="systeminfo:computer:15819c96492:cpu#load" } 
- 
-// fetch data from script every 2 seconds (install exec binding and regex transformation) 
-Number TestLoad "Test load [%.0f]" (signal) { exec="<[/etc/openhab2/test.sh:1000:REGEX((.*?))]" 
-</file> 
- 
-<file txt rules/cpu.rules> 
-import org.openhab.core.library.types.* 
-import org.openhab.core.persistence.* 
-import org.openhab.model.script.actions.* 
- 
-val Timer timer = null 
-val Timer waitTimer = null 
-val int sleepMinutes = 1 
- 
-rule "CPU too high" 
-when 
-    Item Cpu changed 
-then 
-    if (Cpu.state > 40) { 
-      if (timer == null) { 
-        // watch cpu for 5 seconds  
- timer = createTimer(now.plusSeconds(5)) [| 
-      val message = "CPU troppo alta: " + Cpu.state.toString() + ". Prossimo messaggio in "+ sleepMinutes.toString() + " minuti" 
-          sendTelegram("bot1", message) 
-   logWarn("home", message) 
- 
-   waitTimer = createTimer(now.plusMinutes(sleepMinutes)) [|  
-      timer = null  
-      sleepMinutes = sleepMinutes*2 
-          ] 
- ] 
-      } 
-    } else { 
-      if(timer != null) { 
-         timer.cancel 
-         timer = null 
-         sleepMinutes = 1 
-      } 
-    } 
-end 
-</file> 
  • tips/openhab2.1478339957.txt.gz
  • Last modified: 2016/11/05 10:59
  • by scipio