Preventing multiple notifications from sending (analysis/action)

Hi there.

Whenever our devices is triggered, it sometimes updates a specific variable to a value such as true and will remain so until changed. When this device is triggered again that has the same value, it will keep sending notifications. How do we lock the analysis or action from sending multiple notifications. I believe you have that for single devices in the action, but this one uses multiple devices.

Thanks!
Daniel

hi @daniel,

If I got right, you need to send the notification one time until the device is back to normal.

Basically, you need to develop a control solution to your alert, in my opinion,
the better solution is using device configuration parameters.

So, every time that your action is triggered and run the analysis to send the notification alert. You need to set a parameter in your device with the option read as true. And the next time the alert is triggered if the parameter is true, you will know that the alert is already sent.
SDK documentation to manage device parameters: Devices | TagoIO SDK for JavaScript and TypeScript
e.g:

 // getting parameters of the device
  const params = await device_dev.getParameters();
  // finding parameter with key "alert_type" and value "temperature"
  const fail_param = params.find((p) => p.key === "alert_type" && p.value === "temperature");
  // if this param exists or sent equal true. It mains that the alert is already sent.
  if (fail_param && fail_param.sent) {
    throw "Alert already sent";
  }

  // if alert is not sent yet. Set the param and continue running alert.
  const set_fail_param = { sent: true, key: "alert_type", value: "temperature" };
  await account.devices.paramSet(device_id, set_fail_param);
  // continue script to send alert...

Let me know if it helps you.

Hi eger,

Thanks for the help, I will take a look at it and follow up on it.

Thanks!
Daniel

1 Like