Update child device driver programmatically?

Hello everyone,
I have created an app that allows you to group different devices together and based on their capabilities determines the best driver to use and creates a child device with that driver. Works great when you first create the group. However let's say you want to go back in and remove or add devices and the capabilities change, is there any way to programmatically update the child device to change the driver it's using? Right now I am deleting the old child and creating a new one, but this can have it's challenges if it's in use by a rule or other app. I am sure there has to be a better way.

That’s an interesting question. I am tagging @chuck.schwer as he’ll know whether or not it is possible to change the driver of a child device programmatically.

1 Like

Cool thanks!

Currently there isn't a way of doing this, it's on our internal wish list.

2 Likes

Well that's too bad, but I figured as much. I spent a few hours searching the web. I found the getter, but no setter. Put me down for a vote for this feature, this could led to some really cool and smart apps. I think for now I will add a couple attributes to the driver to notify the user if a better driver fits their application. I'll play around with it to see what I can come up with. Unless anyone has a better solution, I am all ears.

Thanks for the quick response guys!

@Cobra has a nice method in most (if not all) of his drivers (that I have reused in all my drivers) to check the current driver version against a Json file on his server (I use XML to check mine) then provide an event whether there is an update available.

1 Like

I'll have to check that out. I use something similar to that at work to keep my scripts update. So when a tech runs them it first checks to make sure it the most recent and auto updates if not. Now you say create an event, but you still have to manually update right?

Yes, it is just an event notification, not an automatic update like you are looking for. So at least a user can know that there is a newer version available. Still have to manually import or otherwise obtain the new driver, but "knowing is half the battle".

1 Like

The original code is here:

Andy

1 Like

Thanks guys, I was just looking at your Super Tiles app when @snell tagged you. I have looked over your suggestions and it's a bit of over kill for my use case. I have an app that has multiple drivers and based the devices capabilities choose the best driver. If you add or remove devices and that driver is no longer relevant then I need to notify the user. I can do this all internally with attributes. All drivers will work, they just won't have the capabilities or have control they don't need. That should work till they release the ability to update a driver for a child or I get a little more creative. Thanks for all of your input and I will stash that away for future reference. It may come in handy later on down the road.
John

digging your own grave GIF

Has anything changed here? I presume not from looking at the dev docs, but never hurts to ask I suppose.

1 Like

Download the Hubitat app