Mariusthvdb / custom-ui

Add templates and icon_color to Home Assistant UI
163 stars 30 forks source link

Unexpected identifier 'state' in custom-ui template #144

Closed JohannCR closed 3 months ago

JohannCR commented 3 months ago

Describe the bug Icon doesn't change. Maybe I configured it wrong ? Thanks for any help

Configuration in Yaml I load customize.yaml like so in the config :

homeassistant:
  customize: !include customize.yaml

Then in customize.yaml I have :

input_number.volet_petit_bureau:
  templates:
    icon: >
      if state === '100.0' return 'mdi:window-shutter-open';
      if state === '0.0' return 'mdi:window-shutter';
      return 'mdi:window-shutter-alert';

Inspector Logs

SyntaxError: Unexpected identifier 'state' in custom-ui template if state === '100.0' return 'mdi:window-shutter-open'; if state === '0.0' return 'mdi:window-shutter-alert'; return 'mdi:window-shutter';

Expected behavior Icon should change depending on entity value.

Mariusthvdb commented 3 months ago

Please check the examples Hint: ()

JohannCR commented 3 months ago

My bad, needed to be in parenthesis like so (state === '100.0')

Works fine now ^^

JohannCR commented 3 months ago

Please check the examples Hint: ()

Lol just figured this out and we commented at the same time^^ Thanks anyway !