gadgetchnnel / lovelace-card-templater

Custom Lovelace card which allows Jinja2 templates to be applied to other cards
120 stars 6 forks source link

template card config options? Map won't change dark_mode #46

Open Mariusthvdb opened 2 years ago

Mariusthvdb commented 2 years ago

trying to change dark_mode for map card based on a theme

  - type: custom:card-templater
    card:
      type: map
      hours_to_show: 48
      dark_mode_template: "{{states('input_select.theme')|regex_search('(ight|Dark|Matrix)')}}"
      entities:

it doesnt change at all, making me wonder if

Any option in the original card which takes a string value can be templated by changing the option name to be option_name_template .

also allows what I was hoping to do?

gadgetchnnel commented 2 years ago

This works for me currently, but I'm using the latest alpha version (0.1.0-alpha2) which has refectored template handling so that may have fixed it.

Also, should regex_search('(ight|Dark|Matrix) be something like regex_search('(Night|Dark|Matrix) a typo? Otherwise it looks like that would potentially match a theme containing the world Light.

Mariusthvdb commented 2 years ago

Ill test this later, as I have setup the same version now. thanks for the update!

and the regex was ok, because indeed I try to catch Night and Midnight theme ;-)

Yes! can confirm this works perfectly too:

        - type: custom:card-templater
          card:
            type: custom:auto-entities
            show_empty: false
            filter:
              include:
                - domain: person
                  not:
                    state: home
            card:
              type: map
              hours_to_show: 48
              dark_mode_template: >
                {{states('input_select.theme')|regex_search('(ight|Dark|Matrix)')}}

really very nice indeed, thank you!

Guess I can close this now, or do you want to wait for a release version?