thomasloven / lovelace-template-entity-row

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

Templating hold action fails (iOS companion) #125

Open erkr opened 1 month ago

erkr commented 1 month ago

Thanks for the great card. I use it a lot. Today I ran into an issue. When I template the Hold_action it doesn’t work, but same template in tap_action works fine!! Noticed this on my iPhone using the iOS companion app, that is configured to use safari (will report back for other browsers):

The example that works fine with tap_action but fails using hold_action (this is intended to be used with Nmap device trackers):

hold_action: |
  {% set ip = state_attr(config.entity, 'ip') %}
  {% if ip %}
    { "action": "url", "url_path": "http://{{ip}}", }
  {% else %}
    { "action": "more-info" }
  {% endif %}
ildar170975 commented 1 month ago

Cannot reproduce with a bit different code:

type: entities
entities:
  - input_boolean.test_boolean
  - type: custom:template-entity-row
    entity: sun.sun
    hold_action: >-
      {% set ip = 'google.com' -%}
      {%- if is_state('input_boolean.test_boolean','on') -%}
        { "action": "url", "url_path": "http://{{ip}}" }
      {%- else -%}
        { "action": "more-info" }
      {%- endif %}

image

erkr commented 1 month ago

@ildar170975 thanks for verifying! Can you please tell on which platform/browsers/mobile app you tested?!

So it is browser specific. I now verified myself on some platforms:

Working:

Not working:

Best Eric

ildar170975 commented 1 month ago

I tested in Chrome & Win. Have iOS companion app (iOS 15.x), but have not tested there. Will try to do it a bit later.

erkr commented 1 month ago

Have iOS companion app (iOS 15.x), but have not tested there. Will try to do it a bit later.

Any update on this 😉

ildar170975 commented 1 month ago

Sorry for a delay, iPad Air 2 with iOS 15.x simply does not show dashboards with 2024.5 )))) That is why I am a bit stuck here )))

erkr commented 1 month ago

Too bad, sorry to hear that. Thanks for replying

ildar170975 commented 1 month ago

Managed to get iPad to work, hold on...

iPad Air 2, iOS 15.x:

type: entities
entities:
  - input_boolean.test_boolean
  - type: custom:template-entity-row
    entity: sun.sun
    hold_action: >-
      {% set ip = 'google.com' -%}
      {%- if is_state('input_boolean.test_boolean','on') -%}
        { "action": "url", "url_path": "http://{{ip}}" }
      {%- else -%}
        { "action": "more-info" }
      {%- endif %}

If condition is TRUE or FALSE - hold_action does nothing. So, the issue is confirmed.

erkr commented 1 month ago

@ildar170975 Thanks!!!