Results 1 to 5 of 5

Thread: Lua event handler and binary data in Payload strings

  1. #1

    Default Lua event handler and binary data in Payload strings

    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:

    pld1="-25.5"
    pld2="{\"type\":80,\"sequence\":134,\"id1\":135,\" data\":\"�\000��y\",\"battery\":9,\"rssi\":7,\"tem p\":-25,5,\"id2\":0,\"subType\":7}",

    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:
    Code:
    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:

    "{\"type\":80,\"sequence\":134,\"id1\":135,\"data\ ":\"�"

    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:
    Code:
    freezerTemp = tonumber(event.payloads[1])
    freezerStatus = event.payloads[2]
    i,j = string.find(freezerStatus, "battery")

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,546

    Default

    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'....
    Ron
    No support through PM

  3. #3
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,546

    Default

    Found the culprit. Do you need the update?
    Ron
    No support through PM

  4. #4

    Default

    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.

  5. #5
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,546

    Default

    No problem, thanks for the detailed report. This fix will roll out with the next release.
    Ron
    No support through PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •