BeardedTinker/Home-Assistant_Config

YouTube integration

BeardedTinker opened this issue · 2 comments

I'll link here some of the YouTube channel that create content that I watch with their Channel IDs, so anyone can use it for their Home Assistant integration:

  1. Automate Your Like
  • UCtRSKEipM17PF7n0mi66btQ
  1. BeardedTinker
  • UCuqokNoK8ZFNQdXxvlE129g
  1. Make It Work
  • UCGoreZKPBtCXCf54F3DF4ug
  1. Mark Watt Tech
  • UCQRm_z7seHnGsBiWDNEWr6A
  1. Mostly Chris
  • UCXEa_Gzl2zjhb7K6xflyrWQ
  1. SlackerLabs
  • UCipZJ6748kd8TbelSxcvcVg
  1. Smart Home Makers
  • UCa-_T4_g4T_11YMlxn80LaQ
  1. Tango Tech
  • UC4YUKOBld2PoOLzk0YZ80lw

Here is excellent automation Jonny created. Of course, you still need individual YT Channel sensors before this will work:

alias: Youtube Live Stream
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.beardedtinker
      - sensor.unexpected_maker
      - sensor.unexpected_streams
      - sensor.bitluni
      - sensor.bitluni_s_trash
      - sensor.superhousetv
      - sensor.intermit_tech
      - sensor.simple_electronics
    attribute: channel_is_live
    to: true
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition: []
action:
  - service: notify.mobile_app_jonny
    data:
      message: >
        {{state_attr(trigger.entity_id, 'friendly_name')}} is live,  video title
        {{ trigger.to_state.state }}
  - service: tts.cloud_say
    data:
      entity_id: media_player.kontor
      message: >
        {{state_attr(trigger.entity_id, 'friendly_name')}} is live, video title 
        {{ trigger.to_state.state }}
mode: single

And it goes in hand with these sensors that tracks if any of the channels is live:

- platform: template
  sensors:    
    beardedtinker_live:
      unique_id: yt00001
      friendly_name: "{{ state_attr('sensor.beardedtinker', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.beardedtinker', 'channel_is_live') }}"
    unexpected_maker_live:
      unique_id: yt00002
      friendly_name: "{{ state_attr('sensor.unexpected_maker', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.unexpected_maker', 'channel_is_live') }}"
    unexpected_streams_live:
      unique_id: yt00003
      friendly_name: "{{ state_attr('sensor.unexpected_streams', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.unexpected_streams', 'channel_is_live') }}"
    bitluni_live:
      unique_id: yt00004
      friendly_name: "{{ state_attr('sensor.bitluni', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.bitluni', 'channel_is_live') }}"
    bitluni_s_trash_live:
      unique_id: yt00005
      friendly_name: "{{ state_attr('sensor.bitluni_s_trash', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.bitluni_s_trash', 'channel_is_live') }}"
    superhousetv_live:
      unique_id: yt00006
      friendly_name: "{{ state_attr('sensor.superhousetv', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.superhousetv', 'channel_is_live') }}"
    simple_electronics_live:
      unique_id: yt00008
      friendly_name: "{{ state_attr('sensor.simple_electronics', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.simple_electronics', 'channel_is_live') }}"
    intermit_tech_live:
      unique_id: yt00007
      friendly_name: "{{ state_attr('sensor.intermit_tech', 'friendly_name') Live }}"
      value_template: "{{ state_attr('sensor.intermit_tech', 'channel_is_live') }}"
    youtube_live:
      unique_id: ytallchannels
      friendly_name: "Youtube Live"
      value_template: >
        {{ state_attr('sensor.beardedtinker', 'channel_is_live') == True or
        state_attr('sensor.unexpected_maker', 'channel_is_live') == True or
        state_attr('sensor.unexpected_streams', 'channel_is_live') == True or
        state_attr('sensor.bitluni', 'channel_is_live') == True or
        state_attr('sensor.bitluni_s_trash', 'channel_is_live') == True or
        state_attr('sensor.superhousetv', 'channel_is_live') == True or
        state_attr('sensor.intermit_tech', 'channel_is_live') == True }}

Created issue on component repository:
custom-components/youtube#56