# Alarm Evaluation and Event Creation From Multiple Sensors and Devices at once

**URL:** <https://forums.losant.com/t/alarm-evaluation-and-event-creation-from-multiple-sensors-and-devices-at-once/5275>\
**Category:** Help\
**Tags:** workflow, events\
**Created:** [September 25, 2023, 7:11pm UTC](https://forums.losant.com/t/alarm-evaluation-and-event-creation-from-multiple-sensors-and-devices-at-once/5275 "2023-09-25T19:11:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amelia\_Evans](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@Amelia\_Evans](https://forums.losant.com/u/Amelia_Evans)\
**Post date:** [September 25, 2023, 7:11pm UTC](https://forums.losant.com/t/alarm-evaluation-and-event-creation-from-multiple-sensors-and-devices-at-once/5275/1 "2023-09-25T19:11:48Z")

</div>

Hi

I am trying to use the [Latching and Events workflow template](https://docs.losant.com/template-library/overview/) to create and auto resolve alarm events from multiple sensors on one device (30-40 alarm sensors per device). Is there an efficient way to do this? I have not done much with loops, but I am struggling to find a way to filter the attributes and perform an evaluation across all the attributes in the payload.

Thank you!

---

<div class="post-metadata">

**Author:** ![Sebastian\_Turner](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/sebastian_turner/32/4024_2.png) [@Sebastian\_Turner](https://forums.losant.com/u/Sebastian_Turner)\
**Post date:** [September 26, 2023, 2:37pm UTC](https://forums.losant.com/t/alarm-evaluation-and-event-creation-from-multiple-sensors-and-devices-at-once/5275/2 "2023-09-26T14:37:40Z")

</div>

Hi @Amelia_Evans and welcome to the Losant forums!

This can certainly be done by maintaining a separate workflow for each of the attributes from which you want to latch / create events, and that might be the easiest way to manage the varying logic you’d be using to evaluate each attribute.

However, let me see if I can come up with a single-workflow example that isn’t too convoluted. I’ll return to the this thread once I have an update.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Turner](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/sebastian_turner/32/4024_2.png) [@Sebastian\_Turner](https://forums.losant.com/u/Sebastian_Turner)\
**Post date:** [September 27, 2023, 9:49pm UTC](https://forums.losant.com/t/alarm-evaluation-and-event-creation-from-multiple-sensors-and-devices-at-once/5275/3 "2023-09-27T21:49:12Z")

</div>

@Amelia_Evans ,

I’ve created a proof-of-concept workflow based on the template you linked that utilizes a [loop](https://docs.losant.com/workflows/logic/loop/) to evaluate multiple attributes from a single device and create/resolve events. Feel free to [import](https://docs.losant.com/workflows/overview/#import--export) this workflow and see if it fits your needs.

[multiple-attribute-latching-and-events-develop.flow](https://forums.losant.com/uploads/short-url/34pd3S2JX4G2uG7AS2V6fi38uZ1.flow) (13.4 KB)

A few considerations:

- This example assumes that each device attribute being evaluated has two [device attribute tags](https://docs.losant.com/devices/attributes/#modifying-device-attributes) - `maxThreshold` and `resetThreshold`. You can, of course, modify the attribute tags that will be evaluated.

- The Virtual Button in this example simulates device state data, as well as device attribute tag values. If you set the `temperature` or `humidity` values in the Virtual Button to greater than the `maxThreshold` attribute tag values (in this example, `100` for `temperature` and `150` for `humidity`), the requisite events will be created. If you set these values to less than the `resetThreshold` attribute tag values (`70` for `temperature` and `125` for `humidity`), the events will resolve

- The loop will iterate over all attributes reported by the device. The same numerical comparison is employed when evaluating each attribute value and determining if an event should be created or resolved. If you need to evaluate certain numerical attributes differently, or if you’re evaluating different types of attributes (such as boolen or string attributes), you’ll need to add that logic into the workflow.

As always, please test before using this workflow in any sort of production capacity. Please let me know if you have any questions!

---

<div class="post-metadata">

**Author:** ![Amelia\_Evans](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@Amelia\_Evans](https://forums.losant.com/u/Amelia_Evans)\
**Post date:** [September 28, 2023, 2:56pm UTC](https://forums.losant.com/t/alarm-evaluation-and-event-creation-from-multiple-sensors-and-devices-at-once/5275/4 "2023-09-28T14:56:08Z")

</div>

Thank you so much! We were able to come up with something very similar but I think your solution will work great for looking at attributes dealing with larger numbers (ours were just changing from 0 to 1 and back). I’ll post ours in case someone else also has this question.
