This is a simple blueprint to change your theme based on the sun.sun entity. Make sure to clear any light/dark specific themes first.
blueprint:
name: Theme switcher
description: Switch to dark theme when the sun goes down.
domain: automation
input:
light_theme:
name: Light theme name
description: What do you call your light theme when you go to choose it?
dark_theme:
name: Dark theme name
description: What do you call your dark theme when you go to choose it?
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: sun.sun
action:
- choose:
- conditions:
- condition: state
entity_id: sun.sun
state: "above_horizon"
sequence:
- service: frontend.set_theme
data:
name: !input light_theme
- conditions:
- condition: state
entity_id: sun.sun
state: "below_horizon"
sequence:
- service: frontend.set_theme
data:
name: !input dark_theme
I’m super new to HA still, and this blueprint looks pretty awesome, but I’m curious whether it is still required in recent versions of HA?
In my theme settings, there appears to be support for theme switching built in:
Does that make this blueprint obsolete, or is there still a need for it? I have noticed that most (maybe all?) 3rd party themes don’t seem to properly support whatever is required for the built-in automatic switching to function, so maybe this blueprint is a workaround for that?
As the title suggests, this is based on sun. So during the night, when the sun has set, it uses the dark theme, and vice versa for light theme. HA’s built-in switching means that if your phone or whatever is configured to use system-wide dark theme, it’ll use dark theme as well.