View Full Version : Lua event handler and binary data in Payload strings

November 2nd, 2015, 03:49 AM
I just installed thermometer to monitor freezer temperature. It transmits data to my RFXtrx device and is working just fine.

In the logger I see that I get two payloads with data, one for just the temperature and and one containing raw data.
Typically like this:


I tried to set up a LUA event handler for this and found that getting the battery status was impossible because the string delivered in the payloads table was chopped at the first binary data. So a statement like this:

tempHandlerID, err = gir.addEvenItHandler("TEMP",87,87, function( eventString, deviceNumber, keyMod, payloads, captures)
currentTemp = tonumber(payloads[1])
thermStatus = payloads[2]
i,j = string.find(payloads[2], "battery")

just returns nil for i/j. Because payloads[2] is chopped down to:


When using the "TEMP" event to trigger a script I can pick up the whole string from the "event.payloads" variable, and code like this is working fine:

freezerTemp = tonumber(event.payloads[1])
freezerStatus = event.payloads[2]
i,j = string.find(freezerStatus, "battery")

November 2nd, 2015, 06:33 AM
that is strange, thanks for the report. I'm going to find why payloads are not properly being pushed into Lua with presumably embedded '0'....

November 2nd, 2015, 06:38 AM
Found the culprit. Do you need the update?

November 2nd, 2015, 07:05 AM
Thanks for the quick response.

I don't need an update right now. Triggering the action the normal way with the event works fine. If I get more devices like this, I might look into centralizing everything in an event handler, but right now there's no need for that.

November 2nd, 2015, 07:09 AM
No problem, thanks for the detailed report. This fix will roll out with the next release.