thomasloven / lovelace-state-switch

🔹Dynamically replace lovelace cards depending on occasion
MIT License
382 stars 27 forks source link

more Q but an issue about variables #113

Open commentsonly opened 8 months ago

commentsonly commented 8 months ago

when using

type: custom:state-switch
entity: template
template: >-
  {% set x = .....

is there a chance to access these further down within the

states:
  xx
  variables:
    - entity_1: {{x}}

section? Would allow me to save around 99% of the complete YAML code. Perhaps I'm not skilled enough with YAML or this isn't possible .. unsure about that.

ildar170975 commented 8 months ago

When an x variable is defined in

{% set x = ... %}
...

it is only accessible within THIS template, i.e. this will not work:

type: custom:state-switch
entity: template
template: >-
  {% set x = ... -%}
  {{ ... }}
states:
  value_xyz:
    ... the `x` variable is not accessible here.

You need to create a FR with a detailed description of a desired functionality.

commentsonly commented 8 months ago

Perhaps the functionality could most easily be described as template within the states: section. Better said the entries with the variables: section should allow for templating. I tried a lot but without any luck .. but perhaps something's possible.

ildar170975 commented 8 months ago

As I already said:

  1. The functionality you asked is not available.
  2. If you need a new functionality - suggest to close THIS issue and create a new one with a clear title (containing a "Feature request", "[FR]", ... whatever) and a clear detailed description (technical assignment).