Roon extension - http APIs


(Raf Verhoogen) #81

Sorry but forgot one, can someone give me some hints to get the background color aligned with the main color of the cover? so in the above one it would be a light gray background ? So i need to find out the color from the image and then use that color as background.


(Bastian) #82

Hi @Raf_Verhoogen1,

If you want to have the track seek functionality, it would be better to use the websocket implementation (it’s the roon-extension-ws-player repository).

The basic difference with the http repository is that the page gets updated every time there is a change in the zone’s data (track seek time, for example) as opposed to updating it every 2 seconds in the http repository.

I just updated both repositories to add a call called getOriginalImage which returns the image untouched, others image calls resize the image. You can try this call and see if it’s better.

For the album/track credits, unfortunately these information are not available through the APIs so currently we cannot show these data.

As for the background color, i’m not good with css, but I think what you would do is use the image as background by using blur and transparencies, then add the untouched image on top of this background.

Please let me know if you have anymore questions.

bastian


(Bastian) #83

Hi Ben,

I’ve just updated Roon to 269 and did npm install on the api directory.
Both get_zones and get_outputs still returns empty.

Thanks,
Bastian


(Ben) #84

We turn out to also have had a silly bug in the node-roon-api-transport code, which should now be fixed. I was able to have your listZones endpoint work with that fixed.

The fix is on github now, commit is fce7fc4, I don’t know what exactly you will need to do to get it on your local systems.


(Bastian) #85

Hi Ben,

I’ve tested it and it works now.
Many Thanks for your help.

Bastian


(simon arnold) #86

Hi I am using the roon-web-extension on a RPI is there a way for me to be able to query if roon has stopped playing so I can trigger an event to turn off the screen I am using. Same goes for when I play to be able to trigger the screen on.


(Bastian) #87

Hi Simon,

You can try to use the websocket implementation (it’s the roon-extension-ws-player repository) to capture events real-time.

The closest one is to look at the alarm implementation where it opens a page to stop/snooze the alarm on those clients that have the same zone open.

You can use the statuses on either zone or output to trigger the screen.

I’m away from my computer now to look for the exact field, I’ll look it up later and let you know.

May I know how are you turning the display on/off programmatically?

Edit: I just checked the zone and output properties at Roon’s GitHub page for node-roon-api-transport, they have the state field which you can use for your trigger.

@property {(‘playing’|‘paused’|‘loading’|‘stopped’)} state

Regards,
Bastian


(simon arnold) #88

Thanks Bastian, I would be using these commands

echo 0 > /sys/class/backlight/rpi_backlight/bl_power
echo 1 > /sys/class/backlight/rpi_backlight/bl_power

any help would be appreciated. I am not really a programmer and new to all this so any guidance as to how I can use roon api to do this would be appreciated. Basically I have an endpoint running dietpi with roon bridge which is running chromium in kiosk mode to display the web extensions web gui to control and show now playing. Currently you can either have the screen on all the time or the screensaver turns it off after set amount of time. Ideally I want to have the screensaver off completely and control if display is on/off by roons play status perhaps with a delay before turning it off.


(Mike Plugge) #89

In order for this to work, you would need to run Node JS as root (VERY dangerous) or adjust the permissions on /sys/class/backlight/rpi_backlight/bl_power to allow the user running node to write to it.

It would be much safer to run:
to turn off the display
xset dpms force off
and to turn on the display
xset dpms force on

Note that this would work on any Linux system - not just a Raspberry Pi. But this assumes that you are running NodeJS on the Raspberry Pi itself. You would not be able to run Node JS on one system and turn off the display on a different Raspberry Pi. That would be a gapping hole in the browser sandboxing.

You may want to look into ShellJS to allow you to run Linux commands from within Node JS
https://www.npmjs.com/package/shelljs
But be VERY VERY VERY careful - allowing Node JS to run arbitrary Linux command can be extremely dangerous.


(Nicolas Will) #90

I’ve used you extension in the context of an IR remote working of LIRC/IREXEC.

Docs and script here:

http://www.youplala.net/2018/03/17/packaging-our-bedroom-raspberry-pi-for-hi-fi/

Thanks for your work!

Nico


(Fernando Fuentes) #91

I see an explanation of your setup but no doc nor script…
Where is my spoon? :confused:


(Nicolas Will) #92

Ooops!

Sorry, I had the wrong URL in there!

The spoon is here:
http://www.youplala.net/2018/03/17/packaging-our-bedroom-raspberry-pi-for-hi-fi/

Corrected in my post too.

Nico


(Fernando Fuentes) #93

I got spooooon!
Nice very nice!

Thanks for the post :wink:


(Nicolas Will) #94

Thank you!


(François Van Houdenhoven) #95

very useful. using the current calls (stop, play, next) but wonder if additional API calls can be added. Interested in transferring queue to another zone (transfer_zone call).
tried to add but says " cannot find transfer_zone"

any suggestions appreciated!


(Bastian) #96

Hi,

Have you figured out how to call fhe api?

I’m traveling now and will take a look at it when I get back early Jan. I just peeked at roon’s api and they have the function call. So hopefully it’s straight forward.

Bastian


(François Van Houdenhoven) #97

Thanks for the reply.
I tried to add the transfer call api but have not been successfull so far so would be great if you could have a go!

Thanks


(Bastian) #98

Hi @Francois_Van_Houdenh,

I have updated the apis to include the transfer_zone

the url is:

http://localhost:PORT/roonAPI/transfer_zone?fromZoneId=SOURCE_ZONEID_OR_OUTPUTID&toZoneId=DESTINATION_ZONEID_OR_OUTPUTID

You can find the zone/output ids from the list_zones call.

I have not added this to the clients, just the API.
Let me know if you have further questions

Bastian


(François Van Houdenhoven) #99

Thanks will try this and let you know. Francois


(François Van Houdenhoven) #100

hi - I tried updating the API file by adding below

exports.transfer_zone = function(req, res) {
core.services.RoonApiTransport.transfer_zone( req.query[‘fromzoneId’], req.query[‘tozoneId’]);

then make the call as follows:

http://localhost:port/roonAPI/transfer_zone?fromZoneId=1601e9xxxxxxxdf08e9a134f&toZoneId=16014xxxxxx3d5d2306c1e6bcc63

I get " succes response, but zone is not actually transferring…

other api calls work (stop, play, next).

am I missing something?

Thanks

Francois