|
Post by papa on Jun 18, 2015 3:23:14 GMT
Help !! My questions (Back when I was new & more clueless in this project): 1) What is the purpose of the contact window item? To indicate OpenHAB, GW, & Node 2 are in communication?
2) How can I get the contact window status to show & be OPEN?
BTW thanks much to all of you who've worked on this project
Some information [ask for more if you need]:
On a Windows PC & 3.3v Arduino stuff, I have a mostly working OpenHAB setup with your GW 22 & DHT node 21 (node ID is 2)
In the Windows browser UI, it reliably displays Outside Temperature, Date & Time, Inside Temp & Inside Humidity from the DHT11, Todays Maximum [Temp] Todays Minimum [Temp], Outside Humidity, Humidex
HOWEVER, I cannot get Contacts Status to work
As CompuTourist instructs, in items, I declare "contact" item:
Contact window "Status [%s]" {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev40:state:OPEN:ON],<[mosquitto:home/rfm_gw/nb/node02/dev40:state:CLOSED:OFF]"}
& as instructed, in sitemap, I put a frame to show the state of the input:
Frame label="Contacts" { Text item=window }
Result: On the UI it shows Contacts [the closed window icon] Status - [that is blank, not OPEN or CLOSED] on the openhab console, osgi> openhab status window produces Uninitialized
Again ... 1) What is the purpose of the contact window item? To indicate OpenHAB, GW, & Node 2 are in communication?
2) How can I get the window status to show & be OPEN?
& again thanks so much for your work & how you might help me.
|
|
|
Post by computourist on Jun 29, 2015 19:32:12 GMT
This has been a while, see if I remember correctly.... The "contact window" items shows the status of a digital input (switch) on an end node. Whenever the input changes state, it sends a message containing "ON" or "OFF", which is interpreted by Openhab. On startup, Openhab hasn't received a message yet and cannot determine state, therefor shows a blank. Flip the switch and openhab will indicate the correct state. You could also send the switch state on a regular basis by including it as a push message. Hope this answers your question... =============================== Papa: Thanks for answering. When I get a chance, I'll re-look at that item using your explanation. Update, April 6, 2017: Fortunately it made more sense after time & study.
|
|
|
Post by papa on Mar 10, 2017 15:19:49 GMT
Interpreting OpenHAB’s config file entries
OpenHAB is a powerful way to gather & display information. However exploiting its power requires one to learn the language it expects in its config file (items, rules, & sitemap) entries. To document & reinforce my understanding, I offer the following Interpretation of OpenHAB’s config file entries. I welcome corrections & better ways to document this.
In the posts below, I will start with a complete item & then list pieces with an explanation for each. Color coding may help match the piece with its location in the complete item. After interpreting through the end of an item, I will give examples of its use in the .rules & .sitemap config files. I am using My.items, My.rules, & My.sitemap as example names of OpenHAB config files.
|
|
|
Post by papa on Mar 10, 2017 15:20:54 GMT
An example item for Windows: C:\openhab\configurations\items\My.items OR Linux (including Raspberry Pi): /etc/openhab/configurations/items/My.items
Complete Item: Number Node2Voltage "Node2Voltage [%.3fVdd]" <battery> (Nodes) {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev04:state:default]"}
Interpreting the Item's parts ... Number = type of value for this item is numerical as opposed to String (text) or Switch (ON / OFF)
Node2Voltage > the item’s reference name, arbitrary, but must be used consistently to access the item’s state (content value)
"Node2Voltage [%.3fVdd]" shapes the text displayed after the item’s icon. put "Node2Voltage" left justified on your sitemap and the current value of Node2Voltage as a number with three decimal places followed by "Vdd" right justified on the line
<battery> The line displaying this item will begin with the battery.png icon found in the openhab\webapps\images folder
(Nodes) means this Node2Voltage item belongs to the Nodes group. One can assign items to one or more groups. OpenHAB can reference all group members via the group name
{} Curly braces surround use of an OpenHAB binding, i.e. specialized coding added on to access certain devices or information types, like MQTT (mosquitto), weather, etc. Requires org.openhab.binding.mqtt-1.8.x.jar file in the openhab\addons folder
mqtt= “<[ ] ” Use OpenHAB’s mqtt binding to “subscribe” to a topic. MQTT is a system where topics are “published” by some things & such topics are received by other things that “subscribe” to them. The topic’s address & desired content or action are in the [ ] square brackets
mosquitto: the reference name of the mosquitto broker. It’s defined in the MQTT Transport section of the openhab.cfg file. Examples are mqtt:mosquitto.url=tcp://localhost:1883 OR mqtt:mosquitto.url=tcp://127.0.0.1:1883. The broker is a mosquitto service running on a computer where OpenHAB is also running. The broker’s name that one uses does not matter as long as the same name is used throughout OpenHAB’s .items file like My.items
The remainder of this item in the square brackets follow the computourist-refined MQTT conventions for Gateway devices & the nodes with which they communicate. Another MQTT convention will use different syntax between the [ ] square brackets: for example, in a different item for Eric Tsai’s Uber Home Automaton Number itm_garage_dist "Garage Dist [%.1f Inch]" (ALL) {mqtt="<[mymosquitto:4032:state:default]"} A parallel item for the PiGateway approach also has a different format between the [ ] square brackets. The differences are dictated by how the Gateway & node program sketches set up the mqtt message structure.
From computourist’s RFM_MQTT_GW_24.ino, the sketch to program a Gateway hub for a network ... the MQTT topic is /home/rfm_gw/direction/nodeid/devid where direction is: southbound (sb) towards the remote node & northbound (nb) towards MQTT broker
home/rfm_gw/ refers to a gateway & the nodes that connect to it in a wireless network. This is assigned in the gateway program sketch. One can change this wireless network reference if a couple other things are changed in the gateway program sketch.
/nb means the topic data will head toward the MQTT broker (on the computer) & OpenHAB which uses it.
/Node02 means the mqtt topic will access a node (hardware connected wirelessly to the Gateway) whose program sketch has named it Node02
The computourist-refined approach defines a system of devices. As follows from the Gateway program sketch: Reserved ranges for node devices, as implemented in the gateway are: 0 - 16 Node system devices 16 - 32 Binary output (LED, relay) 32 - 40 Integer output (pwm, dimmer) 40 - 48 Binary input (button, switch, PIR-sensor) 48 - 64 Real input (temperature, humidity) 64 - 72 Integer input (light intensity)
So dev04 is a node system device, In this case the node’s sketch program obtains the node’s voltage, a curiosity from a node powered by an AC adapter, but key information on a battery-powered node.
By /dev04:state (& the preceding part of the topic), OpenHAB commands Node02 to send its voltage state back via the Gateway.
|
|
|
Post by papa on Mar 10, 2017 15:37:11 GMT
By their names, items are used in rules & sitemap files
If the item Node2Voltage is defined in the My.items file (see previous post above) then in Windows: C:\openhab\configurations\rules\ Or in Linux (including Raspberry Pi): /etc/openhab/configurations/rules/ ...
My.rules could contain a rule like this
// email self if node02 voltage is too low // replace yourEmailaddress with your own email address // Mail Action must be set up in openhab.cfg
rule "email Node02 Low Voltage" when Item Node2Voltage changed then if(Node2Voltage.state <= 2.9) { sendMail("yourEmailaddress","from openhab","Node02 voltage is too low at " + Node2Voltage.state.toString + " volts") } end ===============================
Other notes about the above rule
// starts a commented line, a line of explanatory notes, or a line of disabled code
The first 3 (commented lines) could be written this way with the same effect ...
/* email self if node02 voltage is too low replace yourEmailaddress with your own email address Mail Action must be set up in openhab.cfg */
|
|
|
Post by papa on Mar 10, 2017 15:44:42 GMT
By their names, items are used in rules & sitemap files
Windows: C:\openhab\configurations\sitemaps OR Linux (including Raspberry Pi): /etc/openhab/configurations/sitemaps/ ...
The first (active, non-commented) line of My.sitemap could be sitemap My label="My House"
a later section of My.sitemap could read Frame label="Node Health" { Text item= Node2Voltage }
Then on a web browser, you could enter the address http://localhost:8080/openhab.app?sitemap=My OR enter http://127.0.0.1:8080/openhab.app?sitemap=My
If OpenHAB, MQTT service, Gateway & Node are set up properly, you should see (as said above) "Node2Voltage" (left justified on your sitemap) and the current value of Node2Voltage as a number with three decimal places followed by "Vdd" (right justified on the line).
|
|
|
Post by papa on Mar 10, 2017 15:49:10 GMT
How about this item in My.items: Number Weather_Temp_Max "Todays Maximum [%.1f °F]" <temperature> (Weather_Chart) {weather="locationId=home, forecast=0, type=temperature, property=max, unit=fahrenheit, scale=0"} ^^ Interpreting the above item ^^ Number > type of value for this item is numerical as opposed to String (text) or Switch (on / off) Weather_Temp_Max > the item’s reference name, arbitrary, but must be used consistently to access the item’s state (content value) <temperature> The line displaying this item will begin with the temperature.png icon found in the openhab\webapps\images folder "Todays Maximum [%.1f °F]" shapes the text displayed after the item’s icon. put "Todays Maximum" left justified on your User Interface sitemap and the current value of Todays Maximum as a number with one decimal place followed by " °F" right justified on the line (Weather_Chart) means this Weather_Temp_Max item belongs to the (Weather_Chart) group. One can assign items to one or more groups. OpenHAB can reference all group members via the group name {} Curly braces surround use of an OpenHAB binding, i.e. specialized coding added on to access certain devices or information types, like MQTT (mosquitto), weather, etc. Requires org.openhab.binding.weather-1.8.x.jar file in the openhab\addons folder weather="locationId=home Use OpenHAB’s weather binding to get data for the defined home location. This requires editing the Weather Binding section of openhab.cfg: like indicating home’s Weather provider, api key, latitude & longitude, language, & update interval. forecast=0, type=temperature, property=max, unit=fahrenheit, scale=0" The defining properties of this item, each type of weather data has its properties. To see available weather data & the items to obtain them, go here github.com/openhab/openhab/wiki/Weather-Binding & search for “the following Items section”
|
|
|
Post by papa on Mar 10, 2017 15:53:08 GMT
In My.sitemap, using the item Weather_Temp_Max (See the previous post)
In My.sitemap put the line Text item=Weather_Temp_Max
===================== Interpreting the above ...
Upon entering the web browser address http://127.0.0.1:8080/openhab.app?sitemap=My the user interface would display ...
"Todays Maximum" left justified on your User Interface sitemap and the current value of Todays Maximum as a number with one decimal place followed by " °F" right justified on the line
|
|