renemarc/home-assistant-config

View on GitHub
cameras/wallpapers.yaml

Summary

Maintainability
Test Coverage
#
# Bing daily wallpaper
#
# @see /appdaemon/dashboards/Main.dash
# @see /sensors/camera.yaml
#
# @link https://bing.com
# @link https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US
# @link https://www.home-assistant.io/integrations/generic_ip_camera/
#
- platform: generic
  name: "Bing Wallpaper"
  limit_refetch_to_url_change: true
  content_type: "image/jpg"
  still_image_url: >-
    {% set images = state_attr('sensor.bing_wallpaper', 'images') %}

    {% if images is iterable and images[0].urlbase %}
      {% set path = images[0].urlbase %}

      https://www.bing.com{{ path }}_800x600.jpg
    {% else %}
      {% set port = states('sensor.server_port') | int(8123) %}

      http://127.0.0.1:{{ port }}/local/images/wallpaper-1.jpg
    {% endif %}

- platform: generic
  name: "Bing Wallpaper HD"
  limit_refetch_to_url_change: true
  content_type: "image/jpg"
  still_image_url: >-
    {% set images = state_attr('sensor.bing_wallpaper', 'images') %}

    {% if images is iterable and images[0].urlbase %}
      {% set path = images[0].urlbase %}

      https://www.bing.com{{ path }}_1920x1080.jpg
    {% else %}
      {% set port = states('sensor.server_port') | int(8123) %}

      http://127.0.0.1:{{ port }}/local/images/wallpaper-1.jpg
    {% endif %}

- platform: proxy
  name: "Bing Wallpaper Proxy"
  entity_id: camera.bing_wallpaper_hd
  max_image_width: 1080
  image_quality: 65


#
# NASA's Astronomy picture of the day
#
# Supports images and YouTube thumbnails, but does not handle Vimeo images as
# that would require an extra REST query.
#
# @see /appdaemon/dashboards/Main.dash
# @see /sensors/camera.yaml
#
# @link https://api.nasa.gov/api.html#apod
# @link https://apod.nasa.gov
#
- platform: generic
  name: "Astronomy Picture of the Day"
  limit_refetch_to_url_change: true
  content_type: "image/jpg"
  still_image_url: >-
    {% set image = None %}
    {% set url = state_attr('sensor.apod', 'url') %}

    {% if url != None %}
      {% if state_attr('sensor.apod', 'media_type') == 'video' %}
        {% if 'youtube.com' in url %}
          {% set video = url.split('/')[4].split('?')[0] %}
          {% set image = 'https://img.youtube.com/vi/' + video + '/hqdefault.jpg' %}
        {% endif %}
      {% else %}
        {% set image = url %}
      {% endif %}
    {% endif %}

    {% if image == None %}
      {% set port = states('sensor.server_port') | int(8123) %}

      {% set image = 'http://127.0.0.1:' ~ port ~ '/local/images/wallpaper-2.jpg' %}
    {% endif %}

    {{ image }}

- platform: generic
  name: "Astronomy Picture of the Day HD"
  limit_refetch_to_url_change: true
  content_type: image/jpg
  still_image_url: >-
    {% set image = None %}
    {% set url = state_attr('sensor.apod', 'hdurl') or state_attr('sensor.apod', 'url') %}

    {% if url != None %}
      {% if state_attr('sensor.apod', 'media_type') == 'video' %}
        {% if 'youtube.com' in url %}
          {% set video = url.split('/')[4].split('?')[0] %}
          {% set image = 'https://img.youtube.com/vi/' + video + '/maxresdefault.jpg' %}
        {% endif %}
      {% else %}
        {% set image = url %}
      {% endif %}
    {% endif %}

    {% if image == None %}
      {% set port = states('sensor.server_port') | int(8123) %}

      {% set image = 'http://127.0.0.1:' ~ port ~ '/local/images/wallpaper-2.jpg' %}
    {% endif %}

    {{ image }}

- platform: proxy
  name: "Astronomy Picture of the Day Proxy"
  entity_id: camera.astronomy_picture_of_the_day_hd
  max_image_width: 1080
  image_quality: 65

#
# Local file wallpapers
#
# All source images are licensed under Creative Commons CC0.
#
# Sources:
#   automations: https://unsplash.com/photos/2EJCSULRwC8
#   configuration: https://unsplash.com/photos/401OD83Ke6o
#   hardware: https://unsplash.com/photos/FO7JIlwjOtU
#   switches: https://unsplash.com/photos/f_0t4fYEauU
#   wallpaper 1: https://pxhere.com/en/photo/335
#   wallpaper 2: https://pxhere.com/en/photo/1087220
#
- platform: local_file
  name: "Wallpaper 1"
  file_path: !secret wallpaper_1
  scan_interval: 21600

- platform: local_file
  name: "Wallpaper 2"
  file_path: !secret wallpaper_2
  scan_interval: 21600

- platform: local_file
  name: "Wallpaper Automations"
  file_path: !secret wallpaper_automations
  scan_interval: 21600

- platform: local_file
  name: "Wallpaper Configuration"
  file_path: !secret wallpaper_configuration
  scan_interval: 21600

- platform: local_file
  name: "Wallpaper Hardware"
  file_path: !secret wallpaper_hardware
  scan_interval: 21600

- platform: local_file
  name: "Wallpaper Switchboard"
  file_path: !secret wallpaper_switchboard
  scan_interval: 21600