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 Energyzero get_prices service #100499

Merged

Conversation

iamrgroot
Copy link
Contributor

@iamrgroot iamrgroot commented Sep 16, 2023

Proposed change

Follow-up of #100370 (comment)

This PR adds a service that returns the energy and gas prices as response. This allows someone to put it into a template sensor:

template:
  - trigger:
      - platform: time_pattern
        hours: "*"
    action:
      - service: energyzero.get_prices
        data:
          type: energy
        response_variable: prices
    sensor:
      - name: Response
        device_class: timestamp
        state: "{{ now() }}"
        attributes:
          prices: '{{ prices }}'

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 Black (black --fast 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:

@home-assistant
Copy link

Hey there @klaasnicolaas, mind taking a look at this pull request as it has been labeled with an integration (energyzero) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of energyzero can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign energyzero Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@iamrgroot iamrgroot marked this pull request as ready for review September 16, 2023 21:50
@iamrgroot
Copy link
Contributor Author

@klaasnicolaas do you maybe have some time to look at this pr?

Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Please make sure CI is passing

homeassistant/components/energyzero/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/energyzero/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/energyzero/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/energyzero/const.py Outdated Show resolved Hide resolved
homeassistant/components/energyzero/__init__.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft September 25, 2023 09:57
@home-assistant
Copy link

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.

@edenhaus
Copy link
Contributor

Btw your example can be simplified by using actions in your template

@iamrgroot iamrgroot marked this pull request as ready for review September 25, 2023 13:04
@iamrgroot
Copy link
Contributor Author

@edenhaus
Copy link
Contributor

@edenhaus can I fix this CI run myself? home-assistant/core/actions/runs/6300571239/job/17106518193

Nope only members can retrigger the job.

@iamrgroot
Copy link
Contributor Author

@edenhaus is there any way to get this though without a review from the code owner (or am I being a bit too eager)?

@klaasnicolaas
Copy link
Member

By waiting patiently and no, we are certainly not going to just skip the code owner just to get a PR through 😉

Copy link
Member

@klaasnicolaas klaasnicolaas left a comment

Choose a reason for hiding this comment

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

✅ Approved, don't see anything strange in the code at the moment

homeassistant/components/energyzero/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/energyzero/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/energyzero/const.py Outdated Show resolved Hide resolved
homeassistant/components/energyzero/strings.json Outdated Show resolved Hide resolved
homeassistant/components/energyzero/strings.json Outdated Show resolved Hide resolved
homeassistant/components/energyzero/strings.json Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft October 2, 2023 19:45
tests/components/energyzero/test_services.py Outdated Show resolved Hide resolved
tests/components/energyzero/test_services.py Outdated Show resolved Hide resolved
@iamrgroot iamrgroot marked this pull request as ready for review October 3, 2023 06:01
@home-assistant home-assistant bot requested a review from joostlek October 3, 2023 06:01
Copy link
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

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

Final remark

homeassistant/components/energyzero/strings.json Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft October 3, 2023 08:17
@iamrgroot iamrgroot marked this pull request as ready for review October 3, 2023 08:26
@home-assistant home-assistant bot requested a review from joostlek October 3, 2023 08:26
Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Thanks @iamrgroot 👍

@edenhaus edenhaus changed the title Energyzero service response Add Energyzero get_prices service Oct 3, 2023
@edenhaus edenhaus merged commit d518cf1 into home-assistant:dev Oct 3, 2023
21 checks passed
@frenck
Copy link
Member

frenck commented Oct 3, 2023

@edenhaus @iamrgroot @klaasnicolaas I want to revert this PR, as I think the approach is wrong.

Let me make a revert and explain why in the revert PR.

../Frenck

frenck added a commit that referenced this pull request Oct 3, 2023
@iamrgroot
Copy link
Contributor Author

@frenck this already was a different approach that was suggested by you in #100370

Let me know what to do differently and I'll try again

@frenck
Copy link
Member

frenck commented Oct 3, 2023

@iamrgroot Yup. This is the right direction though, but we should not have merged this.

../Frenck

balloob pushed a commit that referenced this pull request Oct 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2023
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

5 participants