When creating a new device there is a drop down box with all the available drivers in it. Is there anyway to duplicate this in an app? Specifically would like to have a drop down of just the user created drivers. And if this is possible, could I query the version from it?
is there a way to send the version (or any data) from the driver to a device, like we can from an app?
ie. awDevice.sendAWinfoMap(awInfo)
I get this error:
2019-08-21 05:47:32.922 pm errorgroovy.lang.MissingMethodException: No signature of method: java.lang.String.sendAWinfoMap() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [AppWatchdog2DriverVersion:v2.0.0] on line 50 (sendAWinfoMap)
Are you just trying to get the version of the driver a devices is using?
If so, there are many ways to do this and you can look at most of my driver's. See my Join driver below.
I include something like this at the top of the code...so it's easy to find and update as needed. def version() {"v1.2.3"}
You could then include a method to return that value at will eg
def getVersion() {
return version()
}
Then in any app you can do a device.getVersion() ...this would return the string "v1.2.3".
I also save the version to a state variable so it can be seen when viewing the device page.
No, I'm trying to 'send' the version to another device. This is for my App Watchdog app. Each of my apps 'sends' the version data to a device for storage. The device adds all the different apps/versions into a map, App Watchdog then takes this data and compares it with Github. Works great for apps but drivers don't seem to have the same ability to 'send' the info anywhere.
Just curious..why would you send the version data to a device instead of just storing it in the app itself? I'll probably have to look at you Watchdog app to understand the logic flow.
This is what I'm trying to do in the driver, again it works great in an app. This should look familiar to you @stephack, I was actually looking at how you added names into your Virtual Container driver, very interesting.
input("awDevice", "enum", title: "Device to send Version to", options: ["App Watchdog Data"])
I just noticed this line because it wasn't in the code section.
awDevice would need to an actual device selection. In your input, it's actually just text. Essentially you are trying to send a command from a string instead of a device.
The input would need to be a device type ... eg capability.switch...etc
lol, too confusing! Basically I just need to be able to pull the version info from the driver at will so I can compare it to Github. Anyway that you know of to do that? Not a device using it but from the actual driver itself?
Yeah...I just got that..I can be a bit dense sometimes. I don't think it's possible but @chuck.schwer could confirm.
I believe you can query a device for it's version but I don't believe it's possible to check driver code without actually selecting a device that is using said code.
Only thing I can think of off the top would be to have the user select at least one device from every "type" of device that needs to be kept up to date. Then you could have the app issue the sendAWinfoMap command to those devices on a schedule. Sounds painful, but may be doable...I havent really thought it through though.
Do you have a list of "supported" drivers that you maintain?
You could create one input for every supported type and the user could just add an existing device using that driver. If they don't have a device using it, then I doubt they would care if it's up to date or not.
You could narrow down the input selection for each by specifying the driver name in the input type. For example, if Virtual Containers were supported your input would look something like:
input("vcDevice", "device.VirtualContainer", title: "Select a Virtual Container device")
In the above, only Virtual Container devices would be listed.