Expose all properties of a tag
b
brandon
I would be nice to directly read any property configured on a tag with system.tag.read().
For instance, using system.tag.read(["[default]tag/Alarms/High.setpointA"])[0].value to get the alarm limit of a specific alarm configured on a tag. I would also like to be able to directly write this property to set a new alarm limit.
Log In
K
Keith Gamble
Can you not use system.tag.getConfiguration() and then parse through the returned JSON for whatever you want? Then after you have that JSON you can edit it and run system.tag.configure() and overwrite the existing configuration with your newly edited one
b
brandon
Keith Gamble: Yes. But I find that so much more cumbersome than just having it as a dot-field on the tag. Plus if it was a read/write dot-field, we could use it directly as bindings on components.
p
pramanj2013
brandon: in 8.0, atleast you have a way to access this property, but for older versions 7.9 etc don't know whats the alternative
K
Keith Gamble
pramanj2013: I havent 100% tested out every scenario with this, and obviously this isnt as clean as system.tag.getConfiguration(), however you are able to browse the alarm properties of each alarm to grab the setpoint, and then manually set it with system.tag.editAlarmConfig() . I just tested this on an 7.9.9 gateway and it should do what you're looking for!
tagpath = "ExampleTag"
#Get the existing setpoint value
alarms = system.tag.getAlarmStates(tagpath)
#For each alarm associated with that tag
for a in alarms:
#Check the list of alarm properties
props = a.getAlarmProperties()
#Check each property
for p in props:
#If the property name is setpoint, for a limit you may have setpointA and setpointB
#will need to do some testing on your own to determine that part
if 'setpointa' in p.property.lower():
#Grab the current value and set it to your variable
currentSPValue = p.value
#Create a new setpoint value
newSPValue = not currentSPValue
#define your new alarm config for an alarm named "Test Alarm" (Could use same name if just editing the existing alarm)
alarmConfig = {"Test Alarm":[["setpointA","Value",str(newSPValue)]]}
#write your new alarmConfig to a list of tags
system.tag.editAlarmConfig([tagpath], alarmConfig)
Note: I recognize this isnt as easy as a .Property as described above, this is just a solution to @pramanj2013's problem in 7.9