# Reading Tag Alarm state and append to DataSet

**URL:** <https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595>\
**Category:** Ignition\
**Created:** [February 19, 2025, 9:14pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595 "2025-02-19T21:14:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganesan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Ganesan](https://forum.inductiveautomation.com/u/Ganesan)\
**Post date:** [February 19, 2025, 9:14pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/1 "2025-02-19T21:14:04Z")

</div>

Dear All,

I am attempting to append the tag alarm state to the dataSet. However, I am encountering an error message **'com.inductiveautomation.ignition.common.alarming.AlarmStateTransition'** object is not iterable

I have successfully read the alarm state of all the tags. I need to append their status to the Status column as per the attached image. Could someone kindly provide guidance on how to proceed?

Thank you

```python
storeData = []
copyData = event.source.parent.getComponent('copyData').data
print copyData

for row in range(copyData.getRowCount()): 
	tagPath = copyData.getValueAt(row, "TagName")
	configTagPath = tagPath+"/ATestMem/A/Alarms/Test Alarm A.EventState"
	configValue=system.tag.readBlocking(configTagPath)
	alarmstate = configValue[0].value
	print alarmstate
	

headers = ['TagName', 'status']
testData = []
for row in range(copyData.getRowCount()):
	testData.append([copyData.getValueAt(row, "TagName") for column in range(copyData.getColumnCount())])
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(headers, testData)

```

 ![Script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/56e645c7d70c18f858f3cbbb043ce0d4008e1707.jpeg)

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [February 19, 2025, 9:40pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/2 "2025-02-19T21:40:46Z")

</div>

Can you try this and see if it works? If it doesn't work, can you show the complete error message?

```python
tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
tagValues = system.tag.readBlocking(tagPaths)
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue.value)] for tagPath,tagValue in zip(tagPaths,system.tag.readBlocking(tagPaths))])

```

---

<div class="post-metadata">

**Author:** ![Ganesan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Ganesan](https://forum.inductiveautomation.com/u/Ganesan)\
**Post date:** [February 20, 2025, 12:18pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/3 "2025-02-20T12:18:13Z")

</div>

Hi,  
Its working nice. thank you.

Just want to know that; Is there an any way only shows the ''Active'' state? I don't want to display ''clear'' state

Thanks in Advance.

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [February 20, 2025, 12:19pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/4 "2025-02-20T12:19:46Z")

</div>

What do you want to show when the value isn't "Active"? Just leave it empty?

---

<div class="post-metadata">

**Author:** ![Ganesan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Ganesan](https://forum.inductiveautomation.com/u/Ganesan)\
**Post date:** [February 20, 2025, 12:25pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/5 "2025-02-20T12:25:18Z")

</div>

Power table will be disappear if alarm state in not active.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 21, 2025, 1:12pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/6 "2025-02-21T13:12:06Z")

</div>

I modified @leonardo.godoi's script to:

- only read the tags once.
- only return rows with an 'Active' state.

You can then bind the visibility property to an expression:  
`len({Root Container.storeData.data}) > 0`

```python
tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
tagValues = [tag.value for tag in system.tag.readBlocking(tagPaths)]
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue)] for tagPath,tagValue in zip(tagPaths,tagValues) if tagValue == 'Active'])

```

---

<div class="post-metadata">

**Author:** ![Ganesan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Ganesan](https://forum.inductiveautomation.com/u/Ganesan)\
**Post date:** [March 11, 2025, 6:59pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/7 "2025-03-11T18:59:39Z")

</div>

I have tried this code but it not fetching any data to power table.

```python
tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
tagValues = [tag.value for tag in system.tag.readBlocking(tagPaths)]
event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue)] for tagPath,tagValue in zip(tagPaths,tagValues) if tagValue == 'Active'])

```

Therefore I removed the below condition then code fetches all the active and clear alarm state. But I am interested only to show active state.

```python
if tagValue == 'Active'

```

```python
if event.propertyName == 'name':

	tagPaths = [tagPath + "/ATestMem/A/Alarms/Test Alarm A.EventState" for tagPath in event.source.parent.getComponent('copyData').data.getColumnAsList(0)]
	tagValues = [tag.value for tag in system.tag.readBlocking(tagPaths)]
	event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue)] for tagPath,tagValue in zip(tagPaths,tagValues)])

```

 ![Screenshot 2025-03-11 at 18.50.08](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/d/adbc96c2afbd1f96230ab11ea19cc1e552950b95.jpeg)

Any suggestion in this subject highly appreciable.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 11, 2025, 7:18pm UTC](https://forum.inductiveautomation.com/t/reading-tag-alarm-state-and-append-to-dataset/102595/8 "2025-03-11T19:18:06Z")

</div>

Try using an if clause in the list comprehension

> [@JordanCClark](#):
>
> ```python
> event.source.parent.getComponent('storeData').data = system.dataset.toDataSet(['TagName','status'],[[tagPath,str(tagValue)] for tagPath,tagValue in zip(tagPaths,tagValues) if tagValue == 'Active'])
> 
> ```
