config-template-card icon indicating copy to clipboard operation
config-template-card copied to clipboard

Variables: use VARIABLE_1 to define VARIABLE_2

Open ildar170975 opened this issue 3 years ago • 0 comments

Earlier I could use one variable to define another variable:

    type: 'custom:config-template-card'
    variables:
      - 'states[''input_select.graph_hours_to_show_sys'']'
      - 'states[''input_boolean.graph_realtime_sys'']'
      - '''binary_sensor.rpi_power_status'''
      - 'vars[1].state === "on" ? vars[2] : "sensor.test_zero"'      #### LOOK AT THIS !!!!
    entities:
      - '${vars[0].entity_id}'
      - '${vars[1].entity_id}'
      - '${vars[3]}'
    card:
      type: history-graph
      entities:
        - entity: '${vars[2]}'
          name: Питание
      hours_to_show: '${vars[0].state}'
      refresh_interval: 0

изображение

Now I am trying to use variables SENSOR & INPUT_REALTYME to define a variable SENSOR_TO_BE_CHECKED - and I am failed:

type: 'custom:config-template-card'
variables:
  HOURS_TO_SHOW: 'states[''input_select.graph_hours_to_show_sys'']'
  INPUT_REALTYME: 'states[''input_boolean.graph_realtime_sys'']'
  SENSOR: '''binary_sensor.rpi_power_status'''
  SENSOR_TO_BE_CHECKED: 'INPUT_REALTYME.state === "on" ? SENSOR : "sensor.test_zero"'
entities:
  - '${HOURS_TO_SHOW.entity_id}'
  - '${INPUT_REALTYME.entity_id}'
  - '${SENSOR_TO_BE_CHECKED}'
card:
  type: history-graph
  entities:
    - entity: '${SENSOR}'
      name: Питание
  hours_to_show: '${HOURS_TO_SHOW.state}'
  refresh_interval: 0

изображение

Look, now it works again:

type: 'custom:config-template-card'
variables:
  HOURS_TO_SHOW: 'states[''input_select.graph_hours_to_show_sys'']'
  INPUT_REALTYME: 'states[''input_boolean.graph_realtime_sys'']'
  SENSOR: '''binary_sensor.rpi_power_status'''
#  SENSOR_TO_BE_CHECKED: 'INPUT_REALTYME.state === "on" ? SENSOR : "sensor.test_zero"'
entities:
  - '${HOURS_TO_SHOW.entity_id}'
  - '${INPUT_REALTYME.entity_id}'
#  - '${SENSOR_TO_BE_CHECKED}'
card:
  type: history-graph
  entities:
    - entity: '${SENSOR}'
      name: Питание
  hours_to_show: '${HOURS_TO_SHOW.state}'
  refresh_interval: 0

изображение

I suspect that now I cannot ise a VARIABLE_1 to define a VARIABLE_2.

ildar170975 avatar Oct 27 '20 11:10 ildar170975