Youtube Integration improvements

The current Youtube integration lacks some features compared to the Youtube custom component available in HACS which uses scraping instead of API.
Currently, the custom component can’t be setup as it uses the same name as the official integration.

@joostlek Would it be possible to add additional attributes like the custom components has? e.g.

  • stream: If the video was streamed live
  • stream_start: datetime of the start of a live stream
  • live: If the video is live now
  • channel_is_live: If any video on the channel is live
  • channel_image: URL of the channel logo image
  • length: Length of the video
  • thumbnail: URL of the thumbnail for the stream/video

These can be used to make simple and rich notifications.
Almost the same as when Youtube had email notifications for every new video.

Hey thanks for your message. Yes and no. I’m planning to add more features like media browser.

For the features you requested, I tried looking into live stream data, but as far as I know, to get this info from the API you need to do a search request, which is expensive (400 credits of the 10000 available, doesn’t seem much, but keep in mind that home assistant would be polling every X minutes and that you probably have more than one channel set up).

For thumbnail and channel images, they are already available in the state attributes. Channel image is available at the subscriber count entity, and the thumbnail at the latest video.

Length and upload date is something I can add right now (but that would be next release).

Hope this information clears things up!

Joost

1 Like

I guess you are right. It would be quite expensive. I do use a different system (outside of HASS) to get a notification for a new video which also uses API where I have at least 50 channels frequently checked. That would get used pretty quickly.

Ah, perfect! Apologize for not looking at the states. I only checked the attributes via the sensor state and saw only the video ID.

Looking forward to that. Thanks a lot for this!

Is there any possibility that the adding a multiple channels could be simpler? I’m subbed to a ton of channels and clicking/searching individually for each one where I want to have a notification is quite time consuming.
Perhaps, if it would be possible to import every channel where the “Ring” is set to “All notifications” instead of the default, customized.
I’m not sure if there might be another way to get a “batch” import to the integration.

Update: apparently I can’t get the length of the video in the playlistitems call that is used to fetch the latest upload. And I don’t feel like adding a call to every new video at this moment. I first want to think about what features I want to support and how I’ll be implementing them. And then I can calculate how much room there is left before hitting the rate limits

Add upload date to Youtube state attributes by joostlek · Pull Request #96976 · home-assistant/core · GitHub is the PR for adding the upload date to the state attributes