jensrossbach / node-red-contrib-sony-audio

Node-RED nodes for accessing Sony Audio Control API
MIT License
2 stars 0 forks source link

Custom commands - don't work #27

Closed seanwatkins closed 3 years ago

seanwatkins commented 3 years ago

Hi,

I've got a DTR-1080. I can control almost everything on the receiver - however, video2.. doesn't work -

Adding in custom command - I'm sending a message with this JSON data

{ "command": "setSource", "payload": { "source": { "scheme": "extInput", "resource": "video", "port": "2" } } }

The receiver just answers back:

image

jensrossbach commented 3 years ago

Hi,

I need some more information:

Also I noticed in your JSON data that you pass the value for the "port" property as string, but it should be a number. I'm not sure if the video resource supports port numbers at all, but maybe it does (I cannot verify as I don't have a DTR-1080).

If possible, could you activate debug trace level in your Node-RED and send me an extract of the log file when you reproduce the problem?

seanwatkins commented 3 years ago

Hi I'm new to node red + github etc, but I did figure out the issue.

I'm running this inside docker and not totally sure how to get fixes to github.. but let me explain -

I'm sending in a Msg.payload, in JSON, with the data setup like you had in your examples:

{ "command": "setSource", "payload": { "source": { "scheme": "extInput", "resource": "video", "port": "2" } } }

At about line 273, your check, is the msg.payload == "object". Then you pull out the msg.payload.scheme, etc from there. However, thats not correct-

The above JSON object, the payload for the receiver is at

msg.payload.payload

So actual source / port zone will be

msg.payload.payload.source msg.payload.payload.port msg.payload.payload.zone

So poking into it, you need to put another payload statement in front-

ie:

if (typeof msg.payload.payload.source == "object") {

                                if ((typeof msg.payload.payload.source.scheme == "string") &&
                                    (typeof msg.payload.payload.source.resource == "string"))
                                {
                                    args.source = msg.payload.payload.source.scheme + ":" + msg.payload.payload.source.resource;

                                    node.log ("msg payload decoding.. args.source = " + args.source);
                                }

                                if (typeof msg.payload.payload.source.port == "string")
                                {
                                    args.port = msg.payload.payload.source.port;
                                    node.log ("msg payload  - args.port = " + args.port);
                                } else {
                                    node.log ("type of = " + typeof msg.payload.payload.source.port);
                                }

Also, in the function setPlayContent(context, source, port = 0, zone = 0)

I added the extInput:video, source.

 if (((source == "extInput:hdmi") || (source == "extInput:line") || (source == "extInput:video")) && (port > 0))
        {
            uri += "?port=" + port;
        }

And - for my fm radio presets-

 if ((source == "radio:fm") && (port > 0)) {
            uri += "?contentId=" +  port;
        }

Apologize for putting it in like this but like I said not totally sure how to push these :)

Sean

jensrossbach commented 3 years ago

So unfortunately this is not a correct input for the nodes, the examples in the documentation are JSON representations of the whole input message, not just the msg.payload property. So please change your input message in that way.

If you believe that video and radio resources require a port parameter, I can certainly change this in the code, I will also add the possibility to configure this in the configuration page of the node.

jensrossbach commented 3 years ago

I just released version 1.6.5 which should solve your problem. But as I don't have a Sony device that supports video input and FM radio sources, I wasn't really able to test this. Please check if your problem is solved now, thanks!

jensrossbach commented 3 years ago

@seanwatkins did you have the chance to test the new version of the nodes? Is your problem solved now, so that I can close this ticket?

jensrossbach commented 3 years ago

Closing issue due to missing feedback from submitter.