Skip to main content
1-Visitor
June 27, 2016
Solved

Create n things, remote things and bind properties by code

  • June 27, 2016
  • 1 reply
  • 3206 views

Is it possible (and, if so, how) to create things and remote things by code?

I have thing template "SimulationTemplate" which has 3 properties: Prop1, Prop2, Prop3
I want 25 things called "Simulation-TH_1"... "Simulation-TH_25" and 25 remote things "Simulation-RT_1"..."Simulation-RT_25" and I want the properties to be bind.

How can I do this by code instead of doing it one by one?

Best answer by CarlesColl

Yes it's possible.

To create things:

Resources["EntityServices"].CreateThing({ name:, description:, thingTemplateName:,tags:});

To Bind remote properties:

me.SetRemotePropertyBinding({...});

To Bind local properties:

me.SetLocalPropertyBinding({...});

1 reply

1-Visitor
June 27, 2016

Yes it's possible.

To create things:

Resources["EntityServices"].CreateThing({ name:, description:, thingTemplateName:,tags:});

To Bind remote properties:

me.SetRemotePropertyBinding({...});

To Bind local properties:

me.SetLocalPropertyBinding({...});

fmanniti1-VisitorAuthor
1-Visitor
June 28, 2016

Thank you.
And what about for duplicate?
If I want to duplicate 50 times my Thing called TH1 to "TH2"..."TH50" is it possible to do it by code?
Because I've seen CloneThings but it doesn't seem to work

1-Visitor
June 28, 2016

For this, CloneThing should do the trick, but I never used it ( I don't like Copy&Paste when programing )