A custom sensor for Home Assistant that monitors YouTube channels and provides information about the latest videos, including livestreams and YouTube Shorts. Features a modern graphical configuration interface with multi-language support for easy setup!
- ๐ฅ๏ธ Graphical Configuration: Easy setup through Home Assistant's UI (no more YAML editing!)
- ๐ Multi-language Support: Interface available in English, Italian, Spanish, French, German, and more
- ๐บ Video monitoring: Track the latest video published on a YouTube channel
- ๐ด Livestream detection: Detect when a channel is live or when a video is a stream
- ๐ฌ YouTube Shorts support: Automatically identify Short videos with option to include/exclude them
- โ๏ธ Flexible filtering: Choose whether to include or exclude YouTube Shorts from monitoring
- โฑ๏ธ Configurable scan interval: Set custom update frequency (5-120 minutes) for each channel
- ๐ Complete metadata: Views, stars, publication date, thumbnails
- ๐ Automatic updates: Self-updating while respecting YouTube's limits
- ๐ง Migration support: Automatically imports existing YAML configurations
- Home Assistant 2021.12.0 or higher
- Active internet connection
- YouTube channel ID you want to monitor
- Download all files from the repository
- Create the
custom_components/youtube_sensor/
folder in your Home Assistant configuration directory - Copy all files (
__init__.py
,config_flow.py
,const.py
,manifest.json
,sensor.py
,strings.json
) into the created folder - Optional: Copy the
translations/
folder for multi-language support - Restart Home Assistant
- Go to Settings โ Devices & Services โ Add Integration
- Search for "YouTube Sensor" and click to add
- Open HACS in Home Assistant
- Click on "Integrations"
- Click the three dots menu (โฎ) in the top right corner
- Select "Custom repositories"
- Add the repository URL:
https://github.com/drchiodo/hassio_youtube_sensor
- Select "Integration" as the category
- Click "ADD"
- Close the custom repositories dialog
- Click "EXPLORE & DOWNLOAD REPOSITORIES"
- Search for "YouTube Sensor"
- Click "DOWNLOAD" and then "DOWNLOAD" again
- Restart Home Assistant
- Go to Settings โ Devices & Services โ Add Integration
- Search for "YouTube Sensor" and click to add
-
Navigate to Settings โ Devices & Services
-
Click "Add Integration"
-
Search for "YouTube Sensor"
-
Fill out the configuration form:
- Channel ID: The YouTube channel ID (starts with UC)
- Channel Name (optional): Custom name for your sensor
- Include YouTube Shorts: Toggle to include/exclude Shorts
- Scan Interval: Update frequency in minutes (5-120 minutes)
-
Click "Submit" - the integration will validate the channel and create your sensor!
The integration interface is available in multiple languages:
- ๐บ๐ธ English (default)
- ๐ฎ๐น Italian
- ๐ช๐ธ Spanish
- ๐ซ๐ท French
- ๐ฉ๐ช German
The interface automatically adapts to your Home Assistant language settings. Additional languages can be easily added by contributing translation files.
To find the YouTube channel ID:
Method A - From channel URL:
- If the URL is
https://www.youtube.com/channel/UC4V3oCikXeSqYQr0hBMARwg
- The ID is:
UC4V3oCikXeSqYQr0hBMARwg
Method B - From username:
- Go to any video from the channel
- Click on the channel name
- The channel page URL will contain the ID after
/channel/
Method C - Online tools:
- Use sites like
commentpicker.com/youtube-channel-id.php
- Enter the channel URL to get the ID
If you prefer YAML configuration, add this to your configuration.yaml
file:
sensor:
# Basic configuration (excludes Shorts by default, 15min interval)
- platform: youtube_sensor
channel_id: UC4V3oCikXeSqYQr0hBMARwg
name: "Breaking Italy"
# Explicitly exclude Shorts with custom interval
- platform: youtube_sensor
channel_id: UCx7EWheHmjCW3vX8K2d09vg
name: "GeoPop"
includeShorts: false
scan_interval: 30 # Check every 30 minutes
# Include Shorts with frequent updates
- platform: youtube_sensor
channel_id: UC5fmXZRQS-6xa2kCbCQds8g
name: "CURIUSS"
includeShorts: true
scan_interval: 10 # Check every 10 minutes
Note: Existing YAML configurations will be automatically detected and can be migrated to the UI if desired.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Channel ID | string | Yes | - | YouTube channel ID (starts with UC, 24 characters) |
Channel Name | string | No | Auto-detected | Custom name for the sensor |
Include YouTube Shorts | boolean | No | false |
Whether to include YouTube Shorts in monitoring |
Scan Interval | integer | No | 15 |
Update frequency in minutes (5-120 minutes) |
- Include Shorts: OFF (default): The sensor will find the latest regular video, skipping any YouTube Shorts
- Include Shorts: ON: The sensor will find the latest video of any type, including YouTube Shorts
- Default: 15 minutes - Good balance between responsiveness and resource usage
- Range: 5-120 minutes - Customize based on channel activity
- Recommendations:
- High-activity channels (news, live streamers): 5-10 minutes
- Regular channels: 15-30 minutes
- Low-activity channels: 60-120 minutes
This allows you to have granular control over what type of content triggers your automations and how frequently each channel is monitored.
Sensors are created with the format: sensor.youtube_[channel_name]
Examples:
sensor.youtube_breaking_italy
sensor.youtube_geopop
sensor.youtube_curiuss
The sensor state contains the title of the latest published video (filtered by your Shorts setting).
Attribute | Description |
---|---|
url |
Complete video URL |
content_id |
Unique YouTube video ID |
published |
Publication date and time |
stars |
Number of stars/rating |
views |
Number of views |
stream |
true if the video is a stream |
live |
true if the stream is currently live |
stream_start |
Stream start date/time |
channel_is_live |
true if the channel is live |
channel_image |
Channel image URL |
is_short |
true if the video is a YouTube Short |
include_shorts |
Configuration setting for this sensor |
scan_interval_minutes |
Update frequency in minutes |
friendly_name |
Original channel name |
type: entity
entity: sensor.youtube_breaking_italy
type: custom:button-card
entity: sensor.youtube_breaking_italy
name: Breaking Italy
show_name: true
show_entity_picture: true
entity_picture: |-
[[[
return states['sensor.youtube_breaking_italy'].attributes.entity_picture
]]]
tap_action:
action: url
url_path: |-
[[[
return states['sensor.youtube_breaking_italy'].attributes.url
]]]
styles:
card:
- height: 200px
name:
- font-size: 16px
- font-weight: bold
entity_picture:
- border-radius: 10px
alias: Announcing new YouTube videos
description: Alexa automatically announces videos from ALL YouTube channels
triggers:
- trigger: event
event_type: state_changed
conditions:
- condition: template
value_template: |
{{ trigger.event.data.entity_id.startswith('sensor.youtube_') }}
- condition: template
value_template: >
{{ 'old_state' in trigger.event.data and 'new_state' in trigger.event.data
}}
- condition: template
value_template: >
{{ trigger.event.data.old_state.attributes.get('url') !=
trigger.event.data.new_state.attributes.get('url') }}
- condition: template
value_template: |
{{ not trigger.event.data.new_state.attributes.get('is_short', false) }}
- condition: template
value_template: |
{{ 'watch?v=' in trigger.event.data.new_state.attributes.get('url', '') }}
actions:
- action: notify.mobile_app_ipp
data:
message: >-
New video on channel {{
trigger.event.data.new_state.attributes.get('friendly_name',
'YouTube').replace('_', ' ') }}: {{ trigger.event.data.new_state.state
}}
automation:
- alias: "Breaking Italy is Live"
trigger:
- platform: state
entity_id: sensor.youtube_breaking_italy
attribute: live
to: true
action:
- service: notify.family
data:
title: "๐ด LIVE"
message: "Breaking Italy is live!"
type: vertical-stack
cards:
- type: custom:button-card
entity: sensor.youtube_breaking_italy
name: Breaking Italy
show_entity_picture: true
- type: custom:button-card
entity: sensor.youtube_geopop
name: GeoPop
show_entity_picture: true
- Verify installation: Ensure all files are in
custom_components/youtube_sensor/
- Restart Home Assistant completely
- Clear browser cache and refresh the page
- Check logs for any loading errors
"Invalid channel ID"
- Channel ID must start with "UC"
- Channel ID must be exactly 24 characters long
- Example:
UC4V3oCikXeSqYQr0hBMARwg
"Cannot connect to YouTube channel"
- Check your internet connection
- Verify the channel exists and is public
- Channel might be temporarily unavailable
"Already configured"
- This channel is already being monitored
- Check existing integrations in Settings โ Devices & Services
"No non-Short videos found in feed"
- This warning appears when "Include Shorts" is OFF but the channel has only posted Shorts recently
- The sensor will fallback to the most recent video regardless of type
- Consider enabling "Include Shorts" if the channel posts many Shorts
"Scan interval too frequent"
- If you set the scan interval too low (< 5 minutes), it will be automatically adjusted
- Very frequent updates may trigger YouTube rate limiting
- Consider increasing the interval if you experience connection issues
Sensor shows "Unknown" or "Unavailable"
- Temporary connection issues
- YouTube may have changed page structure
- YouTube rate limiting - wait and it should recover
Existing sensors disappeared
- After installing the integration, existing YAML sensors are replaced
- Re-add channels through the UI configuration
- Your automations will work with the new entity IDs
To enable debug logging, add to configuration.yaml
:
logger:
default: warning
logs:
custom_components.youtube_sensor: debug
Debug logs will show:
- Integration setup process
- Channel validation results
- Whether Shorts are being included or excluded
- Which videos are being skipped and why
- Video detection results
- Actual scan intervals being used
- Go to Settings โ Devices & Services
- Find "YouTube Sensor" and click "Configure"
- Click "Add Entry" to add another channel
- Go to Settings โ Devices & Services
- Find your YouTube channel entry
- Click "Configure" to modify settings
- Go to Settings โ Devices & Services
- Find your YouTube channel entry
- Click the three dots and select "Delete"
We welcome translations for additional languages! Here's how to contribute:
custom_components/youtube_sensor/
โโโ strings.json # English (default)
โโโ translations/
โโโ it.json # Italian
โโโ es.json # Spanish
โโโ fr.json # French
โโโ de.json # German
โโโ [your_lang].json # Your language
Currently available translations:
- ๐บ๐ธ English (
en
) - Default - ๐ฎ๐น Italian (
it
) - Complete - ๐ช๐ธ Spanish (
es
) - Complete - ๐ซ๐ท French (
fr
) - Complete - ๐ฉ๐ช German (
de
) - Complete
- Copy the English template from
strings.json
- Create
translations/[language_code].json
- Translate all text strings while keeping the JSON structure
- Submit a pull request with your translation
Use standard ISO 639-1 language codes:
pt
= Portuguesenl
= Dutchru
= Russianzh
= Chineseja
= Japaneseko
= Koreansv
= Swedishno
= Norwegianda
= Danishfi
= Finnish
- Keep technical terms like "Channel ID" consistent
- Maintain the same tone (helpful and professional)
- Test your translation by changing Home Assistant language settings
- Ensure special characters are properly escaped in JSON
- Update frequency: Configurable per sensor (5-120 minutes)
- Default interval: 15 minutes for optimal balance
- Rate limiting: YouTube may limit too frequent requests - increase interval if needed
- Timeout: Requests timeout after 10 seconds to prevent blocking
- Shorts detection: Additional HTTP request per video to determine if it's a Short
- Concurrent sensors: No limit on number of channels, but consider total request volume
- Concurrent sensors: No limit on number of channels you can monitor
If you encounter issues:
- Check the integration status in Settings โ Devices & Services
- Verify your configuration through the UI
- Enable debug logging to see detailed operation
- Check Home Assistant logs for specific errors
- Try with a different channel to isolate issues
- Report bugs on GitHub with debug logs
- NEW: Configurable scan interval (5-120 minutes) per channel
- NEW: Smart update frequency recommendations based on channel activity
- NEW: Scan interval visible in sensor attributes for monitoring
- IMPROVED: Better resource management with customizable polling
- IMPROVED: Enhanced logging with scan interval information
- IMPROVED: Optimal balance between responsiveness and YouTube rate limits
- NEW: Full graphical configuration interface (Config Flow)
- NEW: Multi-language support (English, Italian, Spanish, French, German)
- NEW: Modern Home Assistant integration architecture
- NEW: Automatic migration from YAML configurations
- NEW: Real-time channel validation during setup
- NEW: Prevention of duplicate channel configurations
- NEW: Enhanced error handling with descriptive messages
- IMPROVED: Entity IDs now use channel ID for better uniqueness
- IMPROVED: Support for both UI and YAML configuration methods
- IMPROVED: Better integration management and removal
- NEW: Added
includeShorts
parameter to control YouTube Shorts filtering - NEW: Enhanced logging with separate messages for Shorts inclusion/exclusion
- NEW: Added
include_shorts
attribute to sensor for debugging - IMPROVED: Better logic for video filtering based on content type
- IMPROVED: More descriptive warning messages when no suitable videos are found
- Added YouTube Shorts detection
- Improved livestream detection
- Entity IDs with
youtube_
prefix - Added
friendly_name
attribute - Support for live channels
- Improved error handling
- Optimized information parsing
- Initial release
- Basic video monitoring
- Livestream support
This project is released under the MIT License. See the LICENSE file for details.
โญ If this sensor is useful to you, consider starring the repository!
๐ฏ Now with configurable scan intervals, multi-language support, and modern UI configuration!