Skip to main content
1-Visitor
November 24, 2016
Solved

[Subscription] Enable Subscription

  • November 24, 2016
  • 2 replies
  • 3802 views

Hi guys,

I try to deploy an application which display the information from a weather station. Currently, I access the data via an API using token & credentials. I have three services, one for get access token, one for have new token with a refresh token and one other to access the data. I need to launch the services at specifics timeloop.

So I create a subscription to Thingstart event to launch my first service. I also create two others subscriptions which bind two differents timers to launch my services, they are basically disable.

I want to add at my first subscription (Thingstart event) an enable subscription method to enable my other service when I launch my thing. Badly it don't recognize it :


"Error processing local event: Execution error in service script [QAI_netatmoConnector ThingStart] : ReferenceError: "QAI_Timer30S" not recognize (ThingStart#5)"


this is my first subscription:

// result: JSON

var result = me.GetAccessToken();

var params = {

  propertyName: QAI_Timer30S /* STRING */,

  thingName: undefined /* THINGNAME */,

  eventName: Timer /* STRING */

};

me.EnableSubscription(params);

any idea ?

Regards,

Guillaume

Best answer by ankigupta

Guillaume BEAUMONT​,

You are trying to enable a timer event subscription; so propertyName should remain undefined as there is no propertyName for timer event.

thingName is the name of the timer thing. Should be within Double Quotes.

eventName is name of the event which is "Timer".

So, your code should be something like:

var params = {

  propertyName: undefined /* STRING */,

  thingName: "QAI_Timer30S" /* THINGNAME */,

  eventName: "Timer" /* STRING */

};

 

me.EnableSubscription(params);

I hope it helps.

Thanks,

Ankit Gupta

2 replies

5-Regular Member
November 28, 2016

Hi Guillaume, the value for thingName is missing and have you tried this :

var params = {

  propertyName: "QAI_Timer30S" /* STRING */,

  thingName: "thingName" /* THINGNAME */,

  eventName: "Timer" /* STRING */

};

gbeaumont1-VisitorAuthor
1-Visitor
November 29, 2016

thanks for your answer

ankigupta5-Regular MemberAnswer
5-Regular Member
November 29, 2016

Guillaume BEAUMONT​,

You are trying to enable a timer event subscription; so propertyName should remain undefined as there is no propertyName for timer event.

thingName is the name of the timer thing. Should be within Double Quotes.

eventName is name of the event which is "Timer".

So, your code should be something like:

var params = {

  propertyName: undefined /* STRING */,

  thingName: "QAI_Timer30S" /* THINGNAME */,

  eventName: "Timer" /* STRING */

};

 

me.EnableSubscription(params);

I hope it helps.

Thanks,

Ankit Gupta

gbeaumont1-VisitorAuthor
1-Visitor
November 29, 2016

It works perfectly, thanks a lot !!