benct / lovelace-multiple-entity-row

Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UI
MIT License
807 stars 62 forks source link

tap_action per entity #31

Closed SeLLeRoNe closed 4 years ago

SeLLeRoNe commented 4 years ago

Hi there, first of all, thanks for this card, it is very useful for my current project :)

I would like to ask if it would be possible to have the "tap_action" to work for each defined entity so that I can decide nothing have to happen, or more spefiically for my case, to open a browser_mod.popup using call-service

Here what I am trying now:

                entities:
                  - type: custom:multiple-entity-row
                    entity: input_number.climate_t1_house_workday
                    icon: mdi:timer
                    primary:
                      entity: input_datetime.climate_t1_house_workday_start
                    secondary:
                      entity: input_datetime.climate_t1_house_workday_end
                    tap_action:
                      action: call-service
                      service: browser_mod.popup
                      service_data:
                        title: T1 Workday
                        card:
                          type: entities
                          entities:
                            - input_datetime.climate_t1_house_workday_start
                            - input_datetime.climate_t1_house_workday_end
                            - input_number.climate_t1_house_workday

Unfortuntately for now it seems that it is completely ignored, even if I set on each other entity to do nothing:

                    primary:
                      entity: input_datetime.climate_t1_house_workday_start
                      tap_action:
                        action: none

Would that be possible to integrate?

Thanks Andrea

SeLLeRoNe commented 4 years ago

Ok, I found that there is a service call that can be performed directly inside the card but that doesn't work for the "whole card" (and even the tap_action is ignored for the "whole card")

Example:

    type: custom:multiple-entity-row
    name: '[[name]]'
    entity: input_number.climate_[[area]]_[[day]]_[[timing]]
    icon: mdi:timer
    primary:
      entity: input_boolean.climate_[[area]]_[[day]]_[[timing]]
      service: browser_mod.popup
      service_data:
        title: Configuration
        card:
          type: entities
          entities:
            - input_boolean.climate_[[area]]_[[day]]_[[timing]]
            - input_datetime.climate_[[area]]_[[day]]_[[timing]]_start
            - input_datetime.climate_[[area]]_[[day]]_[[timing]]_end
            - type: section
              label: Temperature
            - type: custom:slider-entity-row
              entity: input_number.climate_[[area]]_[[day]]_[[timing]]
              full_row: true
    secondary:
      entity: input_datetime.climate_[[area]]_[[day]]_[[timing]]_start
      service: browser_mod.popup
      service_data:
        title: Configuration
        card:
          type: entities
          entities:
            - input_boolean.climate_[[area]]_[[day]]_[[timing]]
            - input_datetime.climate_[[area]]_[[day]]_[[timing]]_start
            - input_datetime.climate_[[area]]_[[day]]_[[timing]]_end
            - type: section
              label: Temperature
            - type: custom:slider-entity-row
              entity: input_number.climate_[[area]]_[[day]]_[[timing]]
              full_row: true
    tertiary:
      entity: input_datetime.climate_[[area]]_[[day]]_[[timing]]_end
      service: browser_mod.popup
      service_data:
        title: Configuration
        card:
          type: entities
          entities:
            - input_boolean.climate_[[area]]_[[day]]_[[timing]]
            - input_datetime.climate_[[area]]_[[day]]_[[timing]]_start
            - input_datetime.climate_[[area]]_[[day]]_[[timing]]_end
            - type: section
              label: Temperature
            - type: custom:slider-entity-row
              entity: input_number.climate_[[area]]_[[day]]_[[timing]]
              full_row: true
    service: browser_mod.popup
    service_data:
      title: Configuration
      card:
        type: entities
        entities:
          - input_boolean.climate_[[area]]_[[day]]_[[timing]]
          - input_datetime.climate_[[area]]_[[day]]_[[timing]]_start
          - input_datetime.climate_[[area]]_[[day]]_[[timing]]_end
          - type: section
            label: Temperature
          - type: custom:slider-entity-row
            entity: input_number.climate_[[area]]_[[day]]_[[timing]]
            full_row: true
benct commented 4 years ago

That's correct, the service call is not supported on the main entity at the moment. I'll try to get that implemented in the near future.

SeLLeRoNe commented 4 years ago

Thank you very much :)

benct commented 4 years ago

Off-topic, but what are you using to handle the templating in the example above (climate_[[area]]_[[day]]_[[timing]])?

SeLLeRoNe commented 4 years ago

Config Template Card: https://github.com/iantrich/config-template-card

SeLLeRoNe commented 4 years ago

Correction, in that specific case it was the Decluttering Card: https://github.com/custom-cards/decluttering-card Which does have some variables function which you can "pass on" the template you create so that it uses them (basically to allow you to create a template and pass the information you want to elaborate as variables, allowing you to use it multiple times for different reasons).

Sorry about the confusion.

benct commented 4 years ago

Implemented tap_action on main entity and moved sub entities service configuration into tap_action too, so to better match the default lovelace card configs.

SeLLeRoNe commented 4 years ago

Thanks!

It's working perfectly, except one thing :)

image

If I click on the "T7" I correctly got the popup, while if I click on the icon on the left I got the standard popup: image

I think the icon should be part of the "main entity" tap_action ;)

benct commented 4 years ago

I just added the tap action on the state value itself because that is the way all other entity-rows behave. Try clicking on a default row and more-info dialog is shown on the icon and name, while an action (or nothing) is activated on a state click.

SeLLeRoNe commented 4 years ago

mmmh, not 100% sure to be honest. I do have an entity card where I set the tap_action to "none" and that is applied for the whole thing (including icon and name).

I tried to change it to more-info and I do have the popup on the icon and name, but oddly enough not on the state (person entity)

In the multiple-entity card it's happening the opposite somehow, I got the right popup on the state (T7 in the previous screenshot) and the "more-info" if I click on "thermostat" (text) and the icon