Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tips:openhab2 [2016/11/05 08:05] – [Install] scipio | tips:openhab2 [2021/11/01 08:47] (current) – removed scipio | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== OpenHAB2 ====== | ||
- | * https:// | ||
- | ===== Install ===== | ||
- | |||
- | ==== containers lxd ==== | ||
- | |||
- | device USB container | ||
- | <code bash> | ||
- | lxc config device add openhab2 rfxcom unix-char path=/ | ||
- | lxc config device set openhab2 | ||
- | </ | ||
- | |||
- | ==== rasbian ==== | ||
- | |||
- | <code bash> | ||
- | apt install apt-transport-https | ||
- | </ | ||
- | |||
- | ==== common ==== | ||
- | |||
- | <file txt / | ||
- | cat > / | ||
- | deb [trusted=yes] https:// | ||
- | deb [trusted=yes] https:// | ||
- | EOF | ||
- | </ | ||
- | |||
- | <code bash> | ||
- | wget -qO - ' | ||
- | sudo apt update | ||
- | apt install openjdk-8-jre | ||
- | </ | ||
- | |||
- | <code bash> | ||
- | apt install openhab2-online | ||
- | |||
- | sudo systemctl enable openhab2.service | ||
- | sudo systemctl start openhab2.service | ||
- | sudo systemctl status openhab2.service | ||
- | </ | ||
- | |||
- | ===== WEB GUI ===== | ||
- | |||
- | * http:// | ||
- | |||
- | ===== CLI ===== | ||
- | |||
- | <code bash> | ||
- | / | ||
- | </ | ||
- | |||
- | ==== Manage configuration ==== | ||
- | |||
- | <code bash> | ||
- | config:list " | ||
- | </ | ||
- | |||
- | change params | ||
- | <code bash> | ||
- | config: | ||
- | config: | ||
- | config: | ||
- | </ | ||
- | |||
- | ==== Install features ==== | ||
- | |||
- | show features | ||
- | <code bash> | ||
- | feature: | ||
- | </ | ||
- | |||
- | interesting features | ||
- | <code bash> | ||
- | feature: | ||
- | |||
- | feature: | ||
- | feature: | ||
- | feature: | ||
- | |||
- | feature: | ||
- | feature: | ||
- | |||
- | feature: | ||
- | |||
- | feature: | ||
- | # feature: | ||
- | </ | ||
- | |||
- | ==== Introspection ==== | ||
- | |||
- | <code bash> | ||
- | openhab> things list | ||
- | yahooweather: | ||
- | |||
- | openhab> items list | ||
- | yahooweather_weather_158197f6007_temperature (Type=NumberItem, | ||
- | yahooweather_weather_158197f6007_humidity (Type=NumberItem, | ||
- | yahooweather_weather_158197f6007_pressure (Type=NumberItem, | ||
- | |||
- | openhab> links list | ||
- | yahooweather_weather_158197f6007_temperature -> yahooweather: | ||
- | yahooweather_weather_158197f6007_humidity -> yahooweather: | ||
- | yahooweather_weather_158197f6007_pressure -> yahooweather: | ||
- | </ | ||
- | |||
- | ==== Log ==== | ||
- | |||
- | console | ||
- | <code bash> | ||
- | |||
- | # change log level | ||
- | log:set DEBUG | ||
- | |||
- | # clear | ||
- | log:clear | ||
- | |||
- | # show continuos tail | ||
- | log:tail | ||
- | </ | ||
- | |||
- | ===== Persistence ===== | ||
- | |||
- | * https:// | ||
- | |||
- | Enable rrd4j binding | ||
- | |||
- | <file txt / | ||
- | ctr5min.def=COUNTER, | ||
- | ctr5min.archives=AVERAGE, | ||
- | # ctr5min.items=systeminfo_computer_15819c96492_cpu_load, | ||
- | </ | ||
- | |||
- | |||
- | <file txt / | ||
- | // persistence strategies have a name and a definition and are referred to in the " | ||
- | Strategies { | ||
- | everyHour : "0 0 * * * ?" | ||
- | everyDay | ||
- | |||
- | // 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 " | ||
- | * 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, | ||
- | |||
- | // additionally, | ||
- | Temperature*, | ||
- | } | ||
- | </ | ||
- | |||
- | ===== demo mode ===== | ||
- | |||
- | <file txt / | ||
- | package = demo | ||
- | </ | ||
- | |||
- | ===== Programming ===== | ||
- | |||
- | ==== items ==== | ||
- | |||
- | <file txt items/ | ||
- | // create an item from another channel item "items list" | ||
- | Number Cpu "Cpu [%.0f]" | ||
- | |||
- | // fetch data from script every 2 seconds (install exec binding and regex transformation) | ||
- | Number TestLoad "Test load [%.0f]" | ||
- | </ | ||
- | |||
- | <file txt 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(" | ||
- | logWarn(" | ||
- | |||
- | waitTimer = createTimer(now.plusMinutes(sleepMinutes)) [| | ||
- | timer = null | ||
- | | ||
- | ] | ||
- | ] | ||
- | } | ||
- | } else { | ||
- | if(timer != null) { | ||
- | | ||
- | timer = null | ||
- | | ||
- | } | ||
- | } | ||
- | end | ||
- | </ |