core icon indicating copy to clipboard operation
core copied to clipboard

Add current intraday price ranking to Tibber price sensor

Open haugene opened this issue 1 year ago • 10 comments

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: https://github.com/Danielhiversen/pyTibber/pull/288

Type of change

  • [x] 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

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] I have followed the perfect PR recommendations
  • [x] 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:

haugene avatar Aug 25 '24 20:08 haugene

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

Learn more about our pull request process.

home-assistant[bot] avatar Aug 25 '24 20:08 home-assistant[bot]

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.

home-assistant[bot] avatar Aug 25 '24 20:08 home-assistant[bot]

Please wait for this PR to be solved: #124407

Ah yes :see_no_evil: I actually looked at it, but missed the _ assignment for the return value where I expanded the tuple :man_facepalming: 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 :+1:

haugene avatar Aug 25 '24 20:08 haugene

There we go :heavy_check_mark: After waiting 6 months to follow up my new "feature", I'm one day early with the PR :laughing: Hopefully this looks better :+1:

haugene avatar Aug 27 '24 12:08 haugene

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.

haugene avatar Aug 27 '24 12:08 haugene

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

MartinHjelmare avatar Aug 27 '24 13:08 MartinHjelmare

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

PR is here: https://github.com/Danielhiversen/pyTibber/pull/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.

haugene avatar Aug 28 '24 07:08 haugene

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

MartinHjelmare avatar Aug 28 '24 10:08 MartinHjelmare

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.

haugene avatar Aug 28 '24 12:08 haugene

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

MartinHjelmare avatar Aug 28 '24 12:08 MartinHjelmare