Is it possible to get alarm data for the map widget in Thingsboard?

ε祈祈猫儿з 提交于 2019-12-14 03:22:49

问题


I am trying to change my marker based on an alarm I've created in Thingsboard. Currently the marker is displaying data from my "datasource" entity. However there is no way (that I have seen) that you can add an "Alarm source" similar to the alarm widget.

The data available is "f(data, images, dsData, dsIndex)" which I assume is only the data telemetry.

Basically I need to change the marker if an alarm is going off. My alarm trigger only goes off momentarily so I can't use my data telemetry directly...


回答1:


You can try adding a new "Save attribute" on the alarm rule chain, after the alarm is created. Combined with a "Change originator" you can save the attribute to a specific device. Then on the map widget you can add the new attribute to the datasource and act as per that attribute. It is a bit non-conventional approach, but it should probably work for you.

You should have a "Change Originator"--> "Script" --> "Save Attribute" On the script item you should insert the new attribute to the data and update the msgType to "POST_ATTRIBUTES_REQUEST". I'm not sure if you need to update the message or metadata, but I guess you can try and see.

Script code:

msg = {};
msg.alarm = true;
metadata = {};
metadata.alarm = true;
msgType = "POST_ATTRIBUTES_REQUEST";
return {msg: msg, metadata: metadata, msgType: msgType};


来源:https://stackoverflow.com/questions/54915086/is-it-possible-to-get-alarm-data-for-the-map-widget-in-thingsboard

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