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