Add speed conversion function#53846
Conversation
|
Hey there @DylanGore, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Hey there @raman325, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Hey there @Danielhiversen, @thimic, mind taking a look at this pull request as it has been labeled with an integration ( |
|
Hey there @MatthewFlamm, mind taking a look at this pull request as it has been labeled with an integration ( |
|
I apologize for the excessive bot pinging, probably due to refactoring across a few different components. I did not expect that to happen. |
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
|
This looks mostly good. One concern though; let's move the adding of a default speed unit for the imperial and metric unit systems to a separate PR:
This can be discussed in a separate PR, then this PR is ready for merge IMO. |
|
@emontnemery pinging you in case you didn't get notified of my new commits. I parameterized the tests slightly differently than you suggested (by using only one parameterize call and passing in the expected conversion results). Let me know if you still like your method better. |
|
It's OK, I think. Just a couple of small comments on the tests. |
|
I think all of the conversion factors get tested even if there's not every single permutation, since I use every unit at least once. I don't see your other comments on the tests. Did I accidentally resolve them? |
I forgot to "publish" the review, sorry about that 🤦 |
|
No worries! Thank you for the review. I've addressed the comments. |
Proposed change
Similar to how the distance and temperature units have conversion functions, I created one for converting between speeds, along with tests.
While this refactor does not result in any immediate gains, this function will help implement #48641, which requires converting speeds between user-configurable units.
I've also edited existing kph <--> mph unit conversions using the length conversion function to use the speed conversion function.
Type of change
Additional information
Checklist
black --fast 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..coveragerc.To help with the load of incoming pull requests: