thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
210 stars 16 forks source link

"tap_action" in json does not work #119

Closed ildar170975 closed 4 months ago

ildar170975 commented 4 months ago

Strange, this functionality used to work.

Consider this:

type: entities
entities:
  - type: custom:template-entity-row
    entity: input_boolean.test_boolean
    tap_action: |
      {
        "action": "toggle"
      }
  - type: custom:template-entity-row
    entity: input_boolean.test_boolean
    tap_action:
      action: toggle

Here tap_action works only in the 2nd row.

ver 1.4.0 2024.2.1

thomasloven commented 4 months ago

Are you sure? That's not supposed to work.

tap_action: { "action": "toggle" } would, though, since json is valid yaml. And so would

tap_action:
  { "action": "toggle" }
ildar170975 commented 4 months ago

I just took an example from Docs (w/o "confirmation"): image but may be I am missing smth. Probably the "pipe" not needed (cannot test right now).

This is definitely about the "pipe":

  1. Seems it should be used (as it is already) in your example in readme - since it contains templates:
            tap_action: |
              {
                "action": "toggle",
                "confirmation": {
                  "text": "{{states('sun.sun')}}",
                },
              }
  2. It should not be used w/o templates:
            tap_action:
              {
                "action": "toggle",
                "confirmation": {
                  "text": "hello",
                },
              }
thomasloven commented 4 months ago

When you add the pipe it turns into a string. And JSON strings ARE processed, but ONLY if they are the result of a template. Since yours doesn't include a template, that whole workflow is ignored. So it's sort of in the grey zone...