Use device in app without input statement

I am coding an app using a device I have coded.

Currently to get the device "into" the app I am using this:

input(name: "d_telnet" , type: "capability.telnet" , title: "use telnet..." , description: "", required: true)

And that works fine.

But is there any code I can put into the app to obtain the device without using an input?

And is there a way to create in the app multiple instances of the one device OR do I have to manually add the device multiple times in Devices?

Thanks, Frederick

There isn't a function like this available for user apps. This is a security issue to prevent a bad actor from exporting all your devices without your knowledge.

1 Like

If the app owns the device, you can have the app create a child device (or multiple child devices), and then you’ll have complete control over them, without requiring any user input.

There doesn’t appear to be any dedicated documentation for it, but the methods can be found on the App Object page:

See addChildDevice, getChildDevices, deleteChildDevice, etc.

1 Like

Thanks.

What determines if an app owns a device?

Does using "input" to select a device do that?

Thanks, Frederick

The app owns the devices created using addChildDevice, but not the ones selected using "input".

I don’t have a great standalone example of an app using child devices, but if it helps, I think the closest ones are I have are either this one:

Or this one:

Thanks.

I have a better understanding of how it is done.

Now to try it.

Frederick

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.