thingsboard / thingsboard-edge

Apache License 2.0
93 stars 71 forks source link

[Question] Device activity/inactivity events issue at the edge #85

Closed akseerali closed 7 months ago

akseerali commented 8 months ago

Component

Description We have a gateway device that collects the data from multiple nodes and sends it to the local edge instance via the MQTT protocol. Once the data arrives at the edge, we use the transform script in the rule chain to identify the source ID of the node connected to the gateway and then transfer the incoming telemetry data to the child node by using the "change originator" in the rule chain. image

By doing so, the edge can collect the device's data connected to a single gateway and show it at the user interface; however, the edge is unable to identify the activity/inactivity alarms related to the child nodes even though the "inactivityTimeout" feature is configured for each child node.

Is it possible to resolve this issue?

Environment

volodymyr-babak commented 8 months ago

Hello @akseerali,

I noticed that you mentioned using the PE edition of Edge. Would it be possible for your case to utilize MQTT integration instead of the MQTT Gateway API as described here: https://thingsboard.io/docs/pe/edge/user-guide/integrations/mqtt/?

When using MQTT integration instead of the MQTT Gateway API, the child node (device in TB naming) is updated correctly in the device state service. This approach should provide the inactivity feature as expected.

If using a Rule Chain to switch to the originator by name or another method is the only option, it might not be feasible out of the box. Please let me know if you cannot use MQTT integration, and I will explore potential workarounds, although these may involve security or performance considerations.

Let me know your preference.

akseerali commented 8 months ago

Hi @volodymyr-babak

We have a particular use case where we want to use the MQTT gateway API approach.

Would it be possible to trigger a device-connected event from the rule chain manually for a specific device at the edge? We can use a script node to match the source address of the incoming message and generate a device-connected event to resolve the issue.

volodymyr-babak commented 8 months ago

As an option, you can employ an external rule node, such as HTTP or MQTT, to send a message from the TB Edge rule chain to the HTTP or MQTT device API within the same TB Edge instance. For generating the device API message, you can utilize a script node, as you indicated. To simulate device activity, you can transmit a dummy payload, particularly since timeseries data is already stored in the flow via the MQTT Gateway API.