question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

darkMode option with templating does not work correctly

See original GitHub issue

Version: v0.1.4

My Home Assistant backend-selected theme changes based on sun entity. Automation for that uses this blueprint.

This is my sun card configuration:

type: 'custom:sun-card'
darkMode: '{{ is_state("sun.sun", "below_horizon") }}'

I tried converting it to string too (see below).

Issue: The card does not change appearance correctly. It is constantly rendered as if darkMode was set to True.

Templating outputs:

{{ is_state("sun.sun", "below_horizon") }}                         # False

{{ is_state("sun.sun", "below_horizon") is boolean }}              # True

{{ is_state("sun.sun", "below_horizon") | string }}                # False

{{ (is_state("sun.sun", "below_horizon") | string) is boolean }}   # False

I tried {{ (states("sun.sun") == "below_horizon") }} too but it gives same results.


  1. What would the correct/working configuration look like?
  2. DIfferent Lovelace cards don’t have darkMode option in configuration and they render correctly. Is that because they use themes colour palette for fonts? Why it’s not the case with sun-card?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
ronaldheftcommented, Jul 15, 2021

I managed to work around this with card-mod:

- type: custom:sun-card
  entity: sun.sun
  timeFormat: 12h
  card_mod:
    style: |
      .sun-card.sun-card-light {
        --sun-card-lines: var(--disabled-text-color) !important;
        --sun-card-text-color: var(--primary-text-color) !important;
        --sun-card-subtitle-color: var(--secondary-text-color) !important;
      }
1reaction
bigmak40commented, Jun 9, 2021

I would just do this via a conditional. The below works great.

type: entities
entities:
  - type: conditional
    conditions:
      - entity: sun.sun
        state: below_horizon
    row:
      type: custom:sun-card
      darkMode: true
  - type: conditional
    conditions:
      - entity: sun.sun
        state: above_horizon
    row:
      type: custom:sun-card
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve issues with email dark mode
The dark mode setting is available on mobile, tablet, and PC. All users can activate ... The new email template corrects dark mode...
Read more >
Fixing Problems With Borders in Dark Mode (Email Design)
Are your borders changing color or disappearing into the background when you test your HTML email in dark mode?
Read more >
A Complete Guide to Dark Mode on the Web - CSS-Tricks
Dark mode ” is defined as a color scheme that uses light-colored text and ... Moreover, there's nothing saying we can only use...
Read more >
Dark Mode Logo Problems: Six Ideas to Improve Email Design
2. A dark logo will disappear. Or, maybe your logo is a PNG with a transparent background. That should work, right? Well, maybe....
Read more >
Dark Mode Email: Your Ultimate How-to Guide - Litmus
Yes, you read right. Some email clients let you change their UI to Dark Mode, but that doesn't have any impact on how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found