Example: Using Rule Machine so I can ask Alexa to play the radio on my Sonos through Denon AVR X3400

This took some thinking and working out so I thought it might be useful for others. I wanted a simple Alexa command that enabled me to play Absolute Eighties Radio on the Sonos via my Denon AVR X3400 Receiver. Alexa doesn't play well with my Receiver and I thought this was an ideal opportunity to try using Hubitat to achieve what I wanted and with a bit of trial and error I ended up with the following steps that enabled me to succeed:

  • Hubitat automatically found my Denon AVR X3400

  • I Installed the Sonos Integration App in Hubitat and Hubitat then automatically found my Sonos devices. I had to choose which Sonos devices to show up in Devices.

  • Then I created a Virtual Switch Device called "Eighties Radio"

  • And I Installed the Amazon Echo Skill in Hubitat

  • I exposed the "Eighties Radio" Virtual Switch to my Echo device via the Amazon Echo Skill by adding it in to the list of devices to be exposed to the Echo device.

  • I configured the Hubitat skill in Amazon Alexa App so I could see all Hubitat devices that I'd chosen to expose to Alexa in the Hubitat App.

  • I creating a Routine in Amazon Alexa App to power on the "Eighties Radio" Virtual Switch when I said "Alexa, Listen to Absolute Eighties"

  • Then I wrote a rule in the Rule Machine that activated when the "Eighties Radio" Virtual Switch turned on.
    Select Trigger Events
    Eighties Radio (off) turns on

    Select Actions to Run
    on(1) on Denon AVR X3400
    setInputSource(5) on Denon AVR X3400 --> delayed: 0:00:05
    Front Room Sonos: Play Track: aac://https://stream-ar.planetradio.co.uk
    Off: Eighties Radio


  • The Denon AVRX3400 device learns its inputs by the receiver being on and you moving between the different inputs. This is detailed here: Denon AVR Support
  • To create the right commands in the rule engine for the Denon Receiver, I used the "Set Mode, Variables or File, Run Custom Action" and chose "Run Custom Action" and then chose "Switch" and chose my Denon Receiver as the Switch before choosing the custom command and the right variable option and the contents of the variable, i.e. number and 1 for turning the Denon on.
  • I setInputSource to 5 because that's my CD input which is where my Sonos is attached, your InputSource number might be different
  • I delayed the setInputSource command to give the Denon a chance to power on and be ready to accept further commands
  • To find the right Play Track details, I went in to my Sonos app on my phone and played Absolute Radio. I then went in to the appropriate Sonos device in Hubitat and copied the code from the uri line in the state variables. Your code may well be different. In case the 1st.skey value is particular to me, I've just replaced it in this example code with 1234567890.
  • The last thing the rule does is turn off the virtual switch "Eighties Radio" so it can be used again. I did read that Hubitat was bright enough to switch the virtual switch off automatically, but I've yet to see that.

I've not yet created a Rule for "Alexa, Stop Listening to Eighties Radio", but I guess if I removed the bit about turning the virtual "Eighties Radio" button off, then I could set up "Alexa, Stop Listening to Eighties Radio" as a routine that turned the virtual button off which had another Rule Machine rule set up that turned the Denon AVR off and stopped the Sonos from streaming. Should be simple now I've learnt all the above! :slight_smile:

Hope that's useful.


And mine's a large cod & chips with mushy peas please. Oh, and a pickled onion, slice of buttered white bread and a mug of hot tea, 1 sugar. God, that's making me miss good ol' Blighty. So hungry now. Thanks @chipshopman ! :crazy_face:

Thanks for sharing.

I have a simpler version to start my Yamaha amp to play classical music using network radio, triggered by Alexa through HE.

The Yamaha integration with HE is not as straightforward. I did not considered integrating it through Alexa. That is a very good idea.

As a matter of fact I created a virtual dimmer in HE which is recognized by Alexa, and is used to adjust the volume on the amplifier through a ā€œtrackā€ command in Rule Machine.

Love your solution!

Like the idea of the virtual dimmer for controlling volume in Alexa... Will try that.

Haha! Sorry about that. But, don't forget the pineapple fritter for afters.

1 Like