Sunday, 13 December 2020

Marantz / Denon IP Control in Node-Red

I'm enjoying my recently acquired Marantz AV8805 processor which is now the heart of my Home Cinema. My previous trusty SR7010 receiver is still working hard as a power amp, driving surround and height channels.

One of the challenges of running in this kind of configuration is that both units respond to the same remote control signals. I have switched off remote receiving on the SR7010 as I just want it to behave as a power amp. However, as the 7010 has no trigger inputs (alas, only outputs), the problem remains of how to power up the SR7010, and power it down, in tandem with the AV8805.

Here's the end result;


Here's how this was done in Node-Red....

I use Node-Red for a lot of my automation needs, but hadn't previously done any IP control of AV devices. My first thought was to intercept remote commands from my Harmony Hub and build actions based on that. (there's a node for that!). However, in the end, I figured direct control would be best.

Searching for 'Marantz' in the Node-Red Palette Install section, one option shows up that looks like it might fit the bill;


On testing, though, and on careful reading of the documentation, it turns out that while this promises Input and Output nodes to read and write events and commands, only the output node is functional. However, it does work to send commands as can be seen in this small setup;



The output node is configured to connect to the SR7010 on Port 80;



The Injection nodes are configured to send on and off commands;


And this works. Well, at least for the SR7010. For some reason, when I set up a second node to send commands to to the AV8805, that unit shows up as inactive, even though the configuration is identical, apart from the IP address. In both cases, IP control settings in the Marantz units are set to always on. I'm not sure why this is. In my scenario, I don't need to send commands to the AV8805, but if I did need to in future, I'd need to find a solution to this.

The IP protocol is described in documents that can be found on the product pages on the Marantz website. There's a more detailed document that describes both the protocol and all the available Denon commands that I found here.

Once I'd confirmed my ability to send power commands to the SR7010, it was time to find a way of figuring out when the AV8805 was switched on and off.

Thinking laterally, I searched Node-Red for Denon nodes;


The node-red-contrib-denon node is similar to the Marantz one I'm using already, but again, I couldn't get the Input node to work, and in fact the whole thing crashed my Node-Red, so I gave up on that and installed the chaws option.

This provided an input node only. It listens on port 23 for events and spits them out. As I already had the output working for commands, this was all I needed;



The switch node is configured to filter out a seemingly constant stream of raw buffer events;



With that in place though, the node happily reports events as they happen on the AV8805;



So, now I can capture power events from the AV8805, and send power events to the SR7010. Time to bring it all together;



Here we have the AV8805 events passing through a switch to remove the 'raw' data and pushed on to a debug node and a second switch that reads the event type;


This then calls either the On or Off functions that contain a very basic script with the relevant JSON that's then passed into the SR7010.


Net result: when the AV8805 is powered on or off in any way (remote control, Marantz app, pressing the physical power button), the SR7010 follows suit. Here's a sequence where the AV8805 is powered on, then off a short time later. 


This achieves everything I need for now. That I have events streaming from the devices is useful for future automations like, for example, bringing up the lights when the units are powered off, so I can see my way out of the room!

Here's the Node-Red export for the above flows;

[{"id":"db3e257b.b46038","type":"debug","z":"bb6157c.e254fa8","name":"Marantz AV8805","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1420,"y":580,"wires":[]},{"id":"155239ff.b93336","type":"marantz-http-out","z":"bb6157c.e254fa8","name":"SR7010","controller":"8f628e5c.6925a","x":1600,"y":820,"wires":[]},{"id":"234a69c5.7aead6","type":"inject","z":"bb6157c.e254fa8","name":"Power Off","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"cmd\": \"power\", \"value\": \"off\"}","payloadType":"str","x":1080,"y":800,"wires":[["155239ff.b93336"]]},{"id":"dccee7dc.d6c118","type":"denon-in","z":"bb6157c.e254fa8","name":"AV8805","connection":"d5279c32.3382","x":1050,"y":640,"wires":[["3e11e283.9deb2e"]]},{"id":"b6b5227c.10248","type":"denon-in","z":"bb6157c.e254fa8","name":"SR7010","connection":"12bc4cf2.bab933","x":1050,"y":480,"wires":[["72f6f18.f5ea41"]]},{"id":"3b6737a6.9f1ea8","type":"switch","z":"bb6157c.e254fa8","name":"filter events","property":"payload.event","propertyType":"msg","rules":[{"t":"eq","v":"mainZoneOn","vt":"str"},{"t":"eq","v":"mainZoneOff","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":680,"wires":[["a1544569.86b9e8"],["7854910c.17ba5"]]},{"id":"86f3b6aa.f82938","type":"debug","z":"bb6157c.e254fa8","name":"Marantz SR7010","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1390,"y":480,"wires":[]},{"id":"72f6f18.f5ea41","type":"switch","z":"bb6157c.e254fa8","name":"filter 'raw'","property":"payload.event","propertyType":"msg","rules":[{"t":"neq","v":"raw","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1200,"y":480,"wires":[["86f3b6aa.f82938"]]},{"id":"fb323670.3c2018","type":"inject","z":"bb6157c.e254fa8","name":"Power On","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"cmd\": \"power\", \"value\": \"on\"}","payloadType":"str","x":1080,"y":860,"wires":[["155239ff.b93336"]]},{"id":"7854910c.17ba5","type":"function","z":"bb6157c.e254fa8","name":"Power Off","func":"msg.payload = {\"cmd\": \"power\", \"value\": \"off\"}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1420,"y":700,"wires":[["155239ff.b93336"]]},{"id":"a1544569.86b9e8","type":"function","z":"bb6157c.e254fa8","name":"Power On","func":"msg.payload = {\"cmd\": \"power\", \"value\": \"on\"}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1420,"y":660,"wires":[["155239ff.b93336"]]},{"id":"3e11e283.9deb2e","type":"switch","z":"bb6157c.e254fa8","name":"filter 'raw'","property":"payload.event","propertyType":"msg","rules":[{"t":"neq","v":"raw","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1200,"y":600,"wires":[["db3e257b.b46038","3b6737a6.9f1ea8"]]},{"id":"8f628e5c.6925a","type":"marantz-http-controller","name":"SR7010","host":"192.168.1.10","port":"80"},{"id":"d5279c32.3382","type":"denon-connection","name":"AV8805","address":"192.168.1.85","port":"23"},{"id":"12bc4cf2.bab933","type":"denon-connection","name":"SR7010","address":"192.168.1.10","port":"23"}]



No comments: