So first of all you need to get a youtube api key then set up these two components:
This is a restful sensor and it will allow you to set the videoId string from the api as a variable, the scan interval decides how often it checks the api(which will use your youtube api quota), use this to get the channel id you need http://johnnythetank.github.io/youtube-channel-name-converter/
sensor 2:
- platform: rest
name: "whatever you want"
resource: https://www.googleapis.com/youtube/v3/search?key="insert your youtube api key here without quotes"&channelId="youtube channel id you want to get the newest video from"&part=id&order=date&maxResults=1
value_template: "{{ value_json['items'][0]['id']['videoId'] }}"
scan_interval: 3600
headers:
User-Agent: homeassistant
Then set up a rest command(you may also want to reserve your roku/roku tv's ip so that it doesnt change):
rest_command:
"whatever you want":
url: 'http://"your roku ip without quotes":8060/launch/837?contentID={{states.sensor."sensor name".state}}&MediaType=live'
method: POST
Don't forget to remove the quote on fields you need to change.
Then set up a automation like this, which i hook up to be activated from an ifttt webhook:
- id: 'whatever you want I use webhooks so its a string of numbers'
alias: "whatever you want"
trigger:
- platform: webhook
webhook_id: "whatever you want"
condition: []
action:
- service: rest_command."whatever you named your rest command"
Issues:
Seems that even with longer scan_interval it uses 100-500 (which can lead to it going over quite fast for me since I only get 10,000) quota per GET and I am uncertain why, from what I’ve read it should use 1-3, if anyone knows (or knows a good way to make this all into a single automation that only does the GET when the automation is activated, please do leave a comment on how I would go about that, thank you.
Currently experimenting with:
action:
- service: homeassistant.update_entity
entity_id:
- sensor."your sensor name without quotes"
- delay: 00:00:02
- service: rest_command."your rest command name without quotes"