ChriD / node-raumkernel

A nodeJs lib for controlling the raumfeld multiroom system
MIT License
17 stars 7 forks source link

howto setup a virtual media renderer? #53

Open sajov opened 2 years ago

sajov commented 2 years ago

Hi, impressive work, Thanks!

I have a problem of understanding. I would like to apply loadUri to a specific device. LoadUri is only available for virtual renderers. How can I make a media renderer a virtual media renderer with raumkernel?

ChriD commented 2 years ago

A virtual renderer is a device which will be created by raumfeld if you create a zone out of a room So you have to create a zone out of a room (or find the zone with a room-udn if already there) to get a virtual media renderer.

eg.:

this.managerDisposer.zoneManager.connectRoomToZone(_roomUdn, "", true).then(function(_data){
                _resolve(_data);
            }).catch(function(_data){
                _reject(_data);
            });

Above code will create a new zone for the room with the given room-udn. And so it will create a virtual media renderer too

sajov commented 2 years ago

thank you for the answer! I want to address a specific speaker, regardless of whether it is assigned to a room. To understand, I want to send an acoustic feedback from a smart home system to a speaker. In the logs my devices look like this, I see media renderer, virtual media renderer and media server. Test to connectRoomToZone gives me following error:

Screenshot 2022-04-26 at 20 14 10

I am lost in Glossar

ChriD commented 2 years ago

I want to address a specific speaker, regardless of whether it is assigned to a room.

The Raumfeld system itself can not play anything if the speaker is not attached to a room and the room is not attached to a zone. The times the Raumfeld system was able to do that are long time ago :-(

Test to connectRoomToZone gives me following error:

what's your code?

sajov commented 2 years ago

The code looks now this, on systemReady i try to get/create a virtual reanderer

    const raumkernel = new RaumkernelLib.Raumkernel();
    raumkernel.settings.raumfeldHost = '192.168.0.20';
    raumkernel.settings.uriMetaDataTemplateFile = 'src/services/raumfeld/setUriMetadata.template';
    raumkernel.createLogger();
    raumkernel.on('systemReady', function (_ready: any) {
      raumkernel.logInfo('System ready: ' + _ready);
      raumkernel.managerDisposer.zoneManager.connectRoomToZone('uuid:5208bce6-a82b-40a2-a85f-722ef24af11b','', false).then(function (data: any) {
        console.log({data});
      }).catch(function (error: any) {
        console.log({error});
      });
    });
    raumkernel.init();

log shows:

info: [Raumkernel] Found raumfeld host on: 192.168.0.20
info: [DeviceManager] Raumfeld Media renderer added: Speaker office rear (uuid:5208bce6-a82b-40a2-a85f-722ef24af11b)
error: uncaughtException: Channel closed date=Wed Apr 27 2022 20:06:03 GMT+0200 (Central European Summer Time), pid=52045, uid=501, gid=20, cwd=/Users/diver/Documents/Dev/sajov/smart-home-api, execPath=/Users/diver/.nodebrew/node/v14.15.5/bin/node, version=v14.15.5, argv=[/Users/diver/.nodebrew/node/v14.15.5/bin/node, src/], rss=167632896, heapTotal=125952000, heapUsed=95204976, external=5195946, arrayBuffers=3413754, loadavg=[4.396484375, 3.6884765625, 3.69970703125], uptime=4319269
Error [ERR_IPC_CHANNEL_CLOSED]: Channel closed
    at process.target.send (internal/child_process.js:705:16)
    at Object.exports.send (/Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/ts-node-dev/lib/ipc.js:17:14)
    at /Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/ts-node-dev/lib/wrap.js:88:9
    at obj.<computed> (/Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/ts-node-dev/lib/hook.js:33:17)
    at isInsideNodeModules (internal/util.js:360:26)
    at showFlaggedDeprecation (buffer.js:184:8)
    at new Buffer (buffer.js:281:3)
    at Object.ip.toBuffer (/Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/ip/lib/ip.js:13:22)
    at Object.ip.mask (/Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/ip/lib/ip.js:129:13)
    at /Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/node-raumkernel/lib/lib.external.upnp-device-client.js:481:32
    at Array.map (<anonymous>)
    at DeviceClient.getIfaceForUrl (/Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/node-raumkernel/lib/lib.external.upnp-device-client.js:476:29)
    at DeviceClient.ensureEventingServer (/Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/node-raumkernel/lib/lib.external.upnp-device-client.js:443:22)
    at /Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/node-raumkernel/lib/lib.external.upnp-device-client.js:197:10
    at /Users/diver/Documents/Dev/sajov/smart-home-api/node_modules/node-raumkernel/lib/lib.external.upnp-device-client.js:38:7
    at processTicksAndRejections (internal/process/task_queues.js:75:11)
info: [DeviceManager] Raumfeld Media renderer added: Speaker Wohnzimmer (uuid:a8a92e13-e514-4e87-89fb-1ac29bc68449)
info: [DeviceManager] Raumfeld Media renderer added: Speaker office front (uuid:038f615a-819b-4e3e-9ef0-55bfd7d3cacf)
info: [DeviceManager] Raumfeld Media renderer added: Speaker Badezimmer (uuid:72a15784-f0b5-4b3a-867a-bb30872f4c26)
info: [DeviceManager] Raumfeld Media renderer added: Connector Connector (uuid:d9980cb1-3b0c-4bcc-9089-b67ed84b3b29)
info: [DeviceManager] Virtual media renderer added: office front (uuid:9e85cba8-17b5-451f-ae08-7b2beac7899c)
info: [DeviceManager] Raumfeld media server added: Raumfeld MediaServer (uuid:971926d2-837c-4556-9724-f8fc66d4d0e8)
info: [Raumkernel] System ready: true
{ data: {} }

I don't have rooms. The Raumfeld mobile app -> settings -> devices, shows for each speaker, the speaker name also as room name. :-(

ChriD commented 2 years ago

@sajov Can you try to call connectRoomToZone with the third parameter as 'true' ? This will ensure that the promise which will be returned will be fulfilled when the room was connected to the zone or a new zone was created. With the parameter set to false the promise will return immediately, it does not wait for the zone to be created raumkernel.managerDisposer.zoneManager.connectRoomToZone('uuid:5208bce6-a82b-40a2-a85f-722ef24af11b','', true)