How to write to Canary from Ignition using script
Hi,
I am trying to write to Canary using the following code but it is not being written into and Ignition is also not throwing an error, can somoen help.
Not sure where I am going wrong, I have tried all 4 path formats but to no avail.
historyprovider = "provider"
tagprovider = "default"
paths = ["1000/001/NV/0001/PCS/PCS001/INV1/CMB_01/CMB_Wp"]
#paths = ["[S_Test/default:default]1000/001/NV/0001/PCS/PCS001/INV1/CMB_01/CMB_Wp"]
#paths = ["[S_Test/default:default]Stellar_Test/1000/001/NV/0001/PCS/PCS001/INV1/CMB_01/CMB_Wp"]
#paths = ["[S_Test/default:default]Site_Data/1000/001/NV/0001/PCS001/INV1_CMB_01/CMB_Wp"]
values = [245280]
qualities = [192]
ts = system.date.parse("2019-01-01 00:00:00","YYYY-MM-dd HH:mm:ss")
timestamps = [ts]
system.tag.storeTagHistory(historyprovider,tagprovider,paths, values, qualities, timestamps)
Thanks in advance
10 replies
-
Hey derrickdvdsn ,
It looks like you are storing everything at the static timestamp "2019-01-01 00:00:00", is that correct?
-
With the help of IA support I was finally able to get this to work. The "paths" must be the Ignition path, not the path that Canary uses when providing data back to Ignition, which is "[CanaryProvider/default:default]...". And even though we only act as a historical provider, a realtime provider is still needed in the function. Here is the script I ended up using:
historyprovider = "Local Ignition" tagprovider = "Sample" paths = ["Random/RandomInteger2"] values = [8] qualities = [192] date = system.date.getDate(2023, 10, 16) histDate = system.date.setTime(date, 10, 02, 44) dates = [histDate] system.tag.storeTagHistory("Local Ignition",tagprovider,paths,values,qualities,dates)
"Local Ignition" is the collector I have configured in my module. "Sample" is the realtime provider, but it doesn't actually exist. The "paths" are those as they appear in the Ignition schema.
I used this as a reference: https://docs.inductiveautomation.com/display/DOC81/system.tag.storeTagHistory