Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass target when calling a service? #40

Closed
denilsonsa opened this issue Mar 13, 2021 · 6 comments · Fixed by #68
Closed

How to pass target when calling a service? #40

denilsonsa opened this issue Mar 13, 2021 · 6 comments · Fixed by #68
Labels
enhancement New feature or request

Comments

@denilsonsa
Copy link

denilsonsa commented Mar 13, 2021

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
Copy link
Owner

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.

@jcwillox jcwillox added the enhancement New feature or request label Mar 15, 2021
@denilsonsa
Copy link
Author

Interestingly it's not listed on Home Assistants action docs

Yep, I've already reported it: home-assistant/home-assistant.io#16992

@ristomatti
Copy link
Contributor

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. 🙂

@ristomatti
Copy link
Contributor

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

@ristomatti
Copy link
Contributor

ristomatti commented Dec 17, 2021

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'

🤦‍♂️

@ristomatti
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants