Add Siemes and Millisiemens as additional units of conductivity and enable conversion between conductivity units (#118728)

This commit is contained in:
dontinelli 2024-06-21 11:10:15 +02:00 committed by GitHub
parent 818750dfd1
commit 0dd5391cd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 112 additions and 16 deletions

View file

@ -18,6 +18,7 @@ from homeassistant.const import (
SIGNAL_STRENGTH_DECIBELS,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
UnitOfApparentPower,
UnitOfConductivity,
UnitOfDataRate,
UnitOfElectricCurrent,
UnitOfElectricPotential,
@ -120,6 +121,12 @@ class NumberDeviceClass(StrEnum):
Unit of measurement: `ppm` (parts per million)
"""
CONDUCTIVITY = "conductivity"
"""Conductivity.
Unit of measurement: `S/cm`, `mS/cm`, `µS/cm`
"""
CURRENT = "current"
"""Current.
@ -424,6 +431,7 @@ DEVICE_CLASS_UNITS: dict[NumberDeviceClass, set[type[StrEnum] | str | None]] = {
NumberDeviceClass.BATTERY: {PERCENTAGE},
NumberDeviceClass.CO: {CONCENTRATION_PARTS_PER_MILLION},
NumberDeviceClass.CO2: {CONCENTRATION_PARTS_PER_MILLION},
NumberDeviceClass.CONDUCTIVITY: set(UnitOfConductivity),
NumberDeviceClass.CURRENT: set(UnitOfElectricCurrent),
NumberDeviceClass.DATA_RATE: set(UnitOfDataRate),
NumberDeviceClass.DATA_SIZE: set(UnitOfInformation),