Skip to content
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

Driver ignoring preferred scales for multilevel sensors #7285

Closed
4 of 7 tasks
AlCalzone opened this issue Oct 16, 2024 Discussed in #7284 · 0 comments · Fixed by #7286
Closed
4 of 7 tasks

Driver ignoring preferred scales for multilevel sensors #7285

AlCalzone opened this issue Oct 16, 2024 Discussed in #7284 · 0 comments · Fixed by #7286

Comments

@AlCalzone
Copy link
Member

Discussed in #7284

Originally posted by @spudwebb October 15, 2024

Checklist

  • I have read and followed the above instructions

  • I have checked the troubleshooting section and my problem is not described there.

  • I have read the changelog and my problem was not mentioned there or the fix did not work.

Describe the issue

In ZWave JS UI, I have preferred scales set to "temperature: Fahrenheit (°F)", if I refresh an "Air temperature" multilevel sensor I always get a value in Celsius.
In the logs I see:

2024-10-15T16:17:35.933Z CNTRLR [Node 010] Preferred scale "1" for sensor type 1 not found, using the first supported scale 0

I believe the problem is in the following lines in getPreferredSensorScale. As Object.entries() always return keys as string, when the preferred scale is found, preferred is always set to the key as a string and then the second if is true as if the look up had failed:

// If the scale name or unit was given, try to look it up
if (typeof preferred === "string") {
for (const [key, scale] of Object.entries(sensor.scales)) {
if (scale.label === preferred || scale.unit === preferred) {
preferred = key;
break;
}
}
}
if (typeof preferred === "string") {
// Looking up failed
applHost.controllerLog.logNode(nodeId, {
endpoint: endpointIndex,
message:
`Preferred scale "${preferred}" for sensor type ${sensorType} not found, using the first supported scale ${
supportedScales[0] ?? 0
}`,
});
return supportedScales[0] ?? 0;
}

Software versions

Driver (node-zwave-js): 13.9.0

Z-Wave JS UI: 9.23.0

Z-Wave Controller (Stick/Dongle/...)

No response

Device information

No response

Checklist

  • I made sure to provide a driver log on level debug.

  • The log includes a re-interview of the problematic device (if applicable).

  • The log includes the problematic interaction with the device (if applicable).

  • I provided the node ID of the problematic device (if applicable).

Upload Logfile

zwavejs_2024-10-15.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant