Skip to main content
1-Visitor
May 19, 2017
Solved

How to retrieve name of a thing by specifying ID and accessing its properties

  • May 19, 2017
  • 8 replies
  • 4593 views

Good morning!

I have created  a few Things which inherit the properties from a ThingTemplate which holds a property Identifier string and another property for temperature.

In addition, I have created a helper thing to create a static service. This service gets two inputs: an identifier string and the temperature.

The service should retrieve the name of the thing which holds the same identifier string and should update the temperature property.

I have already found a function which seems to be made for that. It is called GetThingNameForIdentifier(identifier) and returns a THINGNAME.

But I haven't found anything on the internet on how to use this datatype and how to access the thing's properties.

Any suggestions?

Thank you in advance for your help

Theresa~

    Best answer by ankigupta

    Hi Theresa Lichtenberger​

    Please try:

    Things[THINGNAME].temperature= temperature;

    8 replies

    ankigupta5-Regular MemberAnswer
    5-Regular Member
    May 19, 2017

    Hi Theresa Lichtenberger​

    Please try:

    Things[THINGNAME].temperature= temperature;

    1-Visitor
    May 19, 2017

    hi Ankit Gupta​,

    and how do I use the GetThingnameByIdentifier(identifier) function?

    Is it like this or am I doing anything wrong:


    var params = {
    identifier: ID/* STRING: ID is the property Name of the Thing */
    };

    // result: THINGNAME
    var thingname = Resources["EntityServices"].GetThingNameForIdentifier(params);

    Things[thingname].temperature= temperature;

    thank you again for your help!

    1-Visitor
    May 19, 2017

    because if I test my service I get a the following error:

    TypeError: Cannot set property "temperature" of null to "40"