Hey there,
for all that maybe have the same Problem, that the Casting after 20 seconds stops and restarts, and it keeps on doing that.
I’m really new to HA (basically started today XD), I’m not completely sure if its the right way to fix it but it works for me so maybe give it a try ;).
So basically the problem was that the TRIGGER that restream the Dashboard when you have used it for like Streaming music or something else and then stopped it or just paused it (which happens when you tell Google to stop streaming music, it dosen’t actually stop it and just pauses it idk why).
Because the MediaPlayer that is used to show the Dashboard onto the Google Cast device, gives back the status paused all the time when streaming it onto a Google Cast device.
So the thing i did was replacing the TRIGGER statement from “to: paused” to “from: playing”, I tested it by just waiting and seeing if the problem still occurs, which didn’t happen, then i tried to play some music over VoiceCommand which worked fine and played for some time without being interrupted.
And after stopping/pausing the music it recasted the dashboard onto the Hub.
Im not quiet sure if it could cause problems with other use cases, but when I quickly think of it it should work with everything that just has the status playing when its beign casted onto the Hub.
And just as a tip, u can easily tune the timings in the Automation if you don’t want to always start the recast so quickly, by just editing the time when the TRIGGER starts.
As I said im new, that’s why i didn’t wanted to put this new Code into a Blueprint if that would be even possible here?!
So I would suggest if you just do it as I did, create a new empty Automation, then switch to the YAML Editor, by clicking on the 3 dots on the top right and then paste and replace the code into there, then just replace these brackets → “[…]” with your information (Google Cast device name with spaces replaced with underlines → “_” ; and the dashboard_path with your sidebar card name that you want to stream → http://homeassistant.local:8123/["what ever is in here"]/dashboard
; and the view_path with which card from the top at your Dashboard you wanna stream).
alias: Lovelace Dashboard Cast
description: 'Casts a Dashboard of your choice to a Google Cast device, it also recasts it, if it is stopped or another kind of streaming has been paused for 10 seconds (time is adjustible have a look at the code in the YAML Editor) '
trigger:
- platform: state
entity_id: media_player.[yourHub]
for:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0 #change the time here for when the recast should trigger when a streaming is turned off#
to: 'off'
- platform: state
entity_id: media_player.[yourHub]
for:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0 #change the time here for when the recast should trigger when a streaming is beign paused#
from: playing
- platform: time_pattern
minutes: /9
- platform: time_pattern
minutes: '0'
action:
- choose:
- conditions:
- condition: or
conditions:
- condition: state
entity_id: media_player.[yourHUB]
state: 'off'
- condition: state
entity_id: media_player.[yourHUB]
state: paused
for:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0 #change the time here for when the recast should trigger when a streaming is beign paused#
sequence:
- service: media_player.volume_mute
data:
is_volume_muted: true
entity_id: media_player.[yourHUB]
- service: media_player.turn_off
data:
entity_id: media_player.r[yourHUB]
- delay:
seconds: 2
- service: media_player.turn_on
data:
entity_id: media_player.[yourHUB]
- service: cast.show_lovelace_view
data:
view_path: [card name/url from the Dashboard ur streaming]
dashboard_path: [...] #(http://homeassistant.local:8123/["what ever is in here"]/dashboard)#
entity_id: media_player.[yourHUB]
- service: cast.show_lovelace_view
data:
view_path: [card name/url from the Dashboard ur streaming]
dashboard_path: [...] #(http://homeassistant.local:8123/["whatever is in here"]/dashboard)#
entity_id: media_player.[yourHUB]
- delay:
seconds: 10 #time when the Cast device is beign unmuted again#
- service: media_player.volume_mute
data:
is_volume_muted: false
entity_id: media_player.[yourHUB]
mode: single