Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet committed Nov 1, 2024
1 parent 604d6cf commit d70e93a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/number/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class NumberDeviceClass(StrEnum):
"""

BLOOD_GLUCOSE_CONCENTRATION = "blood_glucose_concentration"
"""Blood sugar level.
"""Blood glucose concentration.
Unit of measurement: `mg/dL`, `mmol/L`
"""
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/recorder/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from homeassistant.util import dt as dt_util
from homeassistant.util.unit_conversion import (
BaseUnitConverter,
BloodSugarLevelConverter,
BloodGlugoseConcentrationConverter,
ConductivityConverter,
DataRateConverter,
DistanceConverter,
Expand Down Expand Up @@ -129,7 +129,10 @@


STATISTIC_UNIT_TO_UNIT_CONVERTER: dict[str | None, type[BaseUnitConverter]] = {
**{unit: BloodSugarLevelConverter for unit in BloodSugarLevelConverter.VALID_UNITS},
**{
unit: BloodGlugoseConcentrationConverter
for unit in BloodGlugoseConcentrationConverter.VALID_UNITS
},
**{unit: ConductivityConverter for unit in ConductivityConverter.VALID_UNITS},
**{unit: ConductivityConverter for unit in ConductivityConverter.VALID_UNITS},
**{unit: DataRateConverter for unit in DataRateConverter.VALID_UNITS},
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/recorder/websocket_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.helpers.json import json_bytes
from homeassistant.util import dt as dt_util
from homeassistant.util.unit_conversion import (
BloodSugarLevelConverter,
BloodGlugoseConcentrationConverter,
ConductivityConverter,
DataRateConverter,
DistanceConverter,
Expand Down Expand Up @@ -55,7 +55,9 @@

UNIT_SCHEMA = vol.Schema(
{
vol.Optional("blood_sugar_level"): vol.In(BloodSugarLevelConverter.VALID_UNITS),
vol.Optional("blood_glucose_concentration"): vol.In(
BloodGlugoseConcentrationConverter.VALID_UNITS
),
vol.Optional("conductivity"): vol.In(ConductivityConverter.VALID_UNITS),
vol.Optional("data_rate"): vol.In(DataRateConverter.VALID_UNITS),
vol.Optional("distance"): vol.In(DistanceConverter.VALID_UNITS),
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/sensor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
)
from homeassistant.util.unit_conversion import (
BaseUnitConverter,
BloodSugarLevelConverter,
BloodGlugoseConcentrationConverter,
ConductivityConverter,
DataRateConverter,
DistanceConverter,
Expand Down Expand Up @@ -130,7 +130,7 @@ class SensorDeviceClass(StrEnum):
"""

BLOOD_GLUCOSE_CONCENTRATION = "blood_glucose_concentration"
"""Blood sugar level.
"""Blood glucose concentration.
Unit of measurement: `mg/dL`, `mmol/L`
"""
Expand Down Expand Up @@ -501,7 +501,7 @@ class SensorStateClass(StrEnum):

UNIT_CONVERTERS: dict[SensorDeviceClass | str | None, type[BaseUnitConverter]] = {
SensorDeviceClass.ATMOSPHERIC_PRESSURE: PressureConverter,
SensorDeviceClass.BLOOD_GLUCOSE_CONCENTRATION: BloodSugarLevelConverter,
SensorDeviceClass.BLOOD_GLUCOSE_CONCENTRATION: BloodGlugoseConcentrationConverter,
SensorDeviceClass.CONDUCTIVITY: ConductivityConverter,
SensorDeviceClass.CURRENT: ElectricCurrentConverter,
SensorDeviceClass.DATA_RATE: DataRateConverter,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/sensor/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"name": "Battery"
},
"blood_glucose_concentration": {
"name": "Blood sugar level"
"name": "Blood glucose concentration"
},
"carbon_monoxide": {
"name": "Carbon monoxide"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/util/unit_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class DistanceConverter(BaseUnitConverter):
}


class BloodSugarLevelConverter(BaseUnitConverter):
class BloodGlugoseConcentrationConverter(BaseUnitConverter):
"""Utility to convert blood sugar level values."""

UNIT_CLASS = "blood_glucose_concentration"
Expand Down
8 changes: 4 additions & 4 deletions tests/util/test_unit_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from homeassistant.util import unit_conversion
from homeassistant.util.unit_conversion import (
BaseUnitConverter,
BloodSugarLevelConverter,
BloodGlugoseConcentrationConverter,
ConductivityConverter,
DataRateConverter,
DistanceConverter,
Expand Down Expand Up @@ -61,7 +61,7 @@
_ALL_CONVERTERS: dict[type[BaseUnitConverter], list[str | None]] = {
converter: sorted(converter.VALID_UNITS, key=lambda x: (x is None, x))
for converter in (
BloodSugarLevelConverter,
BloodGlugoseConcentrationConverter,
ConductivityConverter,
DataRateConverter,
DistanceConverter,
Expand All @@ -83,7 +83,7 @@

# Dict containing all converters with a corresponding unit ratio.
_GET_UNIT_RATIO: dict[type[BaseUnitConverter], tuple[str | None, str | None, float]] = {
BloodSugarLevelConverter: (
BloodGlugoseConcentrationConverter: (
UnitOfBloodGlucoseConcentration.MILLIGRAMS_PER_DECILITER,
UnitOfBloodGlucoseConcentration.MILLIMOLS_PER_LITER,
18,
Expand Down Expand Up @@ -138,7 +138,7 @@
_CONVERTED_VALUE: dict[
type[BaseUnitConverter], list[tuple[float, str | None, float, str | None]]
] = {
BloodSugarLevelConverter: [
BloodGlugoseConcentrationConverter: [
(
90,
UnitOfBloodGlucoseConcentration.MILLIGRAMS_PER_DECILITER,
Expand Down

0 comments on commit d70e93a

Please sign in to comment.