Strange statstics with Ethernet GW and Vera



  • Hi,

    I experience some strange behavior with Vera3 and Ethernet GW.

    A little background

    In order to understand and collect some statistics of my sensor network I have hacked L_Arduino.lua in Vera3 to log values received by MySensor GW and timestamp.

    Change in L_Arduino.lua

    local function setVariable(incomingData, childId, nodeId)
        if (childId ~= nil) then
            -- Set variable on child sensor.
            local index = tonumber(incomingData[5]);
            local varType = tVarLookupNumType[index]
            local var = tVarTypes[varType]
            local value = incomingData[6]
            local timestamp = os.time()
            if (var[2] ~= nil) then 
                log("Setting variable '".. var[3] .. "' to value '".. value.. "'")
                setVariableIfChanged(var[2], var[3], value, childId)
        
                -- Handle special variables battery level and tripped which also
                -- should update other variables to os.time()
                if (varType == "TRIPPED" and value == "1") then
                    local variable = tVeraTypes["LAST_TRIP"]
                    setVariableIfChanged(variable[2], variable[3], timestamp, childId)
                else
                    local variable = tVeraTypes["LAST_UPDATE"]
                    setVariableIfChanged(variable[2], variable[3], timestamp, childId)
                end
                -- Start Jocke: adding statistics logging
                local file = io.open("/dataMine/JJLogs/JockeMonitor_"..childId.."_"..var[3]..".log", "a")
                file:write(timestamp.."\t"..value.."\n")
                file:close()
                -- End Jocke
            end
            //...snip...
        end
    end
    

    Then I can copy the data into Excel to do some very simple analysis e.g. see if no transmission was received as expected.
    The sensor used in this scenario is EnergyPulseSensor which send every 20 sec (not comparing the previously value for the test) so 20 sec between transmissions is expected (but tolerate up to 23 sec). Quite often I can see 40, 60 and in this case the transmission failed 1 or 2 times. Also I have got values in between e.g. 29 sec which can indicate that GW (or something is under heavy load)

    So to the issue...
    Yesterday I assembled a prototype for Ehernet GW to replace my current serial GW and let it run over night.
    I can now see quite many "duplicated" values i.e. time from previous is 0 but it's not consistent.
    This doesn't happen with serial GW so I suspect Ethernet GW calling setVariable(..) several times
    See Excel file
    Test5MySensors.xlsx

    Any idea? A bug?


  • Admin

    @jocke4u said:

    Switching gateway shouldn't matter. It does not contain any logic related to this. In the plugin on the other hand the setVariableIfChanged is used to prohibit setting a variable to the same value.



  • @hek
    Yes I know about setVariableIfChanged preventing to set unchanged Vera variables but I log all setVariable calls (unless childId or serviceId is null) and have not seen this with serial GW so I thought Ethernet GW was sending duplicate messages.


Log in to reply
 

Suggested Topics

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts