Using the Media Duration attribute, I can create automations to mute media content less than 30 seconds and un-mute content greater than 30 seconds to effectively silence intrusive advertisements.
This works well for video content like YouTube playing on a Google Home/Nest Hub and audio content like Spotify playing on Google Home/Nest speakers.
Nevertheless, I was unable to create a similar automation to mute video content playing on my television using the built-in chromecast media player. While in theory media duration should work, it did not trigger the automation. Alternatively, I attempted to use the attribute media position, however media position doesn’t appear to be updated frequently enough to trigger the automation reliably. Any ideas?
Example Mute:
alias: You-Tube Mute Commercial
description: ''
trigger:
- platform: numeric_state
entity_id: media_player.hub_display
below: '30'
attribute: media_duration
condition:
- condition: state
entity_id: media_player.hub_display
state: YouTube
attribute: app_name
action:
- service: media_player.volume_mute
data:
is_volume_muted: true
target:
device_id: ***
mode: single
Example Unmute
alias: You-Tube Unmute Commercial
description: ''
trigger:
- platform: numeric_state
entity_id: media_player.hub_display
attribute: media_duration
above: '30'
condition:
- condition: state
entity_id: media_player.hub_display
state: YouTube
attribute: app_name
action:
- service: media_player.volume_mute
data:
is_volume_muted: false
target:
device_id: ***
mode: single
2 posts - 2 participants