fcwilt
April 18, 2023, 4:21pm
1
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
fcwilt
April 19, 2023, 1:37am
4
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:
/**
* Presence URLs
*
* Copyright 2022 Michael Pierce
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
String getVersionNum() { return "2.0.1" }
String getVersionLabel() { return "Presence URLs, version ${getVersionNum()} on ${getPlatform()}" }
#include mikee385.debug-library
This file has been truncated. show original
Or this one:
/**
* Virtual Garage Door
*
* Copyright 2023 Michael Pierce
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
String getVersionNum() { return "1.0.0" }
String getVersionLabel() { return "Virtual Garage Door, version ${getVersionNum()} on ${getPlatform()}" }
#include mikee385.debug-library
This file has been truncated. show original
fcwilt
April 19, 2023, 2:33am
6
Thanks.
I have a better understanding of how it is done.
Now to try it.
Frederick
system
Closed
April 18, 2024, 2:33am
7
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.