Skip to content

Instantly share code, notes, and snippets.

@krissen
Last active May 22, 2020 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krissen/226d7c2570b38fd27cbc49c98514c792 to your computer and use it in GitHub Desktop.
Save krissen/226d7c2570b38fd27cbc49c98514c792 to your computer and use it in GitHub Desktop.
Configuration for differently themed grafana panels (dark/light) that updates automatically according to a light level -sensor.
# Set up two cameras, pulling differently themed panels from Grafana
# One dark; one light.
camera:
# Camera-card for dark theme. Note `theme=dark` in the URL.
- platform: generic
name: Luftfuktighet (mörk)
still_image_url: 'http://internal.ip:port/render/d-solo/P_cth9gGz/klimat?orgId=1&refresh=10m&from=now-1d&to=now&panelId=4&theme=dark&width=500&height=325&tz=Europe%2FLondon'
username: !secret grafana_user
password: !secret grafana_password
# Camera-card for light theme. Note `theme=light` in the URL.
- platform: generic
name: Luftfuktighet (ljus)
still_image_url: 'http://internal.ip:port/render/d-solo/P_cth9gGz/klimat?orgId=1&refresh=10m&from=now-1d&to=now&panelId=4&theme=light&width=500&height=325&tz=Europe%2FLondon'
username: !secret grafana_user
password: !secret grafana_password
# Set up binary sensor, used in the Lovelace conditional card.
# You could use sun.angle or whatever instead of sensor.lightlevel.
# When the binary sensor is off, light theme is used.
# When it is on, dark theme is used.
# A similar logic is used for automatically setting dark/light theme
# overall in Home assistant. Together, I get a light (or dark) themed
# Homeassistant, with grafana panels that fit the theme.
binary_sensor:
- platform: template
sensors:
morkare:
friendly_name: Light level darker than three
# I have a setup with a custom light sensor,
# where 0 = daylight and 5 = night.
# (Yes, the logic of it can be debated.)
value_template: >-
{{ states('sensor.lightlevel') | float > 3 }}
# Relevant Lovelace-config for showing one card when it is light
# and another for when it is dark.
# Camera-card for dark theme
- type: conditional
conditions:
- entity: binary_sensor.morkare
state: "off"
card:
type: picture-entity
name: Luftfuktighet
entity: camera.luftfuktighet_ljus
aspect_ratio: 1.65
show_name: false
show_state: false
# Camera-card for light theme
- type: conditional
conditions:
- entity: binary_sensor.morkare
state: "on"
card:
type: picture-entity
name: Luftfuktighet
entity: camera.luftfuktighet_mork
aspect_ratio: 1.65
show_name: false
show_state: false
@krissen
Copy link
Author

krissen commented May 22, 2020

homeassistant__iphone__dark-light__theme-panels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment