Before using Home Assistant, I had my own homebrew web-server setup to monitor and control lots of things around the house. This included a way to control my HEOS speakers and AVR. This worked perfectly and was very stable. With only the minor inconvenience of friends announcing their arrival by getting on my WiFi and turning up the volume or messing with the music instead of ringing the doorbell.
In the age of Home Assistant it should be much easier though. It SHOULD, but is isn't for me and I don't know why. I'm running Home Assistant Core on a Raspberry Pi 4 with an SSD.
Home Assistant has an integration for HEOS:
https://www.home-assistant.io/integrations/heos/
I've never been able to get it to operate smoothly. It won't find my devices. When it does, it complains about needing to be logged in. I don't understand, because I can telnet in to the devices and everything works and responds as expected.
Anyway, this frustrated me so much, I decided to roll my own. With all the work I've already done on running python scripts as a service, Raspberry Pi, Home Assistant MQTT autodiscover and commanding the HEOS what tot do over a TCP-IP socket, this should be easy.
It's a nice exercise and continuation for some of my other projects. Mostly, it's just a quick and dirty way to set up the speaker in my bedroom to be included in my wake-up sequence. Also, to set scenes and start or stop playing music when I use the NFC-tags I have all over the house.
What it WON'T do: Get any information back from the HEOS devices or do any automatic configuration of names or media info.
Basic setup:
Python script will run as a service/daemon on a Raspberry Pi. This is the same Pi that runs HA, and the MQTT-broker, but that's not required. These three tings can be setup on three different machines, that's the beauty of the MQTT-protocol.
The script will publish messages to config topics for Home Assistant to setup devices with some action/buttons automatically. For each device, it will have buttons to:
- Play
- Pause
- Volume up
- Volume down
- Next
- Group
- Ungroup
It will also listen to a specific topic for raw commands, witch it will pipeline directly to the HEOS-device. Maybe its easier to just use the TCP-integration in Home Assistant though.
https://www.home-assistant.io/integrations/tcp/
Because now, I still have to setup scripts in Home Assistant and using this MQTT-service will just add another layer. Anyway, I will add it. It's never bad to expose it to all other devices. Now my Roomba can play some tunes if it feels lonely when I'm away. That will keep it from chewing on loose cables.
I have three separate HEOS devices:
- An AVR-X2400H: https://www.denon.com/en-us/product/av-receivers/avr-x2400h
- A HEOS3: https://www.denon.com/en-za/shop/speakers/heos3hs2
- A HEOS Link: https://www.denon.com/nl-nl/product/network-audio-players/heos-link-hs2
These will have their own "device" in Home Assistant, with buttons/actions. All buttons of the same device will listen to the same command topic.
The code is not pretty. With a lot of repetition and stuff hardcoded in. But hey, if it works...