Just want to share another version of automation using custom component pyscript (GitHub - custom-components/pyscript: Pyscript adds rich Python scripting to HASS). I personally think this is way better than YAML, especially when you have multiple Nest Hubs to cast. To use the following script, you just need to update the first two global variables.
_DASHBOARD_URL = 'http://xxx.xxx.xxx.xxx:8123/'
# The part after 'media_player.'
_NEST_HUBS = ['nest_hub_living_room', 'nest_hub_study']
def nest_hub_trigger_factory(nest_hub):
entity_id = f'media_player.{nest_hub}'
avail_state = f'pyscript.{nest_hub}_availability'
state.persist(avail_state, default_value='1')
@state_trigger(f'{entity_id} == "off"', state_check_now=True)
def recast_nest_hub():
if state.get(avail_state) == '0':
log.info(f'{entity_id} was unavailable. Wait for 20 secs')
state.set(avail_state, '1')
task.sleep(20)
log.info(f'Recast {entity_id}')
media_player.volume_set(entity_id=entity_id, volume_level=0)
dash_cast.load_url(entity_id=entity_id,
url=_DASHBOARD_URL, force=True)
@state_trigger(f'{entity_id} == "unavailable"', state_check_now=True)
def nest_hub_is_unavailable():
log.info(f'{entity_id} is unavailable')
state.set(avail_state, '0')
return recast_nest_hub, nest_hub_is_unavailable
_triggers = [nest_hub_trigger_factory(nh) for nh in _NEST_HUBS]
Thanks for the pyscript. I tried and the script works smoothly,
but still dashcast would activate for the untargeted device.
I have 1 nest hub, 2 Chromecast for Google TV and 2 nest mini (which is stereo paired)
So the nest hub that I want to cast the dashboard is only one.
I have found that if I make a group in google home app and include the stereo paired nest mini
in any group, it would activate dashcast on the nest mini and the prompt sound comes out.
If I don’t, only nest hub would activate dashcast.
Chromecast for Google TV will be affected as well if included in the group where nest hub is also in the group.
So getting rid of groups totally, now it all work as expected. @chiahsing , could you please try to make a group and include 2 of your nest hubs in there?
If you dashcast to one nest hub, my issue is that it would also activate dashcast on the other nest hub.
You may find that it is weird, but that is what I am experiencing, and again casting directly with catt command, no issues at all.
I don’t really trust the grouping in Google Home. It has other issues. But in your case, I think you can also try using catt. It doesn’t really matter how you cast the dashboard. It’s just easier if DashCast integration works for you.
@chiahsing
Yes, maybe in my environment, casting with catt is proven to work already so it might be the best way.
Anyway, I thank you for giving us a head up to this integration.
Update: The weird problems are gone now I believe because of the recent updates of pychromecast. Dashcast integration is working perfectly.
Thanks, the script is working great. I have one issue, though: I am using the Nest Hub also as a controller for my Nest Doorbell. If someone rings the doorbell, the image appears briefly and is then immediately replaced by the HA dashboard. Would it be possible to amend the script to either give priority to the Nest Doorbell or, if that is too complicated, just add a certain delay (e.g. 1 minute) before the HA dashboard is recast?
Thanks a lot! I went with your suggestion but the doorbell video feed is apparently not treated as an app. The attribute keeps showing the most recent app while the feed is on. So I went with the delay, and also commented out the media_player.volume_set to 0 so I can hear the doorbell chime.
You need to configure trusted network because you won’t have the keyboard to type the username and password. And once it is confitured, you tick the “Keep me logged in” box and press the hidden trusted network function under the usernamd and password fields. The option is somtimes hidden due to some CSS issue, but you can still click on it.
value_template needs to be wrapped in double quotes to avoid the Message malformed: extra keys not allowed @ data['sequence'][0]['sequence'] error. This thread is full of mistakes
This is the script that I have been using w/o the need for an add-on:
thanks @chiahsing , just found this discussion. I am interested in setting this up for my home. Just wondering whether this only works with 2nd gen of Google Nest Hub ?