-
Notifications
You must be signed in to change notification settings - Fork 13
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
Update payload.js #119
base: main
Are you sure you want to change the base?
Update payload.js #119
Conversation
add node power desc
// configuration node power desc | ||
if ( (clusterdID === 0x0050 ) & (attributID === 0x0006)) { | ||
index2 = index + 3; | ||
if ((bytes[index+2] &0x01) === 0x01) { | ||
tab.push({label:"ExternalPowerVoltage" ,value:(bytes[index2]*256+bytes[index2+1])/1000, date:lDate}) ; | ||
index2=index2+2; | ||
} | ||
if ((bytes[index+2] &0x04) === 0x04) { | ||
tab.push({label:"BatteryVoltage" ,value:(bytes[index2]*256+bytes[index2+1])/1000, date:lDate}) ; | ||
index2=index2+2; | ||
} | ||
if ((bytes[index+2] &0x02) === 0x02) {decoded.data.rechargeable_battery_voltage = (bytes[index2]*256+bytes[index2+1])/1000;index2=index2+2;} | ||
if ((bytes[index+2] &0x08) === 0x08) {decoded.data.solar_harvesting_voltage = (bytes[index2]*256+bytes[index2+1])/1000;index2=index2+2;} | ||
if ((bytes[index+2] &0x10) === 0x10) {decoded.data.tic_harvesting_voltage = (bytes[index2]*256+bytes[index2+1])/1000;index2=index2+2;} | ||
} | ||
|
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.
Please add unit tests for your modification to ensure everything is working as expected.
Additionally, when adding the unit tests, include the following test to verify that other data is allowed beyond what has been decoded.
describe("Shall not be parsed", () => {
let payload = [
{ variable: "shallnotpass", value: "04096113950292" },
{ variable: "fport", value: 9 },
];
payload = decoderRun(file_path, { payload });
test("Output Result", () => {
expect(Array.isArray(payload)).toBe(true);
});
test("Not parsed Result", () => {
expect(payload).toEqual([
{ variable: "shallnotpass", value: "04096113950292" },
{ variable: "fport", value: 9 },
]);
});
});
Hello @Watteco, I have reviewed your changes and requested one adjustment. Thanks for your contribution! |
add node power desc
Decoder Description
Explain the functionality of your decoder or any other relevant information.
Type of change
Decoder Information and Payload to test and review
Checklist for Adding a New Decoder
./decoders/network/
or./decoders/connector/
with the name of your decoder.network.jsonc
orconnector.jsonc
file that follows the structure defined in./schema/
.manifest.jsonc
files for each version.Additional Notes
Please add any other information that you think is important.