[RELEASE] - Denon HEOS Integration

I've decided to build a Denon HEOS integration. I had currently been using the DLNA integrations available which isn't great. I recently discovered the HEOS CLI and it's pretty straightforward. I also seem some drama around Sonos and figured why not?

One thing I need help with, I want to make it similar to the Sonos integration. However, I don't really know what the Sonos integration has as features. Can anyone share some info?

Should be a fun project, I haven't yet played with SSDP, XML, and Telnet using HE before. Fun stuff to learn. I already have the SSDP discovery working so that it detects all the HEOS devices on my network. Getting somewhere!

@marktheknife

9 Likes

This is great, thanks for looking into this!

I have only one Sonos device, the ikea speaker, and I don’t even use it that much (compared to my HEOS setup). But when I get home tonight I can paste some screenshots from the device settings page, if that helps?

Perfect!

1 Like

OK sorry for the delay, this is what I can see in a sonos device's settings page.

Here's the commands:

And the current states:

* level :  **52**
* mute :  **unmuted**
* status :  **stopped**
* trackData :  **{"audioSource":"Sonos Q","station":null,"name":"Freedom","artist":"Jurassic 5","album":"Power In Numbers","trackNumber":"1","status":"stopped","level":"52","mute":"unmuted","uri":"x-rincon-queue:RINCON_347E5C354DBC01400#6","trackUri":"https://d3rz60g1mtspwx.cloudfront.net/97cc94d4-2208838686%2F90e9e4b2-008d-3ba4-be66-3d303223c30c.flac?Expires=***&Signature=***&Key-Pair-Id=***","transportUri":"x-rincon-queue:RINCON_347E5C354DBC01400#6","enqueuedUri":"http://192.168.0.57/tts/4594d3b0036b4e888cc777602a78b591.mp3","metaData":"Alexaobject.item.audioItem","trackMetaData":"https://d3rz60g1mtspwx.cloudfront.net/97cc94d4-2208838686%2F90e9e4b2-008d-3ba4-be66-3d303223c30c.flac?Expires=***&Signature=***&Key-Pair-Id=***https://m.media-amazon.com/images/I/81PdtbLNjZL._UL600_.jpgobject.item.audioItem.musicTrackFreedomJurassic 5Power In Numbers505295c7-ea8b-4f45-962e-332cc03eb771"}**
* trackDescription :  **Freedom by Jurassic 5 from Power In Numbers**
* volume :  **52**

The state variables:

* restoreTrack :  **0**
* restoreLevel :  **0**
* restoreURI :  **0**
* uri :  **x-rincon-queue:RINCON_347E5C354DBC01400#6**
* trackData :  **{"audioSource":"Sonos Q","station":null,"name":"Freedom","artist":"Jurassic 5","album":"Power In Numbers","trackNumber":"1","status":"stopped","level":"52","mute":"unmuted","uri":"x-rincon-queue:RINCON_347E5C354DBC01400#6","trackUri":"https://d3rz60g1mtspwx.cloudfront.net/97cc94d4-2208838686%2F90e9e4b2-008d-3ba4-be66-3d303223c30c.flac?Expires=***&Signature=***&Key-Pair-Id=***","transportUri":"x-rincon-queue:RINCON_347E5C354DBC01400#6","enqueuedUri":"http://192.168.0.57/tts/4594d3b0036b4e888cc777602a78b591.mp3","metaData":"Alexaobject.item.audioItem","trackMetaData":"https://d3rz60g1mtspwx.cloudfront.net/97cc94d4-2208838686%2F90e9e4b2-008d-3ba4-be66-3d303223c30c.flac?Expires=***&Signature=***&Key-Pair-Id=***https://m.media-amazon.com/images/I/81PdtbLNjZL._UL600_.jpgobject.item.audioItem.musicTrackFreedomJurassic 5Power In Numbers505295c7-ea8b-4f45-962e-332cc03eb771"}**

Let me know how else I can help. Thanks again!

2 Likes

Thank you, that's perfect. I'm making some headway!

Sweet! I’m out of town and won’t be back til Monday. But obviously I’m more than happy to test anything out that you’re able to get working by then.

Sounds good. I'm making progress, I have all the volume control commands working. This has proved to be a little more difficult than I thought it was going to be because I can't do telnet from an app. However, HEOS routes all commands through a single device. So what I basically had to do is declare one device the "master" which sends the commands. Anyway, it's solveable, just some extra technical challenges I have to think through.

Anyway, looking at your Sonos screenshot, does it not allow you to set the music source? Like Spotify or Amazon? Just to skip to the next track? Also how does the Sonos integration handle speaker groups?

Update: Making good progress so far, I can set volume, mute/unmute, stop/play/pause, next track, previous track. TTS is giving me a lot of difficulty so far. When I try it I'm generally causing the speaker to freak out and skip tracks like crazy. Occasionally it works. I think that's the last big thing to figure out.

Otherwise so far so good:

I haven’t messed around much with the Sonos integration. I’m not sure if the driver can set/change sources, though I’m guessing you can play a specific track from a given source if you know the track URI?

In the screenshot I posted, I had recently set something to play on the Sonos speaker with amazon music through the alexa app (since I’m not at home and can’t do it directly through the Sonos app).

I know that I can send a TTS command to the Sonos speaker, would it help to see a screenshot of the current states after that command is sent?

Also I believe @aaiyar uses Sonos, and he’s a nice guy so maybe he can tell us a bit more about how the integration functions with hubitat? :grin:

1 Like

The HEOS doesn't seems to really like when I tell it to play an MP3 file directly. I think that's the problem with the TTS. Not sure what's up yet. I'll have to do some debugging probably tomorrow. I should be able to have an alpha together by tomorrow that supports everything except TTS and playing URLs. Another limitation is I haven't yet come up with a way to validate the HEOS username/password you enter - so make sure it's correct otherwise it won't work properly. Also, it doesn't currently like if you turn a device off. I haven't built reconnect logic in at all yet. Like I said, it'll be an alpha version, but it's getting there! :slight_smile:

Edit: Actually, I'm getting weird stuff just using the HEOS app. If I play a song from my iPhone it plays fine, then the speaker freaks out and the now playing just keeps switching... wondering if that's just me? I tried restarting the speaker, no change.

Edit Again: Figured it out, playing URLs and TTS now works. Functionally I have it reproducing what the Sonos app does. My next step is going to be to try to add some better error handling and make it more stable. After that I'll work on adding some things the Sonos app doesn't have. I'd love to make commands so you can, for example, run a command to "play top hits on amazon music" for example. Then I want to see what can be done about groups. So far so good though.

2 Likes

Good to hear it’s coming along.

This could be a simple question, but does the app create virtual devices for each HEOS device? I’m wondering if it’s possible to use play/stop status as a trigger in rule machine, or make use of the track data in a dashboard tile. That would require devices right?

Yes, each detected speaker (or soundbar, or avr, or whatever) is created as a device.

I have the alpha code together now. It definitely needs some testing. I'm going to be unable to work on it for at least a week but for anyone out there, let me know how it goes. I do plan to make updates.

I'm really interested in finding a way to incorporate groups into this but I'm not entirely sure how I want to do that just yet... If anyone has thoughts that'd be great.

You can find the code and directions at GitHub - dcmeglio/hubitat-heos

1 Like

Can’t wait to try it out tomorrow after I get home!

OK, I haven't fully tested this.. but this is something I've been waiting for. I have my Denon set as my Google Home's default bluetooth speaker. But I also use a Harmony Hub to control my home theater system.

If I tell Google Home to play music, it turns on my Denon and begins playing. However, Harmony is blissfully unaware and gets unsync'd from my system. Thanks to this app...

If Denon status is PLAYING && Harmony status is POWEROFF -> Turn on Harmony Child (Play Music)

@dman2306 I just wanted to say thanks again for creating this integration. After working a few kinks out with my HEOS groups, it's working great for me!

One feature request:

  1. Is it possible to break up the various parts of the "trackData" into separate custom attributes? That would open up several opportunities for dashboard tiles (like showing the album art for the currently playing track).

I'm always happy to test out any changes if you decide to develop this further!

Yeah. I should be able to look at that this weekend. So like track, album, and artist?

1 Like

Hello, I am curious in what you are doing. I have installed the Driver and App code. In the documentation it says to install Denon HEOS Speaker driver.
This is where I get confused. I can create a virtual Denon HEOS Speaker device so I assume the Denon HEOS Speaker driver is in your driver code. After installing the App code and go to the Apps menu I don't see an app to perform the configuration. What am I doing wrong. Help would be appreciated.

You need to click the add user app button and install it from there.

Duh, I should have known. Thank you.

Out of curiosity I tested with a Marantz NR 1608. When the Marantz input is set to Media the commands I tried work. I am Currently using Hubitat built in Denon driver for the Marantz. It works well enough except there is no way start playing once Media input is selected. Your code does allow play/pause/stop. I can finally put in place the final piece to complete my Bedroom TV automation. This is perhaps an unexpected use case but many thanks for your hard work.

Grab the latest app and driver, there are now separate artist/track/album attributes

1 Like