Last active
September 9, 2021 02:22
-
-
Save zubir2k/e8a37f305a757721d985178a77a62f22 to your computer and use it in GitHub Desktop.
Home Assistant Sensors for Youtube Subscriber & Viewers from Socialblade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Youtube Subscription & Viewers Sensors | |
######################################### | |
## Stats is based on Socialblade using scrape. Scan interval is set at 30min to avoid from being blocked. | |
## Consist of 2; subscriber and views sensors | |
## Automation ideas: use telegram to notify changes. Can also trigger other stuff like RGB light bulb (e.g. Flashing red). | |
## configuration.yaml ## | |
sensor: | |
- platform: scrape | |
name: Youtube Subscriber | |
resource: https://socialblade.com/youtube/channel/UCJYvY4zLKi6KKbUvOplvQew #replace with your channel id/name | |
scan_interval: 1800 | |
select: "#youtube-stats-header-subs" | |
headers: | |
User-Agent: Mozilla/5.0 | |
- platform: scrape | |
name: Youtube Views | |
resource: https://socialblade.com/youtube/channel/UCJYvY4zLKi6KKbUvOplvQew #replace with your channel id/name | |
scan_interval: 1800 | |
select: "#youtube-stats-header-views" | |
headers: | |
User-Agent: Mozilla/5.0 | |
## automation.yaml ## | |
alias: Youtube Update | |
description: '' | |
trigger: | |
- platform: state | |
entity_id: sensor.youtube_subscriber | |
- platform: state | |
entity_id: sensor.youtube_views | |
condition: [] | |
action: | |
- service: notify.telegram | |
data: | |
message: >- | |
Subcribers: {{states.sensor.youtube_subscriber.state}}{{ '\n' }}Views: | |
{{states.sensor.youtube_views.state}} | |
title: 📢 Youtube Subcriber Alert | |
mode: single |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment