# Trigger UDT alarm based on two UDT values

**URL:** <https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [February 15, 2024, 8:19pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791 "2024-02-15T20:19:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian.sebryk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ian.sebryk/32/49319_2.png) [@ian.sebryk](https://forum.inductiveautomation.com/u/ian.sebryk)\
**Post date:** [February 15, 2024, 8:19pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/1 "2024-02-15T20:19:21Z")

</div>

we have a device with a multifunction input. when in digital mode, it can sample 4-20mA (Hi/Lo) or it can count flow pulses. the kink is the device reports _either_ voltage OR the pulse count as a `float`; there is no discrete values for either one. just reports to MQTT as `value`. there **is** a boolean that determines this state: `isPulseCount` and a string that reports port type: `din` or `curr_mA`.

the alarm needs to be triggerable when the `isPulseCount` is `0` **AND** when port type is `din`. i flat out do not know how to set this up correctly. at present, this is what i have attempted in my UDT settings:

![Screenshot 2024-02-15 131529](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/1/f1247805c91dfbc88902614b60ee7aba688476ef.png)

i know this is wrong, because it's not really the setpoint i'm trying to configure here, but i had to build the expression somewhere. now, i am very new to building alarms themselves, so be gentle. 🫣 as i'm typing this, i don't think this is the even the right place to have this logic, but since it's tied to the UDT tag, i'm expecting some greater logic capability. can someone please guide me here?

EDIT: i think i found it. i can create a binding on the `Enabled` property and then just set the `Mode` to `Equal` and set the `Setpoint` value to `1`. am i correct?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 15, 2024, 8:23pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/2 "2024-02-15T20:23:41Z")

</div>

Make an expression tag that evaluates both source tags and yields the desired boolean. Then define the alarm on the expression.

---

<div class="post-metadata">

**Author:** ![ian.sebryk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ian.sebryk/32/49319_2.png) [@ian.sebryk](https://forum.inductiveautomation.com/u/ian.sebryk)\
**Post date:** [February 15, 2024, 8:24pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/3 "2024-02-15T20:24:55Z")

</div>

ooh! is that better than what i found?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 15, 2024, 8:31pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/4 "2024-02-15T20:31:41Z")

</div>

Yes, it's better, because bindings in tag definitions don't actually subscribe to other tags. They evaluate only on tag restart, or for alarm properties, only when the alarm fires. So once your binding disables the alarm, it'll never fire again, and therefore won't ever re-evaluate whether it should be enabled again.

Arguably, you could make a change event script on the portType tag **write** to the alarm enable property on the other tag.

---

<div class="post-metadata">

**Author:** ![ian.sebryk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ian.sebryk/32/49319_2.png) [@ian.sebryk](https://forum.inductiveautomation.com/u/ian.sebryk)\
**Post date:** [February 15, 2024, 8:40pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/5 "2024-02-15T20:40:03Z")

</div>

um, yeah. that's... uh... _ **way** _ better. 😛 i much prefer '_it works_' over '_it worked once and never again good luck debugging me you filthy casual_'.

---

<div class="post-metadata">

**Author:** ![ian.sebryk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ian.sebryk/32/49319_2.png) [@ian.sebryk](https://forum.inductiveautomation.com/u/ian.sebryk)\
**Post date:** [February 15, 2024, 9:00pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/6 "2024-02-15T21:00:41Z")

</div>

so this is what i built:

 ![Screenshot 2024-02-15 135840](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19f6429fe25a66ecef339ed4bc9343d7c431b9e0.png)

 ![Screenshot 2024-02-15 135815](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/2/a27bff45eccfb33c3c047fc5416430f890f2775c.png)

is that what you were talking about? from my understanding, when that expression evaluates to true, the alarm can then be triggered. otherwise, it will just function as 'usual'.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 15, 2024, 9:33pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/7 "2024-02-15T21:33:20Z")

</div>

Looks right. (Didn't do a deep dive.)

---

<div class="post-metadata">

**Author:** ![ian.sebryk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ian.sebryk/32/49319_2.png) [@ian.sebryk](https://forum.inductiveautomation.com/u/ian.sebryk)\
**Post date:** [February 16, 2024, 4:04pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/8 "2024-02-16T16:04:52Z")

</div>

works well, so thank you very much! 💯

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 16, 2024, 4:10pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/9 "2024-02-16T16:10:50Z")

</div>

This is a micro-optimization, but there's no point in an `if(condition, true, false)` in expressions, especially if the return value is boolean. By definition, the equality operator returns a boolean, and even if it didn't, the expression's output value would be coerced to a boolean by the tag system after it was evaluated.  
That is:  
`if(condition, true, false)`  
Is always a more verbose, _slightly_ less efficient way of writing:  
`condition`

---

<div class="post-metadata">

**Author:** ![ian.sebryk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ian.sebryk/32/49319_2.png) [@ian.sebryk](https://forum.inductiveautomation.com/u/ian.sebryk)\
**Post date:** [February 16, 2024, 4:25pm UTC](https://forum.inductiveautomation.com/t/trigger-udt-alarm-based-on-two-udt-values/85791/10 "2024-02-16T16:25:21Z")

</div>

i'm _always_ looking out for these kind of things. they satisfy an obscure itch deep in my nerd-brain. thank you! 👍

so just `{[.]portType} = 'din' && !{[.]isPulseCount}` will do the do. nice. 💯
