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 current intraday price ranking to Tibber price sensor #124595

Conversation

haugene
Copy link
Contributor

@haugene haugene commented Aug 25, 2024

Proposed change

Upgrading pyTibber dependency from 0.28.2 to 0.29.0. See the release notes for more details.

It includes support for Python 3.12, Ruff upgrades, updates to documentation and a new attribute for the price sensor.
The new attribute breaks one of the calls from this integration to the pyTibber library and I'm adding support for it here.
PR for this change is here: Danielhiversen/pyTibber#288

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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.

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 @haugene

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

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.

@home-assistant
Copy link

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

Code owner commands

Code owners of tibber 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 tibber Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please wait for this PR to be solved:
#124407

@haugene
Copy link
Contributor Author

haugene commented Aug 25, 2024

Please wait for this PR to be solved: #124407

Ah yes 🙈 I actually looked at it, but missed the _ assignment for the return value where I expanded the tuple 🤦‍♂️ Thought I'd make it easier if I cleared that one step out of the way.

I'll wait for that to be merged and rebase + resubmit 👍

@haugene haugene force-pushed the haugene/tibber-intraday-price-ranking branch from 09785a6 to 0b29a21 Compare August 27, 2024 12:52
@haugene
Copy link
Contributor Author

haugene commented Aug 27, 2024

There we go ✔️ After waiting 6 months to follow up my new "feature", I'm one day early with the PR 😆
Hopefully this looks better 👍

@haugene haugene requested a review from MartinHjelmare August 27, 2024 12:57
@haugene
Copy link
Contributor Author

haugene commented Aug 27, 2024

And FYI. I'm getting this error when starting HA locally:

2024-08-27 12:53:36.477 ERROR (MainThread) [tibber.home] Error in rt_subscribe
Traceback (most recent call last):
  File "/home/vscode/.local/ha-venv/lib/python3.12/site-packages/tibber/home.py", line 460, in _start
    data = _add_extra_data(data)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/ha-venv/lib/python3.12/site-packages/tibber/home.py", line 421, in _add_extra_data
    if live_data.get("powerProduction", 0) > 0 and live_data.get("power") is None:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int'

Seems like the powerProduction key in the dict here is set to None and then the default value of 0 isn't returned.

@MartinHjelmare
Copy link
Member

If possible, please make a PR with a fix to pyTibber if there's a bug there.

@haugene
Copy link
Contributor Author

haugene commented Aug 28, 2024

If possible, please make a PR with a fix to pyTibber if there's a bug there.

PR is here: Danielhiversen/pyTibber#303

This is unrelated to the change in this PR of course. But if you want I can make it part of this PR to bump the dependency to a new pyTibber and verify it.

@MartinHjelmare
Copy link
Member

It's enough if you've tested locally with the fix in pyTibber that this PR works.

@haugene
Copy link
Contributor Author

haugene commented Aug 28, 2024

It's enough if you've tested locally with the fix in pyTibber that this PR works.

I've tested the fix in pyTibber and it stops throwing exceptions. So that's why I'm asking if you'll build a new release of pyTibber and i could bump it here.

And just to be clear. Both the bug, and fix, in pyTibber has nothing to do with intraday_price_ranking. It's just a parsing error of the subscription data from the Tibber API. But I can still bump it as part of this PR to get it in. If you want. This PR works both with and without the fix in pyTibber. The bug is related to liveMeasurement data, and not price data.

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Aug 28, 2024

I don't maintain pyTibber so I can't cut a new release there on my own. Daniel maintains that library.

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

Please undraft the PR when ready to merge.

@haugene haugene marked this pull request as ready for review August 28, 2024 15:42
@MartinHjelmare MartinHjelmare merged commit 25cdd73 into home-assistant:dev Aug 28, 2024
25 of 26 checks passed
Gigatrappeur pushed a commit to Gigatrappeur/ha-core that referenced this pull request Aug 28, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2024
@haugene haugene deleted the haugene/tibber-intraday-price-ranking branch August 30, 2024 09:28
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.

3 participants