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

@ -58,6 +58,7 @@ def test_matches_device_classes(device_class: SensorDeviceClass) -> None:
SensorDeviceClass.BATTERY: "CONF_IS_BATTERY_LEVEL",
SensorDeviceClass.CO: "CONF_IS_CO",
SensorDeviceClass.CO2: "CONF_IS_CO2",
SensorDeviceClass.CONDUCTIVITY: "CONF_IS_CONDUCTIVITY",
SensorDeviceClass.ENERGY_STORAGE: "CONF_IS_ENERGY",
SensorDeviceClass.VOLUME_STORAGE: "CONF_IS_VOLUME",
}.get(device_class, f"CONF_IS_{device_class.value.upper()}")
@ -66,6 +67,7 @@ def test_matches_device_classes(device_class: SensorDeviceClass) -> None:
# Ensure it has correct value
constant_value = {
SensorDeviceClass.BATTERY: "is_battery_level",
SensorDeviceClass.CONDUCTIVITY: "is_conductivity",
SensorDeviceClass.ENERGY_STORAGE: "is_energy",
SensorDeviceClass.VOLUME_STORAGE: "is_volume",
}.get(device_class, f"is_{device_class.value}")

View file

@ -62,6 +62,7 @@ def test_matches_device_classes(device_class: SensorDeviceClass) -> None:
SensorDeviceClass.BATTERY: "CONF_BATTERY_LEVEL",
SensorDeviceClass.CO: "CONF_CO",
SensorDeviceClass.CO2: "CONF_CO2",
SensorDeviceClass.CONDUCTIVITY: "CONF_CONDUCTIVITY",
SensorDeviceClass.ENERGY_STORAGE: "CONF_ENERGY",
SensorDeviceClass.VOLUME_STORAGE: "CONF_VOLUME",
}.get(device_class, f"CONF_{device_class.value.upper()}")
@ -70,6 +71,7 @@ def test_matches_device_classes(device_class: SensorDeviceClass) -> None:
# Ensure it has correct value
constant_value = {
SensorDeviceClass.BATTERY: "battery_level",
SensorDeviceClass.CONDUCTIVITY: "conductivity",
SensorDeviceClass.ENERGY_STORAGE: "energy",
SensorDeviceClass.VOLUME_STORAGE: "volume",
}.get(device_class, device_class.value)