how can a thing Enable it's own subscription via a service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
how can a thing Enable it's own subscription via a service
Hi,
I have a thingshape that has 2 subscriptions.
- a DataChange subscription to one of its own properties
- a subscription to the timer event of a separate timer thing. By default this subscription is disabled.
I would like to enable the second subscription from within the first. I have tried to use the service EnableSubscription
var subParams = {
propertyName: undefined /* STRING */,
thingName: "RemoteTimerThing" /* THINGNAME */,
eventName: "Timer" /* STRING */
};
me.EnableSubscription(subParams);
This fails as it says it 'Cannot Update A Subscription That Does Not Exist'. Originally I thought it was a permissions issue and so changed the permissions, but it still failed. I have also tried running this service directly from within the composer (as an administrator) using the Test button and it also fails. Now I'm thinking it isn't a permissions issue at all, but maybe there is something wrong with my service call above.
If I manually enable the service via the checkbox it all works fine.
Does anyone know how to enable a thing's own subscription from within it's one of it's own services?
Thanks,
K
- Labels:
-
Coding
- Tags:
- subscriptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I tested here and worked fine:
var params = { propertyName: undefined /* STRING */, thingName: "TIMER60s" /* THINGNAME OF THE SOURCE OF THE SUBSCRIPTION*/, eventName: "Timer" /* STRING OF THE NAME OF THE EVENT OF THE SUBSCRIPTION */ }; me.EnableSubscription(params);
Using data change:
var params = { propertyName: "value1" /* STRING */, thingName: me.name /* THINGNAME */, eventName: "DataChange" /* STRING */ }; me.EnableSubscription(params);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
thanks for the reply. Not sure what is happening with mine as it still doesn't work. I have incorporated a work around by using a dynamic subscription to a timer event run in Administator context. Not ideal but at least it works.
Thanks again for the reply.
K