Which lifecycle event happen on driver updates

I am updating the implementation of a Z-wave driver for a thermostat. The new version changes from using one profile to using two profiles. I need to switch to the correct profile and set some variables depending on previous settings or parameters in the device. Which lifecycle event should I use to read parameters and select correct profile. The documentation does not clearly specify when and in which sequence lifecycle events happen. Should I use added, doConfigure or driverChanged.
An example with lifecycle event sequence for device added, user changed to different driver and driver updated would be very useful.

Maybe you can find answers here

1 Like

Thank you very much. Information was perfect.

1 Like

Hi @ivarsand

To assign the profile that can vary depending on a persistent minor variable, such as preferences, I use the init lifecycle or driver switched

To assign a profile chosen by the user, the infoChanged lifecycle must be used, which is executed when a preference value is changed.

If you want, you can see examples in my drivers zwave o zigbee too

1 Like

Thank you very much. That was very helpful.
The old version of the driver I am writing used only one profile.
The new version will support two profiles.
I use set_field with persist to “remember” selected profile.
Will a set_field survive a driver update?
If so I can just check the value in init. If not existent, I can select and assign profile depending on a preference.

Hi,

with persist= true, then it persists to a hub reboot or hub or driver update.

If you choose the profile with a preference it is better, since it is persistent even after changing the driver and returning to it.

When you change the profile value in preferences, the infoChanged lifecycle is called and the new value is sent so that you can execute the profile change code.

You have mani examples on my github.