jensrossbach / node-red-contrib-sony-audio

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

illegal argument (3) #24

Closed bionicdude closed 3 years ago

bionicdude commented 3 years ago

Hey,

I'm trying to set the source of my amp in a routine.

When i use a simple injector to test the node it works fine, but when i put it at the end of my flow it throws an error. I've tried a bunch of things to simulate passing nothing or date, etc - but all i get is this illegal argument error. I've currently put a change node in between turning on and switching source to try to emulate the injector.

It's very likely just some node-red nuance that i don't understand, but i figure i'd reach out for some help.

Below is my flow. the injector makes the source change, the flow does not. Any help you can offer would be great. [ { "id": "953397ad.b56d58", "type": "tab", "label": "Flow 3", "disabled": false, "info": "" }, { "id": "3b3b07db.e06ca8", "type": "inject", "z": "953397ad.b56d58", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 120, "y": 40, "wires": [ [ "2074fb1d.d803c4" ] ] }, { "id": "2074fb1d.d803c4", "type": "alexa-remote-routine", "z": "953397ad.b56d58", "name": "initializing ", "account": "abf8a9c6.0dd4b8", "routineNode": { "type": "speak", "payload": { "type": "ssml", "text": { "type": "ssml", "value": "<speak>activating game mode now</speak>" }, "devices": [ "90F0071863620MU3" ] } }, "x": 310, "y": 40, "wires": [ [ "b152dae.b42aa28", "c0c35bb7.589258" ] ] }, { "id": "c0c35bb7.589258", "type": "sony-audio-controller", "z": "953397ad.b56d58", "name": "Turn amp on", "device": "3a9732f0.b7e9de", "outputs": 1, "outputPorts": [ { "label": "response" } ], "outFilters": false, "outResponse": true, "enableTopic": true, "command": "powerOn", "networkUpdate": true, "volume": 1, "relativeVolume": false, "source": "extInput:tv", "port": 1, "zone": 0, "soundSettings": [ { "target": "soundField", "value": "clearAudio" } ], "soundTarget": "soundField", "modeSettings": [ { "target": "playType", "value": "normal" } ], "modeTarget": "playType", "x": 530, "y": 40, "wires": [ [ "3be72531.44fd6a", "85fcab98.427498" ] ] }, { "id": "63645d08.43b724", "type": "sony-audio-controller", "z": "953397ad.b56d58", "name": "switch to tv input", "device": "3a9732f0.b7e9de", "outputs": 0, "outputPorts": [], "outFilters": false, "outResponse": false, "enableTopic": false, "command": "setSource", "networkUpdate": true, "volume": 1, "relativeVolume": false, "source": "extInput:tv", "port": 1, "zone": "0", "soundSettings": [ { "target": "soundField", "value": "clearAudio" } ], "soundTarget": "soundField", "modeSettings": [ { "target": "playType", "value": "normal" } ], "modeTarget": "playType", "x": 1080, "y": 80, "wires": [] }, { "id": "3be72531.44fd6a", "type": "debug", "z": "953397ad.b56d58", "name": "amp on", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 680, "y": 140, "wires": [] }, { "id": "ff59514f.b4b11", "type": "inject", "z": "953397ad.b56d58", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 480, "y": 280, "wires": [ [ "63645d08.43b724", "450d9996.171128" ] ] }, { "id": "450d9996.171128", "type": "debug", "z": "953397ad.b56d58", "name": "injector debug", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 700, "y": 300, "wires": [] }, { "id": "b152dae.b42aa28", "type": "debug", "z": "953397ad.b56d58", "name": "talking", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 460, "y": 140, "wires": [] }, { "id": "85fcab98.427498", "type": "change", "z": "953397ad.b56d58", "name": "dummy injector", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 770, "y": 60, "wires": [ [ "63645d08.43b724" ] ] }, { "id": "abf8a9c6.0dd4b8", "type": "alexa-remote-account", "name": "bionicdude", "authMethod": "proxy", "proxyOwnIp": "192.168.1.67", "proxyPort": "3456", "cookieFile": "/usr/src/node-red/amazoncookie", "refreshInterval": "3", "alexaServiceHost": "alexa.amazon.co.uk", "amazonPage": "amazon.co.uk", "acceptLanguage": "en-US", "userAgent": "", "useWsMqtt": "on", "autoInit": "on" }, { "id": "3a9732f0.b7e9de", "type": "sony-audio-device", "name": "BionicAmp [STR-DN1080]", "host": "192.168.1.114", "port": "10000" } ]

and the error is 29/10/2020, 12:01:27node: switch to tv input msg : string[20] "Illegal Argument (3)"

jensrossbach commented 3 years ago

Hi,

the error message "Illegal Argument (3)" comes directly from your Sony device. The only assumption that I currently have is that maybe the device is not ready to switch the input immediately after powering on. Maybe it's worth trying to add a delay node before the second Sony node in order to wait a short time before switching the input.

Best regards, Jens

bionicdude commented 3 years ago

Hey,

Thanks for your reply. I tried with a delay and the results are the same. If i run the flow when the amp is already on and settled, the same result.

But it works fine if i trigger it manually with an inject node. Just never as part of a flow with preceding nodes

bionicdude commented 3 years ago

I finally managed to solve it. It seems the change source node really didn't like being afterthe power on node (anywhere after it in the same flow line) inline When i moved it off to it's own flow line (so running in parallel), it works fine. separate

jensrossbach commented 3 years ago

I think I know now what caused your issue. The output message of the first Sony node contains the properties service, method and version filled with the values according to the power on command. These properties were passed on to the second Sony node (your change node didn't touch them because you just changed the payload and these properties are outside of the payload property). The second Sony node then interpreted these properties as low-level request, ignoring the configured command (i.e. it didn't send an input switch command but another power on command to the device). But as the payload is used as "arguments" to the low-level request, it was also sent to the device. In both cases (with or without your intermediate change node) this was an illegal argument to the second power on command and therefore you retrieved the error.

In order to solve this without using your parallel approach as above, you should add a change node between the two Sony nodes which deletes the three properties service, method and version from the message.

bionicdude commented 3 years ago

And that's the kind of nuance I figured I'd be missing. Thanks for the follow up.

On Fri, 30 Oct 2020, 11:05 Jens Rossbach, notifications@github.com wrote:

I think I know now what caused your issue. The output message of the first Sony node contains the properties service, method and version filled with the values according to the power on command. These properties were passed on to the second Sony node (your change node didn't touch them because you just changed the payload and these properties are outside of the payload property). The second Sony node then interpreted these properties as low-level request, ignoring the configured command (i.e. it didn't send an input switch command but another power on command to the device). But as the payload is used as "arguments" to the low-level request, it was also sent to the device. In both cases (with or without your intermediate change node) this was an illegal argument to the second power on command and therefore you retrieved the error.

In order to solve this without using your parallel approach as above, you should add a change node between the two Sony nodes which deletes the three properties service, method and version from the message.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/jensrossbach/node-red-contrib-sony-audio/issues/24#issuecomment-719488746, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQWWT5JR7KJP2PWOSFX7LSNKMXVANCNFSM4TDUYFQQ .

jensrossbach commented 3 years ago

In release 1.6.4 which I published today, I made some fixes for chaining controller nodes. Now it should be possible to directly connect the nodes via the response message in a chain without any intermediate change nodes. In order to make this working, you have to ensure that the new option Enable Low-Level Request is deactivated in subsequent controller nodes. This prevents those nodes from interpreting the low-level information in the response messages of the preceding node.

bionicdude commented 3 years ago

even better. thanks for the update