|
Post by papa on Feb 17, 2017 19:40:08 GMT
This Thread Updated April 21, 2020 for OpenHAB 2.5.x
I wanted a way for OpenHAB to report any node (ESP8266 or not) offline. From the computourist Gateway & End Node sketches, I tried using ACK & Device 90 (radio error), but was not successful. Then I came across the expire binding, that was announced Nov 2016. It's currently in a 1.14 version, but so far can still be used by both OpenHAB 2.5.x. 1) Install the Expire Binding
Go to PaperUI/Add-ons/Bindings & install Expire Binding. (This will help us know if a device is offline.)
What if you don't see the Expire Binding to install it? When we first installed openHAB, it asked what package we wanted: Simple or Standard or Expert. We need to be in either Standard or Expert to see the 1.x bindings. To fix this I believe you can edit \conf\services\addons.cfg. Find the line that includes "#package = " & change it to "package = standard" or "package = expert" (no "#" to begin & disable the setting). Save the edited file & perhaps restart openHAB.
Continues Below: Use Expire Binding to Report Offline Nodes
|
|
|
Post by papa on Feb 17, 2017 19:46:32 GMT
Continued: Use Expire Binding to Report Offline Nodes Updated April 28, 2020 for OpenHAB 2.5.x
2) Edit the OpenHAB config files to take advantage of the Expire Binding. Below, "Before" indicates before the expire binding & "After" ...
The following assumes the creation of related Things, Channels, & linking the channels to the related items.
.items file Before: String Node12UpTime "Gardn_12_Up [%s mins]" <network> (Nodes) { channel="mqtt:embedded-mqtt-broker:topic:mything:Node12Channel00" } String Node2Rssi "LR_02_RSSI (db) [%s]" <network> (Nodes)
After (change in blue text: String Node12UpTime "Gardn_12_Up [%s mins]" <network> (Nodes) { channel="mqtt:embedded-mqtt-broker:topic:mything:Node12Channel00", expire="3m,Offline?" } papa: All the expire binding declaration needs is a time to allow a non-changing item state (e.g. 3 minutes) & then what will replace the stale state (e.g. Offline?). The time can include hours, minutes, & seconds. See the documentation links below. .sitemap fileBefore: Text item=Node12UpTime After: No change .rules fileNo new rules needed Continues Below: Getting Results with the Expire Binding
|
|
|
Post by papa on Feb 17, 2017 19:55:21 GMT
Continued: Getting Results with the Expire Binding Updated April 21, 2020
As above, I installed the Expire Binding & edited only the .items file. With typical computourist Gateway & End Node (12) running, I got the following results. ^^ User Interface results with End Node connected to power. (OpenHAB reports Node 12's Uptime.) ^^ User Interface results with End Node disconnected from power for greater than 3 minutes. A disconnected node no longer reports Uptime & that state grows stale. After 3 minutes (changeable), OpenHAB UI reports Node 12 may be offline. When the node is re-powered, OpenHAB quickly reports Uptime. See this thread: one might have OpenHAB send an email or a notice about the possibly offline node. Continues Below: Documentation for the Expire Binding
|
|
|
Post by papa on Feb 17, 2017 20:12:47 GMT
|
|
|
Post by greginkansas on Feb 17, 2017 23:48:18 GMT
This looks cleaner than the way I have been doing this. Good find Papa
|
|
|
Post by papa on Feb 18, 2017 0:43:34 GMT
Thanks, greg. How will you use the Expire Binding?
|
|
|
Post by greginkansas on Feb 18, 2017 2:16:05 GMT
I had a rule for every node like this
rule "is node4 transmiting in the last 10 Minutes" when Item node2UPtime changed then if (node4UPtime.changedSince(now.minusMinutes(10))) { postUpdate (node4_is_it_on,"ON") } else { postUpdate (node4_is_it_on,"OFF") } end
So it looks like I can add 1 item per node and get rid of the rules also keep track of the time of last contact
rule "node 28 Changed" when Item node28UPtime received update then postUpdate(node28updatetime, new DateTimeType()) end
|
|
|
Post by agecrabahaykubo on Feb 8, 2018 2:30:27 GMT
I had mine using MAP which I got from OH forum .sitemap file Group item=LivingRoom label="Living Room" icon="room" { Text item=wemostemp2 label="Temperature" valuecolor=[>22="red",<=22="blue"] Text item=wemoshumidity2 label="Humidity" valuecolor=[<=29="red",>=30="green"] Text item=echoDot label="Amazon Echo Dot" valuecolor=[ON="green", OFF="red"] icon="echodot" Text item=AgecraTV label="Samsung TV" valuecolor=[ON="green", OFF="red"] icon="tv" Text item=Node02_PIR label="Motion Sensor" valuecolor=["red"] Switch item=livingroom label="Living Room Light" icon="lightbulb" Switch item=Lamp1 label="Living Room Lamp" icon="lightbulb" } .items file Group Living_Room (Room) Number wemostemp2 "Temperature [%.1f °C]" <temperature2> ["CurrentTemperature"] {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev48:state:default]"} Number wemoshumidity2 "Humidity [%.1f]" <comfort_level> ["CurrentHumidity"] {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev49:state:default]"} Switch AgecraTV "Samsung Smart TV [MAP(device_status.map):%s]" <tv> {channel="network:pingdevice:192_168_xx_xx:online"} Switch echoDot "Amazon Echo Dot [MAP(device_status.map):%s]" <echodot> {channel="network:pingdevice:651ac123:online", mqtt="<[mosquitto:/home/livingroom/echo/state:state:MAP(onoff2.map)], >[mosquitto:/home/livingroom/echo/switch:command:default],>[mosquitto:/home/livingroom/echo/switch:state:*:default]"} Switch livingroom "Living Room Light" <lightbulb> ["Lighting"] {channel="zwave:device:123e7d6a:node2:switch_binary", mqtt="<[mosquitto:/home/livingroom/zwave/switch/state:state:MAP(onoff2.map)], >[mosquitto:/home/livingroom/zwave/switch:command:default],>[mosquitto:/home/livingroom/zwave/switch:state:*:default]"} Switch Lamp1 "Switch 1" <lightbulb> ["Lighting"] {mqtt="<[mosquitto:/home/livingroom/nodemcu/light/state:state:MAP(onoff.map)],>[mosquitto:/home/livingroom/nodemcu/light/com:command:ON:1],>[mosquitto:/home/livingroom/nodemcu/light/com:command:OFF:0]"} .map file ON=ONLINE OFF=OFFLINE -=Unknown
|
|
|
Post by papa on Feb 8, 2018 2:52:57 GMT
Yes, agecrabahaykubo, network devices are pingable & I use code similar to yours for indicating that such devices are online or offline.
I was not successful with the last will feature of ESP8266 devices & did not find something similar for RFM69 devices.
Adding the Expire Binding to RSSI (Radio Signals) gave me a fairly short & reliable way of telling if RFM69 or ESP82xx WiFi devices were online
Thanks for giving some examples of using the Network Binding & Things
|
|
|
Post by greginkansas on Mar 5, 2020 1:16:59 GMT
I like to have the offline nodes on a switch, so I can have a page that only shows offline nodes This line does this. Device 10 is for the IP but here just sets the switch to ON. Switch node70_is_it_on (network, Node70){ mqtt="<[mosquitto:home/esp_gw/nb/node70/dev10:command:ON::]", expire="5m,command=OFF" }
papa: Thanks, Greg, for another example of using the expire binding. I see you are using Mosquitto as your MQTT message service. I've switched to openHAB's embedded MQTT broker
|
|
|
Post by papa on Apr 28, 2020 18:46:36 GMT
Above, see how this thread was updated April, 2020
|
|