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

Add support to service call target #68

Merged
merged 4 commits into from
Dec 24, 2021
Merged

Add support to service call target #68

merged 4 commits into from
Dec 24, 2021

Conversation

ristomatti
Copy link
Contributor

This allows setting a target to a call-service action, e.g.

tap_action:
  action: call-service
  service: remote.send_command
  service_target:
    device_id: a6015bda1dfaf2b5a38f7eefeb050c06
  service_data:
    device: '37034509'
    command: 'FanSpeedUp'

Resolves #40.

@ristomatti
Copy link
Contributor Author

The support lacked also from custom-card-helpers, hence I had to augment the type for CallServiceActionConfig and call a function directly from home-assistant-js-websocket.

Copy link
Owner

@jcwillox jcwillox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great timing, just after the migration to Typescript and GH actions.

You might want to send a PR to custom-card-helpers as well as they should really be supporting this too.

src/action.ts Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
src/action.ts Show resolved Hide resolved
@ristomatti
Copy link
Contributor Author

Great timing, just after the migration to Typescript and GH actions.

As a complete noob to HA custom cards and the ecosystem, this PR would not have been possible with strong TypeScript types. 👍

You might want to send a PR to custom-card-helpers as well as they should really be supporting this too.

I'm not sure if I'll have time to dig into their contribution guidelines etc., I've already got (paid) work piling up 😅. Even this was unnecessary for my current use case but thought I'll make some use of the time spent twiddling with this.

@ristomatti
Copy link
Contributor Author

@jcwillox Can we go with this or do you want to wait for custom-card-helpers to add the missing type?

@jcwillox
Copy link
Owner

@jcwillox Can we go with this or do you want to wait for custom-card-helpers to add the missing type?

Well, I'll be dammed someone already added support for this 2 months ago but they haven't released the update, custom-cards/custom-card-helpers@894aec4.
I'd recommend we just install from the latest commit, I've tested it and now we can just use hass.callService and remove those extra typings 😃.

pnpm add github:custom-cards/custom-card-helpers#ae86495

@ristomatti
Copy link
Contributor Author

Oh boy. I'll have time to follow up on this after the holidays but you're welcome to pull in the changes to another branch and fix things up if you will. :)

@jcwillox
Copy link
Owner

Oh boy. I'll have time to follow up on this after the holidays but you're welcome to pull in the changes to another branch and fix things up if you will. :)

Sure thing, I've already got the code from when I was checking to see if we could just use the latest commit from custom card helpers.

@jcwillox jcwillox merged commit 5ab6123 into jcwillox:master Dec 24, 2021
@ristomatti
Copy link
Contributor Author

Thanks! One thing less on my TODO-list. 🙂

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

Successfully merging this pull request may close these issues.

How to pass target when calling a service?
2 participants