From d80e4a1af947620e1609c796c82447b6d931c279 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Mon, 3 Feb 2025 00:28:11 +0100 Subject: [PATCH] Energy by distance units (#2553) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Energy by distance units * Fix speling eror * Update blog/2025-01-31-energy-distance-units.md Co-authored-by: Abílio Costa --------- Co-authored-by: Abílio Costa --- blog/2025-01-31-energy-distance-units.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 blog/2025-01-31-energy-distance-units.md diff --git a/blog/2025-01-31-energy-distance-units.md b/blog/2025-01-31-energy-distance-units.md new file mode 100644 index 00000000..c1822faa --- /dev/null +++ b/blog/2025-01-31-energy-distance-units.md @@ -0,0 +1,23 @@ +--- +author: jschlyter +authorURL: https://github.com/jschlyter +title: "Energy by distance units" +--- + +### Summary of changes + +A new `ENERGY_DISTANCE` device class for representing energy per distance is now available for number and sensor entities, together with automatic unit conversion based on the unit system. +This new device class can be used, for example, on entities that show the amount of electric energy consumed by an electric car. A corresponding `UnitOfEnergyDistance` unit enumerator, and `EnergyDistanceConverter` converter class have been added to support the new device class. + +The following units are available: + +- kWh/100km +- mi/kWh +- km/kWh + +More details can be found in the [Number documentation](/docs/core/entity/number#available-device-classes) and [Sensor documentation](/docs/core/entity/sensor#available-device-classes) + + +### Inverse Units + +Implementing `EnergyDistanceConverter` has also resulted in support for inverse units in `BaseUnitConverter`. This simplifies adding new units that are inverses of one another, e.g., kWh/100km and km/kWh.