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 for payload_template in rest component #107464

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

ptashek
Copy link
Contributor

@ptashek ptashek commented Jan 7, 2024

Breaking change

Proposed change

This PR picks up where #73106 left off. This change adds the option to use templates in rest sensor payload option, allowing to send dynamically changed payloads to the remote endpoint. This is especially useful with APIs like GraphQL, as demonstrated in my comment on the feature request thread on the community forum.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @ptashek

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
Copy link

home-assistant bot commented Jan 7, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@ptashek
Copy link
Contributor Author

ptashek commented Jan 7, 2024

Related documentation update PR: home-assistant/home-assistant.io#30710

@ptashek ptashek force-pushed the payload_template branch 2 times, most recently from 0ee2388 to 698a0c4 Compare January 12, 2024 19:45
Copy link

@luuuis luuuis left a comment

Choose a reason for hiding this comment

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

Nice work.

@ptashek ptashek force-pushed the payload_template branch 2 times, most recently from d9ba00b to 6d7734d Compare January 22, 2024 00:27
@ptashek
Copy link
Contributor Author

ptashek commented Jan 24, 2024

@luuuis Thank you for the review and the approval.
Not sure why the merge is still blocked - is there a specific maintainer that must approve additionally?

@luuuis
Copy link

luuuis commented Jan 25, 2024

I suppose so @ptashek , I am new and not sure of the process myself.

Copy link
Contributor

@IceBotYT IceBotYT left a comment

Choose a reason for hiding this comment

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

Works for me!

@ptashek ptashek force-pushed the payload_template branch 3 times, most recently from 61cbd47 to 8680415 Compare February 15, 2024 20:21
@ptashek ptashek force-pushed the payload_template branch 2 times, most recently from b5b1bd3 to 3327056 Compare February 23, 2024 20:41
@ptashek ptashek force-pushed the payload_template branch 2 times, most recently from ca0a89a to 4a5a326 Compare March 25, 2024 23:38
@@ -61,6 +62,7 @@
vol.Optional(CONF_USERNAME): cv.string,
vol.Optional(CONF_PASSWORD): cv.string,
vol.Optional(CONF_PAYLOAD): cv.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

This too needs the exclusive marker

@home-assistant home-assistant bot marked this pull request as draft April 18, 2024 08:35
@emontnemery emontnemery marked this pull request as ready for review April 18, 2024 09:53
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @ptashek 👍

I'd like a second opinion before merge though

@emontnemery emontnemery added the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Apr 18, 2024
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

After looking at the missing code coverage I'm not so sure about the changes.
Also, the RestData class is shared with the scrape integration, does that integration need to be changed too when we make changes here?

@home-assistant home-assistant bot marked this pull request as draft April 18, 2024 10:32
@emontnemery emontnemery marked this pull request as ready for review April 18, 2024 13:18
@emontnemery emontnemery removed the second-opinion-wanted Add this label when a reviewer needs a second opinion from another member. label Apr 18, 2024
@emontnemery emontnemery merged commit ceaf8f2 into home-assistant:dev Apr 18, 2024
24 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants