thomasloven / lovelace-template-entity-row

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

FR: support Button on state position #74

Open Mariusthvdb opened 2 years ago

Mariusthvdb commented 2 years ago

Please consider adding support for the Button entity and showing the Button Press as state, just like is done with the toggle for switch. Currently we see

Schermafbeelding 2022-03-08 om 10 40 31

when using:

        - type: custom:template-entity-row
          entity: button.front_room_ping
          secondary: >
            {{as_timestamp(states(config.entity))|
                                timestamp_custom('%d %b %X')}}

and since we dont have a HA core way to use the secondary_info: line for last-triggered one a button (because the button entity doesnt have a last_triggered attribute), this would be the only way to combine both the secondary_info, And the button?

        - type: custom:template-entity-row
          entity: button.front_room_ping
          button: true
          secondary: >
            {{as_timestamp(states(config.entity))|
                                timestamp_custom('%d %b %X')}}

the current more-info shows the last-changed time, but that really is useless info, as it merely shows what the last restart of the system was in this case, and doesn't not survive restart/get restored:

Schermafbeelding 2022-03-08 om 10 52 54

Thanks!

Mariusthvdb commented 2 years ago

or, see: https://community.home-assistant.io/t/auto-entities-automatically-fill-cards-with-entities/147801/546

using:

          filter:
            template: >
              {%- for s in states.binary_sensor -%}
                {%- if s.object_id.endswith("firmware_update") and states(s.entity_id) == 'on' -%}
                    {{
                      { 'type': 'custom:template-entity-row',
                        'entity': "button." + s.object_id.replace("firmware_update", "ota_update"),
                        'state': 'BUTTON',
                        'secondary': state_attr(s.entity_id, 'installed_version')
                      }
                    }},
                {%- endif -%}
              {%- endfor -%}

in an auto-entities card