Use of TCP Client for RFX devices

I have Oregons temperature sensors.
The RFX433 data is exposed in TCP using ser2net.
I have configured in nymea, a TCP client connected to the ser2net server. I want to expose the values of these sensors using a ‘magic’ script, but it seems that the data property of the param object in the ‘onTriggered’ event of the TCP Client object is of type string. RFX frame data is 8 bits unsigned.
I can decode the frame type (the RFX hardware type) and the expected size. However, for the temperatures, the data decoded in the script does not correspond to what it should be. I guess I’m losing information related to raw=>String=>uint conversion.

Anybody have an opinion?

Here the script I used to decode params.data

Item {
property int idx:0
property var buf
property int len:0
ThingEvent {
thingId: “{39122660-690e-4e26-bddc-72bd206bbf70}” // TCP Client RFX433
eventName: “triggered”
onTriggered: {
var data = params.data;
var received = data.length;
if (idx == 0){
len = data.charCodeAt(0) +1;
buf = new Uint8Array(len);
for (var i=0; i< received; i++){
buf[i] = data.charCodeAt(i);
}
if (received != len){
idx = received;
}
}else{
for (var i=0; i< received; i++){
buf[i+idx] = data.charCodeAt(i);
}
idx = idx + received;
if (idx >= len){
idx = 0;
}
}
// we received full message
if (idx == 0){
console.log(“----------------------”);
for (var i = 0; i< len; i++){
console.log(“buf”, buf[i]);
}
}
}
}

}

Hi,
it’s hard to tell without seeing the actual data that comes in… Can you add a print for params.data and paste that?

Hi,

Here is the data receive as String and the value as uint8.

image

message length = data [0] is correct
device type = data [1] is correct
device subtype = data [2]
Sequence nbr = data [3]

device id: data[4] * 256 + data[5]
computed id: 21761
id in openhab for the same device: 21761

signbit = data[6] & 0x80

temperature = ((data[6] & 0x7f) * 256 + data[7]) / 10 * (signbit ? -1 : 1)
computed temp: 25.3
temp in openhab for the same device: 21.6

batteryLevel: data[8] & 0x0f
computed battery level: 0
battery level in openhab for the same device: 10

rssi: (data[8] >> 4) & 0xf

Sorry, without actually being able to reproduce this I can’t really help. Can’t spot any obvious mistakes in the code.

Did you get it running by now?

Hello,

Not yet. But for that, I’m thinking to forward all RFX433 messages to Mqtt with a rfxcom2mqtt container and to use generic things in nymea.

I’m also looking to connect my zigbee dongle (Sonoff Zigbee USB dongle plus) directly with my nymea container to have a “better integration” (and maybe to use Mqtt client to foward messages back to Mqtt). But I have to kind of devices I do not know if they are recognized by nymea.

I’m also looking to use Postgress instead of sqlite at some point, but I saw that InfluxDB will be used in next release.

best regards

The Bosch one will likely just work, the other not. In any case, adding support for new ZigBee devices is rather easy, so, we’ll get those running I suppose.

Yes, no point in switching to postgres any more. The next release will not support SQL databases any more but move to influx instead.