The PR introduces a new ResourceItemattr/otaversion which can be used to select DDFs. First example for it is the Ikea on/off switch which needs a DDF for newer and older firmware versions (will be added as separate PR).
How it works for Ikea on/off switch
DDF 1) The old firmware version DDF has following expression:
{
"matchexpr": "var v = R.item('attr/otaversion').val; (v != 0 && v < 0x23079631);"
}
DDF 2) And the new one:
{
"matchexpr": "var v = R.item('attr/otaversion').val; (v == 0 || v >= 0x23079631);"
}
On first join and after deCONZ update from v2.26.0 to v2.26.1 the firmware version is not known yet, and is 0.
Therefore the new firmware version DDF 2 is selected due the (v == 0 || v >= 0x23079631) condition!
When the firmware version is queried via Read Attribute Request or extracted from OTA Query Next Image request, and if it is different than the previous known version, then the DDF matching starts again for the device, perhaps selecting the older DDF 1 if the version check (v != 0 && v < 0x23079631) applies.
Under the hood the PR does the following:
Every Device Resource has the attr/otaversion item by default and it is filled by either ZCL Read Attributes Request from OTA cluster attribute 0x0002 or when OTA Query Next Image request is received.
The device firmware version value is stored in the database zcl_values table if it doesn't exist or is changed.
This happens for DDF and non DDF legacy devices, so that we have it ready when a DDF is created later on!
A important part is that once a new version is detected, e.g. initially or after an OTA update, the DDF matching process is started again automatically if the DDF has a matchexpr, no restart of deCONZ is required.
The PR introduces a new
ResourceItem
attr/otaversion
which can be used to select DDFs. First example for it is the Ikea on/off switch which needs a DDF for newer and older firmware versions (will be added as separate PR).How it works for Ikea on/off switch
DDF 1) The old firmware version DDF has following expression:
DDF 2) And the new one:
0
.(v == 0 || v >= 0x23079631)
condition!(v != 0 && v < 0x23079631)
applies.Under the hood the PR does the following:
attr/otaversion
item by default and it is filled by either ZCL Read Attributes Request from OTA cluster attribute 0x0002 or when OTA Query Next Image request is received.zcl_values
table if it doesn't exist or is changed.matchexpr
, no restart of deCONZ is required.