Introduction
The goal of this tutorial is to bind a Hideki weather station like IROX Pro X, Mebus TE923 or TFA Nexus.
This tutorial runs on a linux station. It should work on raspberry too. I expect config files to be stored in /etc/openhab2.
It replaces my te923 addon as the approach is cleaner. https://github.com/openhab/openhab2-addons/pull/2899
Prerequisite
You need to have this project setup and running: http://te923.fukz.org/
mylinux:~/bin/te923tool$ ./te923con
1536045108:22.30:55:i:i:i:i:27.50:47:17.10:63:i:i:918.0:i:4:0:i:i:i:i:0
Log
Don’t hesitate to do a "tail -f /var/log/openhab2/*.log
Preparation
Define a rule in /etc/udev/rules.d/99-te923.rules
ATTRS{idVendor}=="1130", ATTRS{idProduct}=="6801", MODE="0660", GROUP="plugdev"
And add openhab to the plugdev group
sudo adduser openhab plugdev
Verify that te923 is running from openhab2 user (you may need to reboot).
linux:/etc/openhab2/things# sudo -u openhab /PATH_TE923/te923tool/te923con -s
0x29:0x17:0x34:0x10:0x26:1:0:1:1:1:1:1:1
Te923 Thing
You first need to define a thing ( /etc/openhab2/things/te923.things ). This binding is using the “Exec” add-on. Replace PATH_TE923 with your own personal path!
Thing exec:command:te923cmd [command="/PATH_TE923/te923tool/te923con", interval=60, timeout=5, autorun=false]
Te923 Items
You then need to define items: ( /etc/openhab2/items/te923.items ). Don’t hesitate to change the description (Ex: Temperature 0) and add/remove items.
String te923_raw "[%s]" {channel="exec:command:te923cmd:output"}
Number te923_t0 "Temperature 0 [%.1f °C]" <temperature> (gTe923)
Number te923_h0 "Humidity 0 [%.0f %%]" <humidity> (gTe923)
Number te923_t1 "Temperature 1 [%.1f °C]" <temperature> (gTe923)
Number te923_h1 "Humidity 1 [%.0f %%]" <humidity> (gTe923)
Number te923_t2 "Temperature 2 [%.1f °C]" <temperature> (gTe923)
Number te923_h2 "Humidity 2 [%.0f %%]" <humidity> (gTe923)
Number te923_t3 "Temperature 3 [%.1f °C]" <temperature> (gTe923)
Number te923_h3 "Humidity 3 [%.0f %%]" <humidity> (gTe923)
Number te923_t4 "Temperature 4 [%.1f °C]" <temperature> (gTe923)
Number te923_h4 "Humidity 4 [%.0f %%]" <humidity> (gTe923)
Number te923_t5 "Temperature 5 [%.1f °C]" <temperature> (gTe923)
Number te923_h5 "Humidity 5 [%.0f %%]" <humidity> (gTe923)
Number te923_press "Pressure [%.1f mBar]" <pressure> (gTe923)
Number te923_uv "UV [%.0f]" <sun> (gTe923)
// The external part of my weather station is HS, don't hesitate to uncomment...
// Number te923_fc "Forecast [%.0f]" <clouds> (gTe923)
// Number te923_storm "Storm Warning [%.0f]" <wind> (gTe923)
// Number te923_wd "Wind Direction [%.1f]" <sun> (gTe923)
// Number te923_ws "Wind Speed [%.1f] m/s" <sun> (gTe923)
// Number te923_wg "Wind Gust speed [%.1f] m/s" <sun> (gTe923)
// Number te923_wc "Windchill temperature [%.1f] °c" <sun> (gTe923)
// Number te923_rc "Rain Counter [%.0f]" <sun> (gTe923)
Group gTe923 "Temperature from TE923 Weather Station" <temperature>
Rule
I use a rule to transform raw string in items: ( /etc/openhab2/rules/te923.rules ).
If you want to support water + wind, please adapt this script.
If you have removed some some things, comment them in this script too!
rule "Process data from TE923"
when
Item te923_raw received update
then
var e = te923_raw.state.toString();
var s = e.split(":");
if (s.length<22 || s.length>25) {
logInfo("TE923 Rule", "te923_raw is not of the expected format: "+e);
return;
}
// T0:H0:T1:H1:T2:H2:T3:H3:T4:H4:T5:H5:PRESS:UV:FC:STORM:WD:WS:WG:WC:RC
// T0 - temperature from internal sensor in °C
// H0 - humidity from internal sensor in % rel
// T1..5 - temperature from external sensor 1..4 in °C
// H1..5 - humidity from external sensor 1...4 in % rel
// PRESS - air pressure in mBar
// UV - UV index from UV sensor
// FC - station forecast, see below for more details
// STORM - stormwarning; 0 - no warning, 1 - fix your dog
// WD - wind direction in n x 22.5°; 0 -> north
// WS - wind speed in m/s
// WG - wind gust speed in m/s
// WC - windchill temperature in °C
// RC - rain counter (maybe since station starts measurement) as value
//var unixdate = s.get(0);
var t0 = s.get(1);
if (!t0.equals("i")) {
sendCommand(te923_t0, t0);
}
var h0 = s.get(2);
if (!h0.equals("i")) {
sendCommand(te923_h0, h0);
}
var t1 = s.get(3);
if (!t1.equals("i")) {
sendCommand(te923_t1, t1);
}
var h1 = s.get(4);
if (!h1.equals("i")) {
sendCommand(te923_h1, h1);
}
var t2 = s.get(5);
if (!t2.equals("i")) {
sendCommand(te923_t2, t2);
}
var h2 = s.get(6);
if (!h2.equals("i")) {
sendCommand(te923_h2, h2);
}
var t3 = s.get(7);
if (!t3.equals("i")) {
sendCommand(te923_t3, t3);
}
var h3 = s.get(8);
if (!h3.equals("i")) {
sendCommand(te923_h3, h3);
}
var t4 = s.get(9);
if (!t4.equals("i")) {
sendCommand(te923_t4, t4);
}
var h4 = s.get(10);
if (!h4.equals("i")) {
sendCommand(te923_h4, t4);
}
var t5 = s.get(11);
if (!t5.equals("i")) {
sendCommand(te923_t5, t5);
}
var h5 = s.get(12);
if (!h5.equals("i")) {
sendCommand(te923_h5, h5);
}
var press = s.get(13);
if (!press.equals("i")) {
sendCommand(te923_press, press);
}
var uv = s.get(14);
if (!uv.equals("i")) {
sendCommand(te923_uv, uv);
}
// You could easily add the following information too
// var fc = s.get(15);
// var storm = s.get(16);
// var wd = s.get(17);
// var ws = s.get(18);
// var wg = s.get(19);
// var wc = s.get(20);
// var rc = s.get(21);
end
Sitemap
OPTIONAL
You need a sitemap to display it. Add the following file ( /etc/openhab2/sitemap/te923.sitemap ).
temperature.sitemap
sitemap temperature label="Temperature"
{
Frame label="Temperature" {
Group item=gTe923 label="Irox Weather Station"
}
}
Persistence
You can persist them ( /etc/openhab2/persistence/xxx.persist ).
OPTIONAL
Strategies {
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
}
Items {
gTe923* : strategy = everyMinute
}