jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.83k stars 462 forks source link

Question: how to switch playbar back to TV ? #709

Closed ghost closed 4 years ago

ghost commented 4 years ago

Everything works as expected with this library. I'm using playbars, sub's, amp's and play:5 devices to control volume, join and leave zone.

But when i want to switch the playbars back to TV i did not find a way.

Is there any solution available (except the sonus app's) ?

jishi commented 4 years ago

You can use this workaround https://github.com/jishi/node-sonos-http-api/issues/382

ghost commented 4 years ago

Thank you for the fast response.

I'll try to parse the necessary UUID's from /zones to be able to use the /zone/setavtransporturi command.

jishi commented 4 years ago

The uuid is hard-coded from factory for a given player, so that is not bound to change unless you replace it.

On Wed, 24 Jul 2019, 20:29 hukedev, notifications@github.com wrote:

Thank you for the fast response.

I'll try to parse the necessary UUID's from /zones to be able to use the /zone/setavtransporturi command.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/jishi/node-sonos-http-api/issues/709?email_source=notifications&email_token=AAYE2IZGIUNRPX5CGHAR5JDQBCNR7A5CNFSM4IGPM4T2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2XGXKY#issuecomment-514747307, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYE2I56SS3ZOS6FEFUYFGDQBCNR7ANCNFSM4IGPM4TQ .

ghost commented 4 years ago

As UUID's are parsed by library already i simply added a new action called spdif based on linein:

'use strict';

function spdif(player, values) {
  const sourcePlayerName = values[0];
  let lineinSourcePlayer = player;

  if (sourcePlayerName) {
    lineinSourcePlayer = player.system.getPlayer(decodeURIComponent(sourcePlayerName));
  }

  if (!lineinSourcePlayer) {
    return Promise.reject(new Error(`Could not find player ${sourcePlayerName}`));
  }

  const uri = `x-sonos-htastream:${lineinSourcePlayer.uuid}:spdif`;

  return player.coordinator.setAVTransport(uri)
    .then(() => player.coordinator.play());
}

module.exports = function (api) {
  api.registerAction('spdif', spdif);
}

So, for switching to SPDIF on playbars i'm calling this:

serverip:5005/zonename/spdif