Skip to main content
1-Visitor
April 30, 2018
Solved

How to create a subscription on a thing from within a script

  • April 30, 2018
  • 1 reply
  • 1873 views

Hello everyone, 

i want do add a subscription to a Thing from within a script but i don't seem to be able to do so. I have tried using EnableSubscription which is not what i'm looking for since it simply activates or disables an already existing subscription. I have also tried using AddDynamicSubscription but this subscription is only in-memory which is not what i want. Is there any way to just add a subscription to a thing from a script like you would when using the editor?

 

Thanks in advance!

Best answer by PaiChung

Right now you can't use a script to create a persistent subscription.

Is there a reason why you need to create it dynamically?

What you can create persistently is Alerts so if you have standard handling, you can create alerts into a AnyAlert subscription.

If they have to be dynamic, then you will need to 

1. create them on demand

2. store the ones that you've created so they can be recreated during ThingStart

1 reply

PaiChung22-Sapphire IAnswer
22-Sapphire I
April 30, 2018

Right now you can't use a script to create a persistent subscription.

Is there a reason why you need to create it dynamically?

What you can create persistently is Alerts so if you have standard handling, you can create alerts into a AnyAlert subscription.

If they have to be dynamic, then you will need to 

1. create them on demand

2. store the ones that you've created so they can be recreated during ThingStart