Hello.
I want to share something with you. Last week i decided to make a Ambilight for my not-so-smart TV Samsung 65’.
My set is:
- Raspberry Pi Zero 2W,
- Chromecast 4 with Raspbian and Hyperion,
- Cheap chineese HDMI => USB Audio Video Grabber without HDMI-CEC (i can’t turn off device with that).
- Not-so-smart TV Samsung (your tv has to be connected to homeassistant, and has to be found as “media player”.
So, firstly i made integration that turning on/off Chromecast via Homeassistant automation with Google cast integration . I had 2 problems: Splashscreen “WELCOME TO HOMEASSISTANT” on start Chromecast, which is not so nice view, especially with Ambilights. Second thing is that its wasn’t so responsive, i had to click “back” on remote couple of times to turn off this screen. I hate it.
Second problem was that when i used “media_player.turn_off” action it wasn’t turning off my chromecast. It didn’t went sleep. It just stopped streaming from Hass to Chromecast.
Third, Chromecast is weak with state changes. When my CC is turned off i have to wait about 30 seconds for Homeassistant state change. Maybe it works good in your case?
I saw it on preview in Hyperion. Device was working, and sending current Chromecast screen live. I have seen it on animations it wasn’t just “last frame before stop”. Like on image below.
So i started to make my research and didn’t found an answer for my problem.
After time i realised that i need something else. I have found Android TV Integration. And it made a job.
Now im sending “WAKEUP” and “SLEEP” adb commands via AndroidTv integration and it works really good.
Okay, so instructions:
Chromecast preparing:
- Go to
Settings
(your picture on right, up corner => settings) - Go to
System
- Click
About
- Find
Android TV OS build
- Pick it from list and “click” on it 7 times.
You are developer now!
- Go to
Remotes and accessories
- Find something like “Buttons settings”
- Configure power button to power on/off your television (its propably CEC now)
- If you can’t do that, try to configure your TV in chromecast settings. It has plenty of futures.
Make sure your chromecast remote is turning off/on your tv.
Okay, so we are ready to prepare script. You can remove lights from it because i guess its not only problem.
Explanation:
- Detect state change of your TV
- Ensure what it did (on? off? else?)
- Wait a second to hass is informed about change
- Make CC actions.
alias: Samsung and chromecast
description: ""
trigger:
- platform: device
type: changed_states
device_id: #pick your TV
entity_id: #pick your TV
domain: media_player
condition: []
action:
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: state
entity_id: #pick your TV
state: "off"
then:
- service: androidtv.adb_command
data:
command: SLEEP
target:
entity_id: #pick your chromecast Android TV Instance
- service: light.turn_off
data: {}
target:
entity_id: #pick your ambient Hyperion LED instance
else:
- service: androidtv.adb_command
data:
command: WAKEUP
target:
entity_id: #pick your chromecast Android TV Instance
- service: light.turn_on
data: {}
target:
entity_id: #pick your ambient Hyperion LED instance
mode: single
Now, you don’t have a HASS Splash screen, and you are saving compute power of your Chromecast, and not waisting your electrocity.
Good to know:
-
WAKEUP
is just “OK” button on remote. It is described in
Bonus: Android tv integration:
- Go to AndroidTV Integration in home-assistant website
- Click integrate
- Set “Auto”
- Give Chromecast IP
- Do not change anything more
- Submit
Test it:
http://your-hass-address/developer-tools/service
- Find
Android TV: ADB command
-
Choose entity
-
Use
SLEEP
andWAKEUP
command, and check your Chromecast reactions.
Thats my case. Thats what i wanted to share with you.
Thanks for reading.
Bonus 2 my setup. White box under HDMI Thief is Raspberry Zero with 3d printed case:
And final effect:
Xmass tree is also made with hyperion and RB Zero
Whole stuff has Wife Acceptance Certificate with A+ mark.