sensors/camera.yaml
#
# Camera folder
#
# Since file paths can varybetween systems, the base path for public camera
# images is saved in the secrets file.
#
- platform: template
sensors:
camera_folder:
friendly_name: "Camera Folder"
icon_template: "mdi:folder-image"
value_template: !secret camera_folder
#
# Bing Wallpaper
#
# Used for wallpaper cameras. The image changes once per day, but we set scan
# interval to 6 hours in case the Internet connection was lost during a previous
# scheduled fetch.
#
# Resource format:
# `https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US`
# format = Javascript or XML.
# idx = Start index
# n = Number of images to retrieve
# mkt = Market
#
# @see /cameras/wallpapers.yaml
#
# @link https://bing.com
# @link https://www.home-assistant.io/integrations/rest/
#
- platform: rest
name: "Bing Wallpaper"
resource: "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US"
scan_interval: 21600
json_attributes:
- images
value_template: >-
{% if value_json and value_json.images[0] and value_json.images[0].copyright %}
{% set parts = value_json.images[0].copyright.split('(') %}
{% for part in parts %}
{%- if not loop.last -%}
{%- if not loop.first %}({% endif %}
{{- part | trim -}}
{%- endif -%}
{% endfor %}.
{% endif %}
#
# NASA's Astronomy Picture of the Day
#
# Used for wallpaper cameras. The image changes once per day, but we set scan
# interval to 6 hours in case the Internet connection was lost during a previous
# scheduled fetch.
#
# Resource format:
# `https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY`
# api_key = Either a free to register API key, or the public DEMO_KEY
#
# API key DEMO_KEY has a rate limit of 30 requests per hour and 50 max per day.
# Registered API keys have a rate limit of 1000 requests per hour.
#
# @see /cameras/wallpapers.yaml
#
# @link https://api.nasa.gov/api.html#apod
# @link https://apod.nasa.gov
#
- platform: rest
name: "APOD"
resource: !secret apod_api_url
scan_interval: 21600
json_attributes:
- copyright
- date
- explaination
- hdurl
- media_type
- title
- url
value_template: >-
{% if value_json and value_json.title %}
{% if value_json.media_type and value_json.media_type == 'video' %}
Video:
{%- endif %} {{ value_json.title }}
{%- if not value_json.title | regex_search('[….!?]$') %}.{% endif %}
{% endif %}