Telemetry upload bug if telemetry list is not ordered by timestamp or if elements of list have different number of key/value pairs

未关闭
#85 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
python
领域
api

调研方向

首先,通过 TBGatewayMqttClient.gw_send_telemetry 重现三个 telemetry 示例,并比较上传的结果。跟踪 telemetry 上传路径,以确定列表顺序和不同的值长度如何影响时间戳和条目;当每个值都能根据输入顺序或形状无关地与其对应的时间戳一起上传时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

verification

I'm using tb-mqtt-client version 1.10.10

I have a use-case where I'm uploading a list of telemetry readings. Depending on the order of the list, sometimes not all telemetry is being uploaded and sometimes the timestamp with which it is being uploaded is incorrect...

I first though that the list needed to be sorted by the timestamp attribute but then I had cases where even if it was sorted by timestamp it would work fine. It seems to be a combination of the list not being sorted with each element of the list not having the same number of key/value pairs.

I can't figure out or understand this behavior so any help would be appreciated.

This is the code snippet I'm using for testing this problem:

from tb_device_mqtt import TBPublishInfo
from tb_gateway_mqtt import TBGatewayMqttClient

telemetry =[...]

client = TBGatewayMqttClient("my.url.com", port=1883, username="token")
client.connect()

result = client.gw_send_telemetry('test device', telemetry) 

success = result.get() == TBPublishInfo.TB_ERR_SUCCESS
client.disconnect()

print(success)

Following are some examples of the problem where the only thing I'm changing is the order of the telemetry list:

Example 1 - works fine

telemetry =[
    {
        'ts': 1736330010000,
        'values': {
            'test_1': 1,
            'test_1_1': 1,
        }
    },
    {
        'ts': 1736330030000,
        'values': {
            'test_3': 3,
            'test_3_1': 3,
        }
    },
    {
        'ts': 1736330020000,
        'values': {
            'test_2': 2,
            'test_2_1': 2
        }
    },
]

image

Example 2 - does not upload test_2 and test_2_1 telemetry

telemetry =[
    {
        'ts': 1736330010000,
        'values': {
            'test_1': 1,
            'test_1_1': 1
        }
    },
    {
        'ts': 1736330020000,
        'values': {
            'test_2': 2,
            'test_2_1': 2
        }
    },
    {
        'ts': 1736330030000,
        'values': {
            'test_3': 3
        }
    },
]

image

Example 3 - test_1 and test_1_1 are being uploaded with the wrong timestamp. They are being uploaded with the same timestamp as test_3

telemetry =[
    {
        'ts': 1736330010000,
        'values': {
            'test_1': 1,
            'test_1_1': 1,
        }
    },
    {
        'ts': 1736330030000,
        'values': {
            'test_3': 3,
        }
    },
    {
        'ts': 1736330020000,
        'values': {
            'test_2': 2,
            'test_2_1': 2
        }
    },
]

image

主要语言
Python
星标
130
派生
86
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

thingsboard/thingsboard-python-client-sdk 的其他 Issue

查看 thingsboard/thingsboard-python-client-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。