YouTube for Home Assistant
Shows your Youtube channel Subscribers count, Views count, Video count.
About this flow
| System | Home Assistant |
|---|---|
| AWTRIX version | AWTRIX 3 |
| Topic | Social |
| Built by | Dmytro Sudakevych (megadimich) |
| File | RpwLoMWG5lZ4.yaml · 1.9 KB |
| Icons | 3 |
| Published | 23 Dec 2023 · updated 24 Dec 2023 |
| Downloads | 38 |
Is this your flow?
If you created this flow, open your saved edit link to add it to your account. You can then manage it whenever you sign in. Adding it to your account replaces the edit link.
- You need to create a sensor in the configuration.yaml file or add a link to the file where the YouTube sensor is recorded.
In my case, I added the following lines to the configuration.yaml:
homeassistant:
packages: !include_dir_merge_named includes/packages
Place the youtube_sensors.yaml file in the packages folder.
In the youtube_sensors.yaml file, in the resource_template: template, enter your Youtube API key (YOURS_API_KEY) and channel ID (YOURS_UID).
-
Create your automation. I added my automation to the automations.yaml file. In this file, set your AWTRIX MQTT prefix in topic: instead of awtrix_565c3c.
-
Do not forget to download the icons mentioned in the project: 10835, 10519 і 9452.
If you have any questions, please contact me on Discord at megadimich.
RpwLoMWG5lZ4.yaml
1. File youtube_sensors.yaml:
youtube_sensors:
sensor:
- platform: rest
name: youtube_api
resource_template: "https://www.googleapis.com/youtube/v3/channels?part=statistics&id=YOURS_UID&key=YOURS_API_KEY"
method: GET
headers:
content-type: 'application/json'
value_template: "0"
json_attributes:
- "items"
scan_interval: 600 # 10 Minutes
- platform: template
sensors:
youtube_subscriber_count:
friendly_name: "Subscriber count"
value_template: "{{state_attr('sensor.youtube_api','items')[0].statistics.subscriberCount }}"
- platform: template
sensors:
youtube_view_count:
friendly_name: "View count"
value_template: "{{state_attr('sensor.youtube_api','items')[0].statistics.viewCount }}m"
- platform: template
sensors:
youtube_video_count:
friendly_name: "Video count"
value_template: "{{state_attr('sensor.youtube_api','items')[0].statistics.videoCount }}""
2. File automations.yaml:
- id: '1703179553264'
alias: 'AWTRIX: Monitoring Youtube '
description: ''
trigger:
- platform: time_pattern
minutes: /2
condition: []
action:
- service: mqtt.publish
data:
qos: '0'
retain: false
topic: awtrix_565c3c/custom/youtube1
payload: '{"icon": "10835", "text": "{{ states(''sensor.youtube_subscriber_count'')}}", "duration": 5 }'
- service: mqtt.publish
data:
qos: '0'
retain: false
topic: awtrix_565c3c/custom/youtube2
payload: '{"icon": "10519", "text": "{{ states(''sensor.youtube_view_count'')}}", "color": "#00FF00", "duration": 5 }'
- service: mqtt.publish
data:
qos: '0'
retain: false
topic: awtrix_565c3c/custom/youtube3
payload: '{"icon": "9452", "text": "{{ states(''sensor.youtube_video_count'')}}", "color": "#007FFF", "duration": 5 }'
mode: single
This flow uses the following icons. Add them to your AWTRIX along with the flow.
8×8 px
8×8 px
8×8 px
More flows for Home Assistant or Social
Something wrong with this flow? Report it.