node-sonos-http-api
node-sonos-http-api copied to clipboard
Volume parameter issue with float numbers
Volume parameters with float numbers are not interpreted when used with "clip".
For example: GET /kitchen/clip/ring.mp3/3.0 Volume parameter is not interpreted as "3" and the predefined announceVolume in settings.json is used.
but GET /kitchen/volume/3.0 is interpreted correctly and the volume is set to 3.
Unfortunately my application can not send integer value to bypass this issue.
Is it possible to accept float values when "clip" is used?
regards Pascal
https://github.com/jishi/node-sonos-http-api/blob/master/lib/actions/clip.js#L17-L20
That checks that the volume parameter (the comment is wrong, it's the second parameter) consist of only numbers, which is why it is ignoring it. It would have to check for periods as well and then maybe do a parseInt of it or similar, because Sonos will probably be sad if you sent in a decimal value as volume (it only takes integer 0-100).
Is this a problem because the value is produced by some external source? Seems fairly trivial to just only send integers in the request to begin with :)
Thank you very much for your reply.
Yes, the values are produced by an external building automation system which can not be modified.
It would be great if the check could be modified to accept float values and round them downwards to its nearest integer. That would match the /volume/ behavior. If I send /kitchen/volume/10.7 the volume is automatically rounded downwards (probably with method floor) to 10.
Thank you.