thomasloven / lovelace-template-entity-row

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

HA 2021.6 doesn't execute tap/hold action #54

Closed Mariusthvdb closed 3 years ago

Mariusthvdb commented 3 years ago

first logged on auto-entities, this seems to be an template-entity-row issue after all, therefor please allow a dedicated issue in this repo:

(no error in the inspector is displayed) but as of ha 2021.6, clicking a row doesn't popup the more-info anymore, nor does the hold navigate to the configured view:

    - type: custom:auto-entities
        card:
          type: entities
       filter:
          include:
            - group: group.github_repos_in_use
              options: &github_options
                tap_action:
                  action: more-info
                hold_action:
                  action: navigate
                  navigation_path: /ui-settings/weblinks
                type: custom:template-entity-row
                state: >
                  {% if states(config.entity) is not none %}
                    {% if state_attr(config.entity,'latest_release_tag') %}
                    {{state_attr(config.entity,'latest_release_tag')}}
                    {% else %} {{states(config.entity)}}
                    {% endif %}
                  {% else %} Unknown
                  {% endif %}
                secondary: >
                  {% if states(config.entity) == 'unavailable' %} Unavailable
                  {% elif states(config.entity) is not none %}
                    {{state_attr(config.entity,'latest_commit_message')}}
                  {% else %} Unknown
                  {% endif %}
              sort:
                method: name

this worked perfectly up to 2021.6. I've also tested with wildcard entities, and the result is identical: the frontend shows the entities alright, and all secondary info etc etc is correct, but no action is executed.

simpler config with an explicit entity:

      - type: custom:template-entity-row
        entity: sun.sun
        name: Sun elevation below -3?
        state: >
          {{state_attr('sun.sun','elevation') < -3}}
        active: >
          {{state_attr('sun.sun','elevation') < -3}}
        secondary: >
          Sun elevation: {{state_attr('sun.sun','elevation')}}

the bump to version #1.1.2 doesn't fix this issue. please have a look

chinyaolin commented 3 years ago

same

BoneheadFraggle commented 3 years ago

Same here, just want to clarify that clicking the icon works, but not the text/label/name, nor state.

Ordinary entities card:

With template-entity-row:

thomasloven commented 3 years ago

Please try version 1.2.0

BoneheadFraggle commented 3 years ago

Thanks, but 1.20 made no change for me.

Installed via HACS, reloaded (cleared cache) Restarted HA. Home Assistant 2021.6.2 template-entity-row 1.2.0

Example config:

  - entity: sensor.unavailable_entities_tmpl
    active: '{{ states(config.entity) | int > 0 }}'
    name: Enheter utan data
    secondary: '{{ as_timestamp(states[config.entity].last_changed) | timestamp_local }}'
    type: custom:template-entity-row
    hold_action:
      action: call-service
      confirmation: true
      service: script.update_unavailable_entities

Like before:

Just ping me if you want me to try something or provide logs.

Mariusthvdb commented 3 years ago

oddly enough, it does 2 things:

this is not a cache thing, its the same on Safari (sorry), Chrome, and both app and browser on iPhone

BoneheadFraggle commented 3 years ago

After testing on another computer to make sure it wasn't a cache thing (which it probably was..), I agree with @Mariusthvdb with one addition: The localization doesn't semm to work any more ("In evaluated templates the function () (underscore) will localize the to the current language. E.g. (state.binary_sensor.motion.off) will be replaced with Clear if your language is set to English.")

code:

        - entity: binary_sensor.rorelsesensor_i_entre_tmpl
          active: '{{ states(config.entity) == "on" }}'
          condition: '{{ states(config.entity) == "on" }}'
          state: _(component.binary_sensor.state.motion.{{ states(config.entity) }})
          secondary: >-
            {{ as_timestamp(states[config.entity].last_changed) |
            timestamp_local }}
          type: custom:template-entity-row

t-e-r

Mariusthvdb commented 3 years ago

fixed with 1.2.1! thanks Thomas

BoneheadFraggle commented 3 years ago

@Mariusthvdb Can you try an example like mine, with a state: _(component.binary_sensor.state.motion.{{ states(config.entity) }})?

That still doesn't work for me, but maybe that's a separate issue? The other issues, icons, click opens more-info and so on seems to work fine!

Again, probably a cache issue. I'll test a bit more. Thanks a lot Thomas!

thomasloven commented 3 years ago

Yes, that is a separate issue, and should be fixed with 1.2.1, so make sure your browser console says you have that installed.

Mariusthvdb commented 3 years ago

thank you so much Thomas, this is really very very cool!

please let me ask 1 thing here about the syntax format: is it correct we have to write it like this:

                hold_action: |
                  {
                    'action': 'url',
                    "url_path": "{{state_attr(config.entity,'latest_release_url')}}"
                  }

where a correct syntax (and much simpler) in the action would also be:

                hold_action:
                  action: url
                  url_path: >
                    {{state_attr(config.entity,'latest_release_url')}}

the latter does move away from the view, but to another internal view somehow.

again, thank you very much!

thomasloven commented 3 years ago

Correct.

I assume the second would try to navigate to "https://YOUR-HA-URL/{{state_attr(config.entity,'latest_release_url')}}" without evaluating the template.

Mariusthvdb commented 3 years ago

almost:

https://mydomain.duckdns.org:port/ui-settings/%7B%7Bstate_attr(config.entity,'latest_release_url')%7D%7D

and as expected it does nothing, other than navigate to https://mydomain.duckdns.org:port/ui-settings/

if this has settled down (your efforts I mean), would it be at all possible to enhance the row so it accepts these 'easier' configs? I ask because all other templates accept regular easy jinja...