I’d like to share my simple project that I made to control my Chromecast Audio with standard IR remote from stereo it’s connected to.
I did it to ease changing songs for my family when I play music from Google Music on Chromecast Audio and they don’t have access to my phone cause I’m in the other part of house. The stereo itself cannot control chromecast because it’s connected to simple jack-jack cable.
Important thing is that I don’t know much about electronics, even less about arduino programming so I used prebuild, precompiled components.
What I used:
- media player - I used Chromecast Audio connected to old Sony Stereo via Audio In
- HA running on anything, recognizing your media player. My Chromecast is getting auto discovered so no problem there.
- MQTT server which is listened by HA
- ESP8266
- ESPEasy software (my version is 120)
- IR receiver - I used ready Ir component which I think is based on TSOP4838 (recognized by ESPEasy)
- connection cables
- remote control - it can be any remote but for my family’s convenience I use the one from Sony stereo to which my Chromecast Audio is connected.
Pictures of the hardware:
- ESP 8266 - Lolin Board:
- IR receiver - prebuild from YWRobot
- whole set put together:
What I’ve done with it:
- setup HA, media player, MQTT
- flashed ESPEasy on ESP8266 board - standard precompiled file from ESPEasy project’s page
- Connected ESP to Wifi and connect it to my MQTT server on Config page:
- Connected IR remote to 3V, GND and data pin
- configured IR on devices page of ESP:
- Now was the harder part. I needed to get what codes are sent when pressed which buttons. Luckly ESPEasy shows values received by IR on it’s web page. So I’ve pointed remote to receiver, pressed desired button, refreshed the page and checked the code. It looked like that:
In the example I pressed on/off button on remote so the code for my remote’s on/off is 2145523267. - When I got all the codes I wanted I wrote automation part for Home Assistant. In my config ESP sends MQTT message in format /ESPname/Name of Device/Value Name and the payload of the message is the IR code. It looks like that in MQTT reading software:
So the automation part was quite simple now:
automation:
# Controling Chromecast Audio from remote
- alias: ‘Song forward’
trigger:
platform: mqtt
topic: “/Esp03/IRda/IR”
payload: ‘2152563055’
action:
service: media_player.media_next_track
entity_id: media_player.chromecastaudio- alias: ‘Song reverse’
trigger:
platform: mqtt
topic: “/Esp03/IRda/IR”
payload: ‘1788844172’
action:
service: media_player.media_previous_track
entity_id: media_player.chromecastaudio- alias: ‘Song play’
trigger:
platform: mqtt
topic: “/Esp03/IRda/IR”
payload: ‘862875138’
action:
service: media_player.media_play
entity_id: media_player.chromecastaudio- alias: ‘Song pause’
trigger:
platform: mqtt
topic: “/Esp03/IRda/IR”
payload: ‘1580485439’
action:
service: media_player.media_play_pause
entity_id: media_player.chromecastaudio
- restart HA and enjoy controling chromecast from remote.
In my set up I configured the on/off button to turn off Chromecast, I’ve put ESP with receiver behind stereo so when I turn off chromecast it also turns off the stereo.
It’s not visible at all and this IR receiver gets the Ir codes very well when I point at the stereo.
The only problem I have with the setup is changing song to previous one, it simply restarts it. Simlar to pressing once rev on remote to pressing it twice quickly.
I think it’s a problem with HA implementation of control for Chromecast rather that my setup because I also cannot do it from HA page.
If you have any ideas of adjusting the setup please let me know.
Hope my guide is clear and will work for you:)