ThingsBoard: plot timeseries with future timestamps in a chart widget

梦想的初衷 提交于 2019-12-23 03:58:10

问题


I've been having some troubles with TB in the last days.

I have a generic variable (let's assume, for example, the external temperature), which measures are acquired at realtime using MQTT and tb-gateway. I also have the variable forecasts for a given future time period, acquired via MQTT from a Python module which performs the forecasting. I wish to plot in the same graph both the data acquired at realtime and the forecasted trend for a given time period (let's say for the next 24 hours), using two different curves.

Now, I managed to upload (via MQTT) the forecasted timeseries with the correct future timestamps, exploiting the timestamp mapping feature of ThingsBoard.

When it came to plot these information on a chart, I found out that ThingsBoard can only plot timeseries values related to the current system timestamp or past timestamps. I am trying to find a way to plot timeseries data related to future timestamps on the chart widget.

Anybody experienced the same issue and managed to solve it?


回答1:


Short answer: you will need to create a custom widget for implementing your case.


Long answer:

When you are using 'Realtime - Last XXX' time window, widget actually creates a subscription for the temperature telemetry. Since subscription is created, the Thingsboard backend will send all temperature updates to the UI even if the timestamp is in the future. But standard chart widgets will reject all telemetries that are 'from future'.

You can open the browser console 'network' tab and view WebSocket activity - telemetry from future is transmitted to the UI.

Another problem is that standard Thingsbarod Time Range picker does not allow to select 'future' time range.

In the same time, Thingsboard REST API does not validate startTs and endTs of the request so you can easily download telemetry 'from the future'.


So I recommend to create custom chart widget that will contain its own time-range picker and that will request data using REST API. https://thingsboard.io/docs/reference/rest-api/



来源:https://stackoverflow.com/questions/53080482/thingsboard-plot-timeseries-with-future-timestamps-in-a-chart-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!