-
-
Notifications
You must be signed in to change notification settings - Fork 29
Volume Delta Expansion #1062
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
base: main
Are you sure you want to change the base?
Volume Delta Expansion #1062
Conversation
|
This has expanded to also include #1024 due to that being one extra line beyond what I'd already done to implement that for zones, though I then discovered it was an extra chunk to App.jsx to do the same for groups so there was some slight feature creep to this PR there. |
0bb2671 to
31dc4ab
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1062 +/- ##
==========================================
- Coverage 50.67% 50.25% -0.42%
==========================================
Files 40 41 +1
Lines 7154 7368 +214
==========================================
+ Hits 3625 3703 +78
- Misses 3529 3665 +136
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This does not interfere with home assistant's functionality |
b2379f0 to
eea75bb
Compare
db7f047 to
54fda80
Compare
94e796e to
f067d19
Compare
linknum23
left a comment
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.
The changes here look pretty reasonable. As this is an API change we should add one or more tests (or update pre-existing ones) right?
| assert z['vol_f'] - (zones[z['id']]['vol_f'] + 0.1) < 0.0001 and z["vol_f_overflow"] == 0 | ||
|
|
||
| # test oversized deltas | ||
| rv = client.patch('/api/zones', json={'zones': [z['id'] for z in zones], 'update': {'vol_delta_f': -10.0}}) | ||
| # test overflowing deltas | ||
| rv = client.patch('/api/zones', json={'zones': [z['id'] for z in zones], 'update': {'vol_delta_f': -1.0}}) | ||
| assert rv.status_code == HTTPStatus.OK | ||
| jrv = rv.json() | ||
| assert len(jrv['zones']) >= 6 | ||
| # check that each update worked as expected | ||
| for z in jrv['zones']: | ||
| if z['id'] in range(6): | ||
| assert z['vol_f'] == amplipi.models.MIN_VOL_F | ||
| assert z["vol_f_overflow"] == zones[z['id']]['vol_f'] + 0.1 - 1 | ||
|
|
||
| # test oversized overflowing deltas | ||
| rv = client.patch('/api/zones', json={'zones': [z['id'] for z in zones], 'update': {'vol_delta_f': 10.0}}) | ||
| assert rv.status_code == HTTPStatus.OK | ||
| jrv = rv.json() | ||
| assert len(jrv['zones']) >= 6 | ||
| # check that each update worked as expected | ||
| for z in jrv['zones']: | ||
| if z['id'] in range(6): | ||
| assert z['vol_f'] == amplipi.models.MAX_VOL_F | ||
| assert z["vol_f_overflow"] == amplipi.models.MAX_VOL_F_OVERFLOW | ||
|
|
||
| # test overflow reset | ||
| mid_vol_f = (amplipi.models.MIN_VOL_F + amplipi.models.MAX_VOL_F) / 2 | ||
| rv = client.patch('/api/zones', json={'zones': [z['id'] for z in zones], 'update': {'vol_f': mid_vol_f}}) | ||
| assert rv.status_code == HTTPStatus.OK | ||
| jrv = rv.json() | ||
| assert len(jrv['zones']) >= 6 | ||
| # check that each update worked as expected | ||
| for z in jrv['zones']: | ||
| if z['id'] in range(6): | ||
| assert z['vol_f'] == mid_vol_f | ||
| assert z["vol_f_overflow"] == 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.
Changed this test to account for valid overflows, oversized overflows, and overflow resets
8888e3c to
6fc3b89
Compare
|
There's some jittering in this yet, not due to this PR but exacerbated by it. The origin of this jitter is that we send volume change requests while sliding the slider but not all of the delta is always realized during that due to a race condition. A few solutions to this:
There's also some potential that the jitter is due to javascript only having floats for decimal values, which would mean we have to fix this by rounding every single instance of a float vol everywhere to see this fixed |
Add more values to models.py to track the min and max overflow
1e75bbc to
f92f5c5
Compare
What does this change intend to accomplish?
This PR aims to preserve the relative distance between zone volume levels when they would otherwise exceed the min or max vol_f
Checklist
./scripts/test