sam
sam

Reputation: 63

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

enter image description hereI 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...

Upvotes: 1

Views: 1303

Answers (1)

Roni Beitel
Roni Beitel

Reputation: 68

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};

Upvotes: 1

Related Questions