I set up a Tasmota Smart Plug using MQTT.
Works fine.
So I bought 4 more.
Since its quite a lot of work to set them up, I was wondering, if there is a way to copy the thing and change the name.
I did that with the thing code. So far thats a success, but I didn’t find a way to copy also the items linked to the channel.
Copy the YAML you find there to the clipboard after “label” (the second line)
Create a new Generic MQTT Thing
Open the “Code” tab for the newly configured Thing and paste the contents over everything after “label”.
Modify what ever needs to be modified.
You could also use the API Explorer.
Query for the example Thing. Copy the JSON you get back.
Got to the create Thing endpoint and paste the JSON into the body.
Make what ever edits you need (don’t forget to at least change the UUID).
POST the modified JSON.
Repeat the edit and POST steps for each subsequent Thing.
Using the API Explorer can be a bit faster as there is less clicking around. However the JSON is a little harder to read and understand. You’ll have to decide which is more of a pain.
Yeah, I guess I wasn’t clear.
I did it that first way. Just created a new thing with just an UID and then past the “code” into it and changed the names of the chanels.
Thats ok, but I didn’t figure out how to copy the things items.
Since the Smart Plug has 10 channels/Items I would love to copy that as well.
I just had a quick look at the API Explorer.
Am I right, that I can query the things items? I will get the response with all items code. Then I change the code according to the new thing and “post” it?
This will create the new items under the new thing?
Items are not Things. They are their own thing (pun intended).
The easiest thing to do would be to use “Add equipment to model” or “Add points to model” from the Channels tab. That will let you create Items automatically linked to the Channels you choose.
No, Items are independent entities and their only association with the Thing is the ItemChannelLink.
Well, I think I get the concept of Things and Items and Channels.
My question is: how to duplicate the things’s items (channel links)
Thing1
channel1.1
item1.1
channel1.2
item1.2
Thing2
channel2.1
item2.1
channel2.2
item2.2
I am able to copy the thing and it’s channel, but still have to make a manual link and create each item.
If I have 100 Things of the same kind, I want to copy also the links and and change a suffix to make it unique.
The easiest would be to copy the Things and then use “add equipment to model” to create the Items linked to the new Thing. Just about anything else is going to just as much if not more work than that.
To duplicate the Things though you can:
Create the first Thing
Open the code tab and copy the YAML you find there
Create a new Thing
Open the code tab and paste the YAML there, edit as necessary
Alternatively:
Create the first Thing
Go to Developer Tools → API Explorer → things
Query for the Thing created in 1, copy the JSON returned
Open the “create thing” endpoint, paste in the JSON, edit as necessary (be sure to change the UID) and submit