-
Notifications
You must be signed in to change notification settings - Fork 82
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
query attributes with edited global attributes #1162
Conversation
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.
This does not seem to fix the output of zcl_attributes....
Codecov Report
@@ Coverage Diff @@
## master #1162 +/- ##
==========================================
+ Coverage 65.38% 65.41% +0.02%
==========================================
Files 171 171
Lines 18366 18384 +18
Branches 3969 3971 +2
==========================================
+ Hits 12008 12025 +17
- Misses 6358 6359 +1
|
9d6ea90
to
c06ff95
Compare
@tecimovic @brdandu could you guys please take a look at the Zigbee regen failures when you have a moment? Thanks |
e7b1fab
to
6b50b3c
Compare
047586c
to
182092d
Compare
src-electron/upgrade/upgrade.js
Outdated
let byName = data?.attributeAccessInterfaceAttributes | ||
let lists = data?.listsUseAttributeAccessInterface | ||
let forcedExternal = { byName, lists } | ||
return forcedExternal | ||
} | ||
|
||
/** | ||
* This function takes a clusterId and an array of attributes associated with that clusterID from the database | ||
* and changes the global attributes (attributes with clusterId = null) to represent storage policy |
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.
Nothing below is restricted to global attributes...
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.
Thanks, I just added a check "if(attribute.clusterId == null)". The "non global attributes" should already be computed from the loading process.
This function should only change global attributes.
src-electron/upgrade/upgrade.js
Outdated
try { | ||
return JSON.parse(json) | ||
} catch (err) { | ||
return 'undefined' |
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.
return 'undefined' | |
return undefined |
src-electron/upgrade/upgrade.js
Outdated
* @returns an array of objects representing attributes in the database | ||
*/ | ||
|
||
async function computeStoragePolicy(db, clusterId, attributes) { |
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.
async function computeStoragePolicy(db, clusterId, attributes) { | |
async function computeStoragePolicyForGlobalAttributes(db, clusterId, attributes) { |
if that's what it does.
ab8c376
to
935e58a
Compare
this.id, | ||
packageIds | ||
) | ||
attributes = await upgrade.computeStoragePolicyForGlobalAttributes( |
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.
This doesn't feel right, layer-wise. The point of upgrade.js
is to perform upgrades when you READ IN the .zap files.
You are here using upgrade.js
when you're generating stuff.
Not saying that it's the wrong thing, functionally, but I'd then go and move the logic out of upgrade.js
, put it somewhere else, and maybe have both places call the common place.
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.
will make follow up PR, thanks
try { | ||
return JSON.parse(json) | ||
} catch (err) { | ||
return undefined |
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.
? You are hiding exception here. Why do we need this? This feels wrong. I don't want for people to blindly start using this function, and then be confused why they get "error: undefined", instead of "error: JSON parsing error".
So this function makes no sense to me.
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.
thanks will fix
src-electron/upgrade/upgrade.js
Outdated
let data = JSON.parse(obj) | ||
zcl = zcl?.path | ||
let obj = await fsp.readFile(zcl, 'utf-8') | ||
let data = await parseJson(obj) |
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.
I don't see why you wrap JSON parsin into a "fake asynchronous call"... (See my comment above).
zcl = zcl.path | ||
let obj = await fsp.readFile(zcl) | ||
let data = JSON.parse(obj) | ||
zcl = zcl?.path |
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.
Somewhere along the way this part is also eating up an "exception condition" (zcl being null or undefined).
9e7f8b0
to
4b83332
Compare
No description provided.