Skip to content

Instantly share code, notes, and snippets.

@peterkeen
Last active July 12, 2023 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterkeen/c07ed11ae1494897849997665e5fbe4e to your computer and use it in GitHub Desktop.
Save peterkeen/c07ed11ae1494897849997665e5fbe4e to your computer and use it in GitHub Desktop.
Home Assistant YouTube Blocker
type: custom:timer-bar-card
entities:
- entity: timer.youtube_15_minutes
state_color: true
name: YouTube
translations:
idle: Blocked
extend_paper_buttons_row:
position: right
buttons:
- icon: mdi:play
tap_action:
action: call-service
service: timer.start
service_data:
entity_id: timer.youtube_15_minutes
- icon: mdi:stop
tap_action:
action: call-service
service: timer.cancel
service_data:
entity_id: timer.youtube_15_minutes
alias: Block YouTube
description: ""
trigger:
- platform: state
entity_id:
- sensor.YOUR_ROKU_active_app
to: YouTube
for:
hours: 0
minutes: 0
seconds: 5
condition: []
action:
- service: media_player.select_source
data:
source: Home
target:
device_id: YOUR_ROKU_DEVICE_ID
mode: single
alias: Block YouTube When Timer Ends
description: ""
trigger:
- platform: state
entity_id:
- timer.youtube_15_minutes
from: null
to: idle
condition: []
action:
- service: automation.turn_on
data: {}
target:
entity_id: automation.block_youtube
- service: automation.trigger
data:
skip_condition: true
target:
entity_id: automation.block_youtube
mode: single
alias: Enable YouTube When Timer Starts
description: ""
trigger:
- platform: state
entity_id:
- timer.youtube_15_minutes
from: null
to: active
condition: []
action:
- service: automation.turn_off
data:
stop_actions: true
target:
entity_id: automation.block_youtube
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment