Fix Chromecast volume rounding bug (#2656)
* Fix Chromecast volume rounding bug for values 8% and below
Changed volume level conversion from int() to round() to fix floating-point
precision issues. Chromecast reports volume as float (0.0-1.0) which can have
slight imprecision (e.g., 4% = 0.
03999999910593033). Using int() truncated
these values, causing displayed volume to be 1% less than actual for values
8% and below.
Fixes the issue where setting volume to 5% would display as 4%, etc.
* Fix Chromecast volume rounding bug for values 8% and below
Changed volume level conversion to use round() instead of int() in both
directions to fix floating-point precision issues:
1. When setting volume: round to 2 decimal places before sending to device
2. When reading volume: round to nearest integer when converting to percentage
This fixes the issue where Chromecast reports volume as float (0.0-1.0) with
slight imprecision (e.g., 4% = 0.
03999999910593033). Using int() truncated
these values, causing displayed volume to be 1% less than actual for values
8% and below.
Fixes the issue where setting volume to 5% would display as 4%, etc.
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Marvin Schenkel <marvinschenkel@gmail.com>