Recently were wondering if I could play the most reason youtube video of an channel without the hussle to take out my Phone. Getting out the content ID was cind of a struggle, First via the API, then with a scrape sensor and now at last (maybe not least) with an command line sensor (@Ludeeus came up with this <3 grateful i am meme )
sensor:
- platform: command_line
name: yt_Franck
command: curl -sSL https://www.youtube.com/feeds/videos.xml?channel_id=UCZ2Ku6wrhdYDHCaBzLaA3bw | grep videoId | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1
scan_interval: 6000
- platform: command_line
name: yt_Franck_title
command: curl -sSL https://www.youtube.com/feeds/videos.xml?channel_id=UCZ2Ku6wrhdYDHCaBzLaA3bw | grep title | head -n 2 | cut -d '>' -f 2 | cut -d '<' -f 1 | tail -1
scan_interval: 6000
media_extractor:
script:
bad_franck:
sequence:
- service: media_extractor.play_media
entity_id: media_player.kffowi202_2
data_template:
media_content_id: "https://www.youtube.com/watch?v={{ states('sensor.yt_franck') }}"
media_content_type: video/youtube
Lovelace card :
cards:
- cards:
- entity: script.bad_franck
hold_action:
action: none
name: Franck
tap_action:
action: call-service
service: script.bad_franck
type: entity-button
type: horizontal-stack
- cards:
- entity: sensor.yt_franck_title
type: sensor
name: 'Lastest Show:'
type: horizontal-stack
type: vertical-stack
When you need help to find a channel ID :
http://dev.zype.com/posts/2014/11/04/finding-youtube-channel-id/
started to create a costom sensor… But I cant code… yet
Maybe someone would like to create a proper sensor?
https://codeshare.io/aJJ6jn
you can get an API key >here<