node-sonos-http-api icon indicating copy to clipboard operation
node-sonos-http-api copied to clipboard

Volume parameter issue with float numbers

Open pasger opened this issue 6 years ago • 3 comments
trafficstars

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

pasger avatar Nov 08 '19 14:11 pasger

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).

jishi avatar Nov 09 '19 15:11 jishi

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 :)

jishi avatar Nov 09 '19 15:11 jishi

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.

pasger avatar Nov 09 '19 16:11 pasger