I am beginning to realize that there may have been misunderstanding all around about the driverSwitched lifecycle. I went back and re-read the doc on this topic and it clearly says (and maybe this was updated recently?) that this lifecycle is for when a device gets switched from one driver to another… NOT for when a driver is re-installed.
So if this documentation is correct, there really is no way for a driver to know when it is being reinstalled and there really is no lifecycle call associated with this type of event.
Currently we know that there is an info_changed lifecycle invoked when an updated driver is about to be installed. Then there is about a 10 second delay, and then the driver gets installed. However, there are some problems with this with the current firmware:
-
As discussed here earlier, there is no apparent device data change between what the old_st_store arg provides and the device table that can be tested that indicates that a driver update is about to happen. Perhaps adding the driver package version to the driver object would be useful in this case.
-
I have found that within the info_changed lifecycle handler, the values for device.driver.id, device.driver.name, and device.driver.type are strangely blank(!), even though they are present in args.old_st_store.driver.id, etc. This may be a bug, or there is some different way to access these values; the keys do exist in the device table, but the values are nil.
2021-11-10T18:02:53.106858075+00:00 DEBUG Test Driver 1 OLD device values:
2021-11-10T18:02:53.110340283+00:00 DEBUG Test Driver 1 device_network_id myTestDevice01
2021-11-10T18:02:53.113356825+00:00 DEBUG Test Driver 1 label Test Device
2021-11-10T18:02:53.126766658+00:00 DEBUG Test Driver 1 data table: 0x1d3d0d8
2021-11-10T18:02:53.130099533+00:00 DEBUG Test Driver 1 network_type DEVICE_LAN
2021-11-10T18:02:53.133252241+00:00 DEBUG Test Driver 1 profile table: 0x1d3ab70
2021-11-10T18:02:53.136534450+00:00 DEBUG Test Driver 1 id 7c9afda9-8184-31f2-b476-680a054d8e4b
2021-11-10T18:02:53.139917116+00:00 DEBUG Test Driver 1 components table: 0x1d570f0
2021-11-10T18:02:53.142966908+00:00 DEBUG Test Driver 1 main table: 0x1d41de8
2021-11-10T18:02:53.145919325+00:00 DEBUG Test Driver 1 id main
2021-11-10T18:02:53.154979033+00:00 DEBUG Test Driver 1 capabilities table: 0x1d1f7b0
2021-11-10T18:02:53.158391200+00:00 DEBUG Test Driver 1 switch table: 0x1d1f760
2021-11-10T18:02:53.161473991+00:00 DEBUG Test Driver 1 id switch
2021-11-10T18:02:53.164548325+00:00 DEBUG Test Driver 1 version 1
2021-11-10T18:02:53.171041158+00:00 DEBUG Test Driver 1 emit_event function: 0x1d27c20
2021-11-10T18:02:53.174127950+00:00 DEBUG Test Driver 1 manufacturer SmartThings Community
2021-11-10T18:02:53.180457950+00:00 DEBUG Test Driver 1 id 490a5dc6-0d20-4fbe-8da5-21dfb8f81669
2021-11-10T18:02:53.183495741+00:00 DEBUG Test Driver 1 vendor_provided_label Test Device
2021-11-10T18:02:53.192839325+00:00 DEBUG Test Driver 1 driver table: 0x1d57270
2021-11-10T18:02:53.196032450+00:00 DEBUG Test Driver 1 id 4e69668a-8f61-4a8c-b4cd-89a9fc2bf7a8
2021-11-10T18:02:53.199464991+00:00 DEBUG Test Driver 1 type LAN
2021-11-10T18:02:53.202553283+00:00 DEBUG Test Driver 1 name Test Driver 1
2021-11-10T18:02:53.210292366+00:00 DEBUG Test Driver 1 preferences table: 0x1d4a498
2021-11-10T18:02:53.214924158+00:00 DEBUG Test Driver 1 option option_a
2021-11-10T18:02:53.218719158+00:00 DEBUG Test Driver 1 parent_device_id e2c73330-dac4-4bda-b297-8e0a771467de
2021-11-10T18:02:53.226781283+00:00 DEBUG Test Driver 1 execution_environment HUBCORE
2021-11-10T18:02:53.230163950+00:00 DEBUG Test Driver 1 ******************************************************
2021-11-10T18:02:53.233241033+00:00 DEBUG Test Driver 1 Equivalent NEW device values:
2021-11-10T18:02:53.236512200+00:00 DEBUG Test Driver 1 device_network_id myTestDevice01
2021-11-10T18:02:53.246112783+00:00 DEBUG Test Driver 1 label Test Device
2021-11-10T18:02:53.249671158+00:00 DEBUG Test Driver 1 data table: 0x1d66848
2021-11-10T18:02:53.252860116+00:00 DEBUG Test Driver 1 network_type DEVICE_LAN
2021-11-10T18:02:53.255988158+00:00 DEBUG Test Driver 1 profile table: 0x1d44d88
2021-11-10T18:02:53.267083825+00:00 DEBUG Test Driver 1 id 7c9afda9-8184-31f2-b476-680a054d8e4b
2021-11-10T18:02:53.270423450+00:00 DEBUG Test Driver 1 components table: 0x1d07990
2021-11-10T18:02:53.273552408+00:00 DEBUG Test Driver 1 main table: 0x1d4c528
2021-11-10T18:02:53.276691825+00:00 DEBUG Test Driver 1 id main
2021-11-10T18:02:53.282161741+00:00 DEBUG Test Driver 1 capabilities table: 0x1d1c870
2021-11-10T18:02:53.289865200+00:00 DEBUG Test Driver 1 switch table: 0x1cb4478
2021-11-10T18:02:53.293141575+00:00 DEBUG Test Driver 1 id switch
2021-11-10T18:02:53.297192950+00:00 DEBUG Test Driver 1 version 1
2021-11-10T18:02:53.300256491+00:00 DEBUG Test Driver 1 emit_event function: 0x1d454c0
2021-11-10T18:02:53.308146741+00:00 DEBUG Test Driver 1 manufacturer SmartThings Community
2021-11-10T18:02:53.311230700+00:00 DEBUG Test Driver 1 id 490a5dc6-0d20-4fbe-8da5-21dfb8f81669
2021-11-10T18:02:53.317726116+00:00 DEBUG Test Driver 1 vendor_provided_label Test Device
2021-11-10T18:02:53.320938491+00:00 DEBUG Test Driver 1 driver table: 0x1d63388
2021-11-10T18:02:53.327109658+00:00 DEBUG Test Driver 1 id
2021-11-10T18:02:53.330391783+00:00 DEBUG Test Driver 1 type
2021-11-10T18:02:53.333434450+00:00 DEBUG Test Driver 1 name
2021-11-10T18:02:53.710911700+00:00 DEBUG Test Driver 1 preferences table: 0x1d0e168
2021-11-10T18:02:53.715924783+00:00 DEBUG Test Driver 1 option option_b
2021-11-10T18:02:53.719133158+00:00 DEBUG Test Driver 1 parent_device_id e2c73330-dac4-4bda-b297-8e0a771467de
2021-11-10T18:02:53.727646491+00:00 DEBUG Test Driver 1 execution_environment HUBCORE
- Quite often, driver updates simply do not seem to work. When I reinstall an existing driver using the CLI, I can see in the log that the info_changed lifecycle gets called, that handler gets executed, and then nothing. The driver never actually gets re-installed. This usually forces me to delete all devices, uninstall the driver, wait a bit, then reinstall the driver and recreate the devices. Not fun. I have also had instances where supposedly the new driver was installed, but in fact it reinstalled the prior code again and not the new code. EDIT: I suppose this could also be a glitch in the logger itself…