-
-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): support conditional settings with "$if" #1810
Conversation
Awesome! |
Looks great to me. I'm not sure when we'd differentiate by more than firmware version but it could come up, so makes sense to include it. Does this (or could this) also apply to association groups? I noticed recently that the Kwikset locks seems to gain a group over time but I'm not actually sure it's even definable as they use the same everything else. It may come up again though. |
) { | ||
this.parameterNumber = parameterNumber; | ||
this.valueBitMask = valueBitMask; | ||
|
||
if (typeof definition.label !== "string") { | ||
throwInvalidConfig( | ||
"devices", | ||
`packages/config/config/devices/${filename}: | ||
`packages/config/config/devices/${parent.filename}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are plenty of parent.filename
here. Maybe a new var could be useful
Yeah you can use it for the individual association groups just not with the array notation of parameters. |
This PR introduces conditional config settings to cut down on repetition for devices that only slighly change between firmware versions or hardware revisions. The
"$if"
property accepts a string with logic inside, e.g.The logic supports the JavaScript operators
<
,<=
,>
,>=
and===
, as well as&&
,||
and(...)
. Available variables aremanufacturerId
,productType
,productId
andfirmwareVersion
.You can use
"$if"
in the following locations:It is also possible to select one of multiple variants of a config parameter by specifying an array. In this case
"$if"
is mandatory in each parameter, except the last one. The first matching definition will be used, the others don't apply.