Skip to main content
13-Aquamarine
March 23, 2024
Solved

How to pass one thing properties, services,, subscription to the another thing.

  • March 23, 2024
  • 2 replies
  • 2831 views

Hi Developers,

 

In my use case I have t1 and t2 thing.  I want to pass all t1 Thing  properties, services and subscriptions to the t2 Thing. Is it possible? If yes then how can we do this?

 

Thanks.

Best answer by Rocko

Not sure what you'r trying to do here, but have you thought about using a common ThingTemplate for that? You create the properties and services in a ThingTemplate, and then when you run CreateThing instead of passing GenericThing you pass your ThingTemplate and the new Thing will inherit all properties and services of the template.

This is a much more robust approach, and the purpose of thing templates.

 

If you're on your thing t1, in Composer in the "More" dropdown you will even have a "Create ThingTemplate" option to support you with the process.

2 replies

17-Peridot
March 24, 2024

What do you mean pass?

 

If you want pass the property values, you can use the local bindings or Services

Or you can duplicate the t1 and rename into t2.

 

Explain your usecase further...

Rocko
19-Tanzanite
March 25, 2024

If you mean copy over property and service definitions, you can do that manually in the Composer, but this is very tedious.

I've seen a Helper around which copies services from one entity to another, so you could write yourself a tool for that if you have that use case more often. The fastest, but also a bit fragile way if not done correctly is to export the things to XML, manually copy over the definitions in question and then import again.

 

13-Aquamarine
March 26, 2024

Hi @Rocko 

 

Thanks for your replay....

 

As you said yes we can do by using that method. 

In my usecase I created a thing by  using a createThing service which I pass  input parameter like:-

 

 

 
Pratik_A_1-1711428219112.pngPratik_A_0-1711428115284.png
Now, Thing is created successfully. In That blank thing I wanted to add same properties, subscriptions and services which I have already another one thing. So whenever we create a new thing by using createThing service can we also add or pass  properties, subscriptions and services to that newly created thing at the same time or in same service ?
 

 

Rocko
Rocko19-TanzaniteAnswer
19-Tanzanite
March 26, 2024

Not sure what you'r trying to do here, but have you thought about using a common ThingTemplate for that? You create the properties and services in a ThingTemplate, and then when you run CreateThing instead of passing GenericThing you pass your ThingTemplate and the new Thing will inherit all properties and services of the template.

This is a much more robust approach, and the purpose of thing templates.

 

If you're on your thing t1, in Composer in the "More" dropdown you will even have a "Create ThingTemplate" option to support you with the process.