Dropdown list of user created drivers?

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?

Thanks

More thinking out loud...

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.

Thanks

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"])

def setVersion(){
    state.appName = "AppWatchdog2DriverVersion"
	state.version = "v2.0.0"
    
    awInfo = "${state.appName}:${state.version}"
    
    if(awDevice) { awDevice.sendAWinfoMap(awInfo) }
    
}

Can you post the sendAWinfoMap() method of the driver. Is it expecting the parameter to be a string or a map?

It's a string...

attribute "sendAWinfoMap", "string"
        attribute "appTile", "string"
        
        command "sendAWinfoMap", ["Text"]
        command "sendDataMap", ["Text"]


def sendAWinfoMap(appWatchdogData) {
    if(logEnable) log.debug "In sendAWinfo (${state.version})"
    
	def newData = "${appWatchdogData}"
    if(logEnable) log.debug "In sendAWinfo - Incoming Data - ${newData}"

    if(state.theDataMap == null || state.theDataMap == "") {
        if(logEnable) log.debug "In sendAWinfoMap - Resesting theDataMap"
        state.theDataMap = [:]
    }
    
    def (dataKey, dataValue) = newData.split(':')
    if(logEnable) log.debug "In sendAWinfoMap - dataKey: ${dataKey} - dataValue: ${dataValue}"
    state.theDataMap.put(dataKey, dataValue)
    
    def allMap = state.theDataMap.collectEntries{ [(it.key):(it.value)] }
    
    allMapSize = allMap.size()
    if(logEnable) log.debug "In sendAWinfoMap - mapSize: ${allMapSize} - allMap: ${allMap}"
    
    sendEvent(name: "sendAWinfoMap", value: allMap, displayed: true)
}

Is this line 50?

def newData = "${appWatchdogData}"

Nope, this is ...

if(awDevice) { awDevice.sendAWinfoMap(awInfo) }

Thanks

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

I didn't think we could do that in a driver?

Ahhh...I thought the setVersion() section was part of the app code.
Any reason you don't do this from the main app instead?

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?

thanks

Hah, I read it before you deleted it! lol

1 Like

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.

Makes sense, I keep trying to think outside the box and hopefully come up with something.

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.

You tagged me, but I'm completely lost on what is trying to be accomplished here. If we are just talking about the original question:

The answer is no.

@chuck.schwer, I was referring to this question.