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

Wh is not a recognized volume unit - 2023.9 beta #99525

Closed
purcell-lab opened this issue Sep 3, 2023 · 3 comments · Fixed by #99708
Closed

Wh is not a recognized volume unit - 2023.9 beta #99525

purcell-lab opened this issue Sep 3, 2023 · 3 comments · Fixed by #99708

Comments

@purcell-lab
Copy link
Contributor

The problem

With the 2023.9 beta Wh is again causing issues on the Gas Consumption dashboard.

Gas consumption measured in Wh is an allowed sensor for the Gas consumption dashboard:

image

This was functional with 2023.8 and earlier, kWh is still functional, just sensors in Wh are causing this issue.

What version of Home Assistant Core has the issue?

core-2023.9.0b

What was the last working version of Home Assistant Core?

core-2023.8

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

energy

Link to integration documentation on our website

https://www.home-assistant.io/docs/energy

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 93, in _get_from_to_ratio
    return unit_conversion[from_unit], unit_conversion[to_unit]
           ~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: <UnitOfEnergy.WATT_HOUR: 'Wh'>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 293, in _async_dispatch_entity_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 615, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/energy/sensor.py", line 421, in async_state_changed_listener
    self._update_cost()
  File "/usr/src/homeassistant/homeassistant/components/energy/sensor.py", line 387, in _update_cost
    converted_energy_price = converter(
                             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 73, in convert
    return cls.converter_factory(from_unit, to_unit)(value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 83, in converter_factory
    from_ratio, to_ratio = cls._get_from_to_ratio(from_unit, to_unit)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/unit_conversion.py", line 95, in _get_from_to_ratio
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Wh is not a recognized volume unit.

Additional information

The fix for a similar issue back in November was:
home-assistant/frontend#14448

unsure if there is a similar cause this time around?

@home-assistant
Copy link

home-assistant bot commented Sep 4, 2023

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

Code owner commands

Code owners of energy can trigger bot actions by commenting:

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

(message by CodeOwnersMention)


energy documentation
energy source
(message by IssueLinks)

@emontnemery
Copy link
Contributor

emontnemery commented Sep 6, 2023

@purcell-lab what device class is the sensor and which integration provides it? If you've defined the sensor yourself with a template or something similar, please share the configuration

The bug is related to the unit of the gas price, and the linked PR fixes that. However, that bug is very old and was not introduced in 2023.9 beta.
Have you changed anything related to the gas price? How have you configured the gas price? If the gas price is derived from a sensor, can you share that sensor's configuration or which integration provides it?

@purcell-lab
Copy link
Contributor Author

Have you changed anything related to the gas price? How have you configured the gas price? If the gas price is derived from a sensor, can you share that sensor's configuration or which integration provides it?

I didn't change anything with 9 beta.

The price sensor I am using house_consumption_cost is in $/kWh.

I have other sensors in the gas consumption dashboard which are in units kWh and are still functioning correctly, but this one sensor which is reporting in Wh is causing this issue, which I note is different to the denominator of the price sensor above.

image

@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants