Skip to content

Add mV as a unit for voltage and enable conversions#84805

Merged
frenck merged 7 commits into
home-assistant:devfrom
jbouwh:accept-mV-as-valid-unit-for-voltage
Dec 30, 2022
Merged

Add mV as a unit for voltage and enable conversions#84805
frenck merged 7 commits into
home-assistant:devfrom
jbouwh:accept-mV-as-valid-unit-for-voltage

Conversation

@jbouwh
Copy link
Copy Markdown
Contributor

@jbouwh jbouwh commented Dec 29, 2022

Proposed change

The unit mV was added for device_class voltage, but only V was still accepted as valid unit.
Further conversion support between V and mV (voltage) was missing.

Related frontend PR: home-assistant/frontend#14921

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
  • 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
Copy Markdown
Contributor

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (sensor) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of sensor can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign sensor Removes the current integration label and assignees on the issue, add the integration domain after the command.

Copy link
Copy Markdown
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

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

See #84492

I suggest that you restrict this PR to only electric potential, and create the corresponding:

  • arch discussion
  • dev docs PR
  • docs PR
  • frontend PR

@epenet
Copy link
Copy Markdown
Contributor

epenet commented Dec 29, 2022

Also, please note that the way to "fix" this in 2023.1 beta is to remove the incorrect device class.
Then it can be added again for 2023.2 once the conversion has been added.

@jbouwh jbouwh marked this pull request as draft December 29, 2022 21:11
epenet
epenet previously requested changes Dec 29, 2022
Comment thread homeassistant/util/unit_conversion.py Outdated
Comment thread homeassistant/components/sensor/__init__.py Outdated
Comment thread homeassistant/components/sensor/__init__.py Outdated
Comment thread homeassistant/components/sensor/__init__.py Outdated
Comment thread homeassistant/components/sensor/__init__.py Outdated
Comment thread tests/components/sensor/test_init.py Outdated
Comment thread tests/components/sensor/test_init.py Outdated
Comment thread tests/util/test_unit_conversion.py Outdated
Comment thread tests/util/test_unit_conversion.py Outdated
Comment thread tests/util/test_unit_conversion.py Outdated
@jbouwh jbouwh force-pushed the accept-mV-as-valid-unit-for-voltage branch from a41d610 to 97480f3 Compare December 29, 2022 21:37
@jbouwh jbouwh changed the title Fix mV and mA valid unit for voltage and enable conversions Add mV and as a unit for voltage and enable conversions Dec 29, 2022
@jbouwh jbouwh force-pushed the accept-mV-as-valid-unit-for-voltage branch from 97480f3 to f3c5ffe Compare December 29, 2022 21:56
@epenet epenet changed the title Add mV and as a unit for voltage and enable conversions Add mV as a unit for voltage and enable conversions Dec 29, 2022
@jbouwh
Copy link
Copy Markdown
Contributor Author

jbouwh commented Dec 29, 2022

@jbouwh jbouwh marked this pull request as ready for review December 29, 2022 23:46
@frenck frenck added this to the 2023.1.0 milestone Dec 30, 2022
Copy link
Copy Markdown
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @jbouwh! ✅

As I wrote in the linked architectural discussion, we are going to pull this into the current 2023.1 beta, to minimize the impact of the new checks.

../Frenck

@frenck frenck dismissed epenet’s stale review December 30, 2022 11:50

Comments have been addressed

@frenck frenck merged commit b2388b7 into home-assistant:dev Dec 30, 2022
@jbouwh jbouwh deleted the accept-mV-as-valid-unit-for-voltage branch December 30, 2022 13:15
@frenck frenck modified the milestone: 2023.1.0 Dec 30, 2022
frenck pushed a commit that referenced this pull request Dec 30, 2022
kvanzuijlen pushed a commit to kvanzuijlen/core that referenced this pull request Dec 30, 2022
kvanzuijlen pushed a commit to kvanzuijlen/core that referenced this pull request Dec 30, 2022
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 31, 2022
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.

Entity xxx_voltage is using native unit of measurement 'mV' which is not a valid unit for the device class ('voltage')

3 participants