# How to derive the tag path from an alarm event

**URL:** <https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [August 9, 2023, 8:29pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664 "2023-08-09T20:29:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![David.Reed.Schmidt](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@David.Reed.Schmidt](https://forum.inductiveautomation.com/u/David.Reed.Schmidt)\
**Post date:** [August 9, 2023, 8:29pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664/1 "2023-08-09T20:29:57Z")

</div>

Given an alarm event object. Is there a way to obtain the tag path from that alarm. My alarm comes from a tag and I can get the 'source' property and this has the tag provider and the alarm name. I simply want the tag path for example '[default]My Tag' instead of 'prov:default/tag:My Tag/alarm:Test Alarm'

---

<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:** [August 9, 2023, 8:34pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664/2 "2023-08-09T20:34:17Z")

</div>

The source is a [`QualifiedPath`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.30/com/inductiveautomation/ignition/common/QualifiedPath.html) object which has various structured mechanisms to extract data.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 9, 2023, 8:38pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664/3 "2023-08-09T20:38:01Z")

</div>

toStringSimple, perhaps?

---

<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:** [August 9, 2023, 8:46pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664/4 "2023-08-09T20:46:06Z")

</div>

Probably the simplest that gives you the representation you're looking for:

```auto
from com.inductiveautomation.ignition.common import QualifiedPathUtils
tagPath = QualifiedPathUtils.toTagPathNew(alarmEvent.getSource()).toStringFull()

```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 25, 2024, 11:21pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664/5 "2024-09-25T23:21:48Z")

</div>

Hi Paul, I just tried this:

```python
from com.inductiveautomation.ignition.common import QualifiedPathUtils, QualifiedPath
tagpath = 'prov:default:/tag:Area A/Device 01/Level:/alm:High Alarm'
qp = QualifiedPath.parse(tagpath)
QualifiedPathUtils.toTagPathNew(qp).toStringFull()

```

and the result is:

```python
u'[default]Area A/Device 01/Level'

```

But my expected result is:

```python
u'[default]Area A/Device 01/Level/Alarms/High Alarm'

```

As this is the actual tagpath to that alarm, if you copy it from the tag browser  
How would I produce that instead?

Also, is there any way to read/write the value of tags given a QualifiedPath object like above without converting to a string path?

---

<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:** [September 25, 2024, 11:44pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664/6 "2024-09-25T23:44:15Z")

</div>

> [@nminchin](#):
>
> How would I produce that instead?

Best I can do on short notice:

```python
from com.inductiveautomation.ignition.common import QualifiedPathUtils, QualifiedPath, WellKnownPathTypes
from com.inductiveautomation.ignition.common.tags.config.properties import WellKnownTagProps

tagpath = 'prov:default:/tag:Area A/Device 01/Level:/alm:High Alarm'
qp = QualifiedPath.parse(tagpath)
tp = QualifiedPathUtils.toTagPathNew(qp)

alarm = qp.getPathComponent(WellKnownPathTypes.Alarm)
if alarm is not None:
	tp = tp.getChildPath("Alarms").getChildPath(alarm)

print tp.toStringFull()

```

> [@nminchin](#):
>
> Also, is there any way to read/write the value of tags given a QualifiedPath object like above without converting to a string path?

The underlying APIs can accept TagPaths, but there's no (easy-ish) ways to access or consume them from scripting.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [September 25, 2024, 11:51pm UTC](https://forum.inductiveautomation.com/t/how-to-derive-the-tag-path-from-an-alarm-event/77664/7 "2024-09-25T23:51:29Z")

</div>

Ok cool, that works, cheers 🙂

Minor correction to the import:  
`from com.inductiveautomation.ignition.common import WellKnownPathTypes`
