-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Fix Tibber get_prices when called with aware datetime #123289
Fix Tibber get_prices when called with aware datetime #123289
Conversation
Hey there @Danielhiversen, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
9c12522
to
2e6effc
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
6772082
to
f2b739f
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
@functionpointer Please don't ping people for reviews. The PR is in the queue and will be picked up eventually. If the PR needs attention from someone specific, the bot will ping instead. Thanks! 👍 ../Frenck |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @functionpointer 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comment in a new PR. Thanks!
freezer.move_to(STARTTIME) | ||
call = ServiceCall(DOMAIN, PRICE_SERVICE_NAME, {"start": start_time}) | ||
|
||
result = await __get_prices(call, hass=create_mock_hass()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test the services by calling the services from the core service registry, while patching the library. Use hass.services.async_call
.
https://developers.home-assistant.io/docs/development_testing#writing-tests-for-integrations
Set up integration with a MockConfigEntry while patching the library client, and then call the service.
* Tibber: Add extra test to expose aware/naive datetime issue * Tibber: Fix get_prices action not working with aware datetimes * Tibber: Simplify comparison * Tibber: Combine timezone tests into single parametrized one * Tibber: Split test again to prevent if statement
Proposed change
Change
tibber.get_prices
action to accept both aware and naive datetimes, in addition to simple dates.I have implemented this by changing
__get_date()
to always output aware datetimes, and then modifying__get_prices()
to work with that. Naive datetimes and simple dates are interpreted to be in the default timezone, by usingas_local()
fromhomeassistant.utils.dt
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: