Hey everyone!
I’ve been wanting a Nest Hub for a while now, as a replacement for an old Nexus 7 dashboard that gave up the ghost a while back. Finally pulled the trigger over the weekend and I was excited to get started casting my Lovelace dashboard to it.
It worked beautifully using https://cast.home-assistant.io/, I could cast any tab from my default Lovelace with only minor problems (mostly some custom cards that did not seem to be supported). But my excitement lasted only as long as it took the Nest Hub to turn on photo mode. So, while it works great as a test, I really didn’t feel like casting via a website was going to be very convenient or sustainable for me.
So I started playing with service calls to test before writing an automation to handle the casting for me. To my surprise, I was getting some weird results. I could get the right view to show up by calling the service as shown below, but once Google took back over and I wanted to cast again, I ran into three problems:
- Calling the service did nothing at all unless I woke the device up first
- The same service call would either result in a “dashboard not found” message when specifying a view_path, OR if I changed it back to ‘0’ it would show the standard auto-generated lovelace config with everything.
- There’s no state change in HA when the device transitions into photo mode
I also didn’t find a lot of information about this behavior here or anywhere else really, aside from the post Automatically Cast Home Assistant to Nest Hub? where I saw the technique of casting a “wrong” view, waiting five seconds, and then casting the desired view.
I also had a problem with needing to wake the thing up before casting would be successful. So I ended up adding to that automation… mine looks like this now:
- id: '1591682005536'
alias: Test Nest Hub
description: ''
trigger:
- event: start
platform: homeassistant
- entity_id: media_player.kitchen_display
platform: state
to: 'off'
action:
- data:
entity_id: media_player.kitchen_display
service: media_player.turn_on
- delay: '00:00:05'
- data:
entity_id: media_player.kitchen_display
view_path: lovelace
service: cast.show_lovelace_view
- delay: '00:00:05'
- data:
dashboard_path: lovelace-cast
entity_id: media_player.kitchen_display
view_path: home
service: cast.show_lovelace_view
The triggers never actually happen, of course (unless I restart HA – the state never transitions to ‘off’ or even ‘idle’ for me). So I set up a flow in Node-Red to trigger this automation every ten minutes and it’s been working reliably for the past day or so.`
It’s pretty simple: every ten minutes, we turn the media_player entity back on, cast the wrong view, wait five seconds, and cast the right view. The only irritating thing is if you’re trying to use the display for… well, i guess literally anything else, you have at most ten minutes to do so until the automation brings it back to lovelace. I guess I could build a condition into the Node-Red flow to see if anything else is going before triggering the automation, but realistically I don’t know how much of a problem that’s going to be.
It’s a bit of a hack, but I’m happy to have it working. I didn’t see a lot of posts on this topic so I thought I’d post here for anyone running into the same problems I did.
Also half hoping that the old adage of posting something wrong on the internet is the best way to get the right answer in case anyone is offended by the admittedly inelegant nature of my solution.
Anyway, thanks for looking, and hope someone else finds this useful, or at least interesting!