-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[upnpcontrol] Ignore negative volume values #17991
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Stefan Höhn <[email protected]>
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
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 for the fix! I have put some minor comments for consideration.
@@ -1113,6 +1113,11 @@ private void onValueReceivedVolume(String variable, @Nullable String value) { | |||
long volume = Long.valueOf(value); | |||
volume = volume * 100 / config.maxvolume; | |||
|
|||
if (volume < 0) { |
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.
Perhaps this could be checked right after line 1113 to avoid performing any calculations with invalid value?
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.
In the identified error case, volume came from the service as a negative. But there might also be a case where config.maxvolume (also retrieved from the service) is negative and that would lead to problems as well. Or we catch this bad data where config.maxvolume is set as well, or we leave this statement where it is.
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.
Too many ORs 😅 So what do we wanna do?
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.
Move it right after line 1113, but also change here:
Line 55 in e2571d6
if (volume) { |
Put the following on that line:
if (volume && volume > 0)
In principle, it should be a positive integer less than or equal to 100. You could also log a warning there if it is not.
I have at least one upnp system that is sending incorrect negative volume values. This change make the binding resilient by ignoring negative volume values.