YouTube for Home Assistant
Home Assistant

YouTube for Home Assistant

Shows your Youtube channel Subscribers count, Views count, Video count.
A flow by Dmytro Sudakevych (megadimich)

Go to automations Download flow Download assets

Flow Details

  1. 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).

  1. 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.

  2. 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.

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
/flows/RpwLoMWG5lZ4/10519.gif
/flows/RpwLoMWG5lZ4/9452.gif
/flows/RpwLoMWG5lZ4/10835.gif
-- Flow first published on December 23, 2023, last updated on December 24, 2023 at 15:13.