jcwillox / lovelace-paper-buttons-row

Adds highly configurable buttons that use actions and per-state styling.
MIT License
287 stars 10 forks source link

How to pass `target` when calling a service? #40

Closed denilsonsa closed 2 years ago

denilsonsa commented 3 years ago

I believe recent Home Assistant versions added support for target when calling a service:

However, I can't find a way to do so when using this custom component. The following example works in the developer tools page:

service: light.turn_on
data:
  transition: 60
  color_temp: 450
  brightness_pct: 100
target:
  entity_id:
    - light.foo
    - light.bar

And the following code works using the built-in buttons type:

type: entities
entities:
  - type: buttons
    entities:
      - entity: light.bedroom_lights
        name: 1min
        icon: 'mdi:lightbulb-on'
        tap_action:
          action: call-service
          service: light.turn_on
          service_data:
            transition: 60
            color_temp: 450
            brightness_pct: 100
          target:
            entity_id:
              - light.bedroom_lights
              - light.foobar
…

But I am unable to add target to custom:paper-buttons-row.

jcwillox commented 3 years ago

Hmm, yes target is not a supported option of tap_action at least in paper-buttons-row that's something I'll have to implement. Interestingly it's not listed on Home Assistants action docs, but I agree that it is working on the built-in cards.

denilsonsa commented 3 years ago

Interestingly it's not listed on Home Assistants action docs

Yep, I've already reported it: https://github.com/home-assistant/home-assistant.io/issues/16992

ristomatti commented 2 years ago

Any update? Logitech Harmony Hub remote requires this also. As a workaround I can create a script for each button but that's a lot of scripts! Maybe there's some better alternative but I'm just few weeks into HA. :slightly_smiling_face:

ristomatti commented 2 years ago

If it's any help, the usage seems to be documented here and used included in this example.

ristomatti commented 2 years ago

I decided to give it a shot and it seems I got it working, I'll create a PR. The funny thing is that this was not actually needed for my use case after all. I had the config set like this:

action: call-service
service: remote.send_command
service_data:
  entity_id: remote.harmony_hub
  device: '37034509'
  command: 'FanSpeedUp'

...instead of this:

tap_action:
  action: call-service
  service: remote.send_command
  service_data:
    entity_id: remote.harmony_hub
    device: '37034509'
    command: 'FanSpeedUp'

:man_facepalming:

ristomatti commented 2 years ago

@denilsonsa If you'd like to help, you could test if my changes work as you'd expect. I set up my so that it can be installed as a custom HACS repository (for personal testing purposes) https://github.com/ristomatti/lovelace-paper-buttons-row