"""Provides the constants needed for the component."""

from enum import StrEnum
from typing import Final

import voluptuous as vol

from homeassistant.const import (
    DEGREE,
    LIGHT_LUX,
    SIGNAL_STRENGTH_DECIBELS,
    SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
    UnitOfApparentPower,
    UnitOfArea,
    UnitOfBloodGlucoseConcentration,
    UnitOfConductivity,
    UnitOfDataRate,
    UnitOfDensity,
    UnitOfElectricCurrent,
    UnitOfElectricPotential,
    UnitOfEnergy,
    UnitOfEnergyDistance,
    UnitOfFrequency,
    UnitOfInformation,
    UnitOfIrradiance,
    UnitOfLength,
    UnitOfMass,
    UnitOfPower,
    UnitOfPrecipitationDepth,
    UnitOfPressure,
    UnitOfRadiationConcentration,
    UnitOfRatio,
    UnitOfReactiveEnergy,
    UnitOfReactivePower,
    UnitOfSoundPressure,
    UnitOfSpeed,
    UnitOfTemperature,
    UnitOfTime,
    UnitOfVolume,
    UnitOfVolumeFlowRate,
    UnitOfVolumetricFlux,
)
from homeassistant.util.unit_conversion import (
    ApparentPowerConverter,
    AreaConverter,
    BaseUnitConverter,
    BloodGlucoseConcentrationConverter,
    CarbonMonoxideConcentrationConverter,
    ConductivityConverter,
    DataRateConverter,
    DistanceConverter,
    DurationConverter,
    ElectricCurrentConverter,
    ElectricPotentialConverter,
    EnergyConverter,
    EnergyDistanceConverter,
    FrequencyConverter,
    InformationConverter,
    MassConverter,
    MassVolumeConcentrationConverter,
    NitrogenDioxideConcentrationConverter,
    NitrogenMonoxideConcentrationConverter,
    OzoneConcentrationConverter,
    PowerConverter,
    PressureConverter,
    RadiationConcentrationConverter,
    ReactiveEnergyConverter,
    ReactivePowerConverter,
    SpeedConverter,
    SulphurDioxideConcentrationConverter,
    TemperatureConverter,
    TemperatureDeltaConverter,
    UnitlessRatioConverter,
    VolumeConverter,
    VolumeFlowRateConverter,
)

ATTR_VALUE = "value"
ATTR_MIN = "min"
ATTR_MAX = "max"
ATTR_STEP = "step"

DEFAULT_MIN_VALUE = 0.0
DEFAULT_MAX_VALUE = 100.0
DEFAULT_STEP = 1.0

DOMAIN = "number"

SERVICE_SET_VALUE = "set_value"


class NumberEntityCapabilityAttribute(StrEnum):
    """Capability attributes for number entities."""

    MIN = "min"
    MAX = "max"
    STEP = "step"
    MODE = "mode"


class NumberMode(StrEnum):
    """Modes for number entities."""

    AUTO = "auto"
    BOX = "box"
    SLIDER = "slider"


class NumberDeviceClass(StrEnum):
    """Device class for numbers."""

    # NumberDeviceClass should be aligned with SensorDeviceClass
    ABSOLUTE_HUMIDITY = "absolute_humidity"
    """Absolute humidity.

    Unit of measurement: `g/m³`, `mg/m³`
    """

    APPARENT_POWER = "apparent_power"
    """Apparent power.

    Unit of measurement: `mVA`, `VA`, `kVA`
    """

    AQI = "aqi"
    """Air Quality Index.

    Unit of measurement: `None`
    """

    AREA = "area"
    """Area

    Unit of measurement: `UnitOfArea` units
    """

    ATMOSPHERIC_PRESSURE = "atmospheric_pressure"
    """Atmospheric pressure.

    Unit of measurement: `UnitOfPressure` units
    """

    BATTERY = "battery"
    """Percentage of battery that is left.

    Unit of measurement: `%`
    """

    BLOOD_GLUCOSE_CONCENTRATION = "blood_glucose_concentration"
    """Blood glucose concentration.

    Unit of measurement: `mg/dL`, `mmol/L`
    """

    CO = "carbon_monoxide"
    """Carbon Monoxide gas concentration.

    Unit of measurement: `ppb` (parts per billion),
    `ppm` (parts per million), `mg/m³`, `μg/m³`
    """

    CO2 = "carbon_dioxide"
    """Carbon Dioxide gas concentration.

    Unit of measurement: `ppm` (parts per million)
    """

    CONDUCTIVITY = "conductivity"
    """Conductivity.

    Unit of measurement: `S/cm`, `mS/cm`, `μS/cm`
    """

    CURRENT = "current"
    """Current.

    Unit of measurement: `A`,  `mA`, `μA`
    """

    DATA_RATE = "data_rate"
    """Data rate.

    Unit of measurement: UnitOfDataRate
    """

    DATA_SIZE = "data_size"
    """Data size.

    Unit of measurement: UnitOfInformation
    """

    DISTANCE = "distance"
    """Generic distance.

    Unit of measurement: `LENGTH_*` units
    - SI /metric: `mm`, `cm`, `m`, `km`
    - USCS / imperial: `in`, `ft`, `yd`, `mi`
    """

    DURATION = "duration"
    """Fixed duration.

    Unit of measurement: `d`, `h`, `min`, `s`, `ms`, `μs`
    """

    ENERGY = "energy"
    """Energy.

    Unit of measurement: `J`, `kJ`, `MJ`, `GJ`, `mWh`,
    `Wh`, `kWh`, `MWh`, `GWh`, `TWh`, `cal`, `kcal`,
    `Mcal`, `Gcal`
    """

    ENERGY_DISTANCE = "energy_distance"
    """Energy distance.

    Use this device class for sensors measuring energy by
    distance, for example the amount of electric energy
    consumed by an electric car.

    Unit of measurement: `kWh/100km`, `Wh/km`, `mi/kWh`, `km/kWh`
    """

    ENERGY_STORAGE = "energy_storage"
    """Stored energy.

    Use this device class for sensors measuring stored
    energy, for example the amount of electric energy
    currently stored in a battery or the capacity of a
    battery.

    Unit of measurement: `J`, `kJ`, `MJ`, `GJ`, `mWh`,
    `Wh`, `kWh`, `MWh`, `GWh`, `TWh`, `cal`, `kcal`,
    `Mcal`, `Gcal`
    """

    FREQUENCY = "frequency"
    """Frequency.

    Unit of measurement: `mHz`, `Hz`, `kHz`, `MHz`, `GHz`
    """

    GAS = "gas"
    """Gas.

    Unit of measurement:
    - SI / metric: `L`, `m³`
    - USCS / imperial: `ft³`, `CCF`, `MCF`
    """

    HUMIDITY = "humidity"
    """Relative humidity.

    Unit of measurement: `%`
    """

    ILLUMINANCE = "illuminance"
    """Illuminance.

    Unit of measurement: `lx`
    """

    IRRADIANCE = "irradiance"
    """Irradiance.

    Unit of measurement:
    - SI / metric: `W/m²`
    - USCS / imperial: `BTU/(h⋅ft²)`
    """

    MOISTURE = "moisture"
    """Moisture.

    Unit of measurement: `%`
    """

    MONETARY = "monetary"
    """Amount of money.

    Unit of measurement: ISO4217 currency code

    See https://en.wikipedia.org/wiki/ISO_4217#Active_codes for active codes
    """

    NITROGEN_DIOXIDE = "nitrogen_dioxide"
    """Amount of NO2.

    Unit of measurement: `ppb` (parts per billion), `ppm` (parts per million), `μg/m³`
    """

    NITROGEN_MONOXIDE = "nitrogen_monoxide"
    """Amount of NO.

    Unit of measurement: `ppb` (parts per billion), `μg/m³`
    """

    NITROUS_OXIDE = "nitrous_oxide"
    """Amount of N2O.

    Unit of measurement: `μg/m³`
    """

    OZONE = "ozone"
    """Amount of O3.

    Unit of measurement: `ppb` (parts per billion), `ppm` (parts per million), `μg/m³`
    """

    PH = "ph"
    """Potential hydrogen (acidity/alkalinity).

    Unit of measurement: Unitless
    """

    PM1 = "pm1"
    """Particulate matter <= 1 μm.

    Unit of measurement: `μg/m³`
    """

    PM10 = "pm10"
    """Particulate matter <= 10 μm.

    Unit of measurement: `μg/m³`
    """

    PM25 = "pm25"
    """Particulate matter <= 2.5 μm.

    Unit of measurement: `μg/m³`
    """

    PM4 = "pm4"
    """Particulate matter <= 4 μm.

    Unit of measurement: `μg/m³`
    """

    POWER_FACTOR = "power_factor"
    """Power factor.

    Unit of measurement: `%`, `None`
    """

    POWER = "power"
    """Power.

    Unit of measurement: `mW`, `W`, `kW`, `MW`, `GW`, `TW`, `BTU/h`
    """

    PRECIPITATION = "precipitation"
    """Accumulated precipitation.

    Unit of measurement: UnitOfPrecipitationDepth
    - SI / metric: `cm`, `mm`
    - USCS / imperial: `in`
    """

    PRECIPITATION_INTENSITY = "precipitation_intensity"
    """Precipitation intensity.

    Unit of measurement: UnitOfVolumetricFlux
    - SI /metric: `mm/d`, `mm/h`
    - USCS / imperial: `in/d`, `in/h`
    """

    PRESSURE = "pressure"
    """Pressure.

    Unit of measurement:
    - `mbar`, `cbar`, `bar`
    - `mPa`, `Pa`, `hPa`, `kPa`
    - `inHg`
    - `psi`
    - `inH₂O`
    """

    RADON = "radon"
    """Radon.

    Unit of measurement: UnitOfRadiationConcentration
    - SI / metric: `Bq/m³`
    - USCS / imperial: `pCi/L`
    """

    REACTIVE_ENERGY = "reactive_energy"
    """Reactive energy.

    Unit of measurement: `varh`, `kvarh`
    """

    REACTIVE_POWER = "reactive_power"
    """Reactive power.

    Unit of measurement: `mvar`, `var`, `kvar`
    """

    SIGNAL_STRENGTH = "signal_strength"
    """Signal strength.

    Unit of measurement: `dB`, `dBm`
    """

    SOUND_PRESSURE = "sound_pressure"
    """Sound pressure.

    Unit of measurement: `dB`, `dBA`
    """

    SPEED = "speed"
    """Generic speed.

    Unit of measurement: `SPEED_*` units or `UnitOfVolumetricFlux`
    - SI /metric: `mm/d`, `mm/h`, `m/s`, `km/h`
    - USCS / imperial: `in/d`, `in/h`, `ft/s`, `mph`
    - Nautical: `kn`
    """

    SULPHUR_DIOXIDE = "sulphur_dioxide"
    """Amount of SO2.

    Unit of measurement: `ppb` (parts per billion), `μg/m³`
    """

    TEMPERATURE = "temperature"
    """Temperature.

    Unit of measurement: `°C`, `°F`, `K`
    """

    TEMPERATURE_DELTA = "temperature_delta"
    """Difference of temperatures - Temperature range.

    Unit of measurement: `°C`, `°F`, `K`
    """

    VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
    """Amount of VOC.

    Unit of measurement: `μg/m³`, `mg/m³`
    """

    VOLATILE_ORGANIC_COMPOUNDS_PARTS = "volatile_organic_compounds_parts"
    """Ratio of VOC.

    Unit of measurement: `ppm`, `ppb`
    """

    VOLTAGE = "voltage"
    """Voltage.

    Unit of measurement: `V`, `mV`, `μV`, `kV`, `MV`
    """

    VOLUME = "volume"
    """Generic volume.

    Unit of measurement: `VOLUME_*` units
    - SI / metric: `mL`, `L`, `m³`
    - USCS / imperial: `ft³`, `CCF`, `MCF`, `fl. oz.`,
    `gal` (warning: volumes expressed in USCS/imperial
    units are currently assumed to be US volumes)
    """

    VOLUME_STORAGE = "volume_storage"
    """Generic stored volume.

    Use this device class for sensors measuring stored
    volume, for example the amount of fuel in a fuel tank.

    Unit of measurement: `VOLUME_*` units
    - SI / metric: `mL`, `L`, `m³`
    - USCS / imperial: `ft³`, `CCF`, `MCF`, `fl. oz.`,
    `gal` (warning: volumes expressed in USCS/imperial
    units are currently assumed to be US volumes)
    """

    VOLUME_FLOW_RATE = "volume_flow_rate"
    """Generic flow rate

    Unit of measurement: UnitOfVolumeFlowRate
    - SI / metric: `m³/h`, `m³/min`, `m³/s`, `L/h`, `L/min`, `L/s`, `mL/s`
    - USCS / imperial: `ft³/min`, `gal/min`, `gal/d`
    """

    WATER = "water"
    """Water.

    Unit of measurement:
    - SI / metric: `m³`, `L`
    - USCS / imperial: `ft³`, `CCF`, `MCF`, `gal` (warning: volumes expressed in
    USCS/imperial units are currently assumed to be US volumes)
    """

    WEIGHT = "weight"
    """Generic weight, represents a measurement of an object's mass.

    Weight is used instead of mass to fit with every day language.

    Unit of measurement: `MASS_*` units
    - SI / metric: `μg`, `mg`, `g`, `kg`
    - USCS / imperial: `oz`, `lb`
    """

    WIND_DIRECTION = "wind_direction"
    """Wind direction.

    Unit of measurement: `°`
    """

    WIND_SPEED = "wind_speed"
    """Wind speed.

    Unit of measurement: `SPEED_*` units
    - SI /metric: `m/s`, `km/h`
    - USCS / imperial: `ft/s`, `mph`
    - Nautical: `kn`
    """


DEVICE_CLASSES_SCHEMA: Final = vol.All(vol.Lower, vol.Coerce(NumberDeviceClass))
DEVICE_CLASS_UNITS: dict[NumberDeviceClass, set[type[StrEnum] | str | None]] = {
    NumberDeviceClass.ABSOLUTE_HUMIDITY: {
        UnitOfDensity.GRAMS_PER_CUBIC_METER,
        UnitOfDensity.MILLIGRAMS_PER_CUBIC_METER,
    },
    NumberDeviceClass.APPARENT_POWER: set(UnitOfApparentPower),
    NumberDeviceClass.AQI: {None},
    NumberDeviceClass.AREA: set(UnitOfArea),
    NumberDeviceClass.ATMOSPHERIC_PRESSURE: set(UnitOfPressure),
    NumberDeviceClass.BATTERY: {UnitOfRatio.PERCENTAGE},
    NumberDeviceClass.BLOOD_GLUCOSE_CONCENTRATION: set(UnitOfBloodGlucoseConcentration),
    NumberDeviceClass.CO: {
        UnitOfRatio.PARTS_PER_BILLION,
        UnitOfRatio.PARTS_PER_MILLION,
        UnitOfDensity.MILLIGRAMS_PER_CUBIC_METER,
        UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
    },
    NumberDeviceClass.CO2: {UnitOfRatio.PARTS_PER_MILLION},
    NumberDeviceClass.CONDUCTIVITY: set(UnitOfConductivity),
    NumberDeviceClass.CURRENT: set(UnitOfElectricCurrent),
    NumberDeviceClass.DATA_RATE: set(UnitOfDataRate),
    NumberDeviceClass.DATA_SIZE: set(UnitOfInformation),
    NumberDeviceClass.DISTANCE: set(UnitOfLength),
    NumberDeviceClass.DURATION: {
        UnitOfTime.DAYS,
        UnitOfTime.HOURS,
        UnitOfTime.MINUTES,
        UnitOfTime.SECONDS,
        UnitOfTime.MILLISECONDS,
        UnitOfTime.MICROSECONDS,
    },
    NumberDeviceClass.ENERGY: set(UnitOfEnergy),
    NumberDeviceClass.ENERGY_DISTANCE: set(UnitOfEnergyDistance),
    NumberDeviceClass.ENERGY_STORAGE: set(UnitOfEnergy),
    NumberDeviceClass.FREQUENCY: set(UnitOfFrequency),
    NumberDeviceClass.GAS: {
        UnitOfVolume.CENTUM_CUBIC_FEET,
        UnitOfVolume.CUBIC_FEET,
        UnitOfVolume.CUBIC_METERS,
        UnitOfVolume.LITERS,
        UnitOfVolume.MILLE_CUBIC_FEET,
    },
    NumberDeviceClass.HUMIDITY: {UnitOfRatio.PERCENTAGE},
    NumberDeviceClass.ILLUMINANCE: {LIGHT_LUX},
    NumberDeviceClass.IRRADIANCE: set(UnitOfIrradiance),
    NumberDeviceClass.MOISTURE: {UnitOfRatio.PERCENTAGE},
    NumberDeviceClass.NITROGEN_DIOXIDE: {
        UnitOfRatio.PARTS_PER_BILLION,
        UnitOfRatio.PARTS_PER_MILLION,
        UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
    },
    NumberDeviceClass.NITROGEN_MONOXIDE: {
        UnitOfRatio.PARTS_PER_BILLION,
        UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
    },
    NumberDeviceClass.NITROUS_OXIDE: {UnitOfDensity.MICROGRAMS_PER_CUBIC_METER},
    NumberDeviceClass.OZONE: {
        UnitOfRatio.PARTS_PER_BILLION,
        UnitOfRatio.PARTS_PER_MILLION,
        UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
    },
    NumberDeviceClass.PH: {None},
    NumberDeviceClass.PM1: {UnitOfDensity.MICROGRAMS_PER_CUBIC_METER},
    NumberDeviceClass.PM10: {UnitOfDensity.MICROGRAMS_PER_CUBIC_METER},
    NumberDeviceClass.PM25: {UnitOfDensity.MICROGRAMS_PER_CUBIC_METER},
    NumberDeviceClass.PM4: {UnitOfDensity.MICROGRAMS_PER_CUBIC_METER},
    NumberDeviceClass.POWER_FACTOR: {UnitOfRatio.PERCENTAGE, None},
    NumberDeviceClass.POWER: {
        UnitOfPower.MILLIWATT,
        UnitOfPower.WATT,
        UnitOfPower.KILO_WATT,
        UnitOfPower.MEGA_WATT,
        UnitOfPower.GIGA_WATT,
        UnitOfPower.TERA_WATT,
    },
    NumberDeviceClass.PRECIPITATION: set(UnitOfPrecipitationDepth),
    NumberDeviceClass.PRECIPITATION_INTENSITY: set(UnitOfVolumetricFlux),
    NumberDeviceClass.PRESSURE: set(UnitOfPressure),
    NumberDeviceClass.RADON: set(UnitOfRadiationConcentration),
    NumberDeviceClass.REACTIVE_ENERGY: set(UnitOfReactiveEnergy),
    NumberDeviceClass.REACTIVE_POWER: set(UnitOfReactivePower),
    NumberDeviceClass.SIGNAL_STRENGTH: {
        SIGNAL_STRENGTH_DECIBELS,
        SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
    },
    NumberDeviceClass.SOUND_PRESSURE: set(UnitOfSoundPressure),
    NumberDeviceClass.SPEED: {*UnitOfSpeed, *UnitOfVolumetricFlux},
    NumberDeviceClass.SULPHUR_DIOXIDE: {
        UnitOfRatio.PARTS_PER_BILLION,
        UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
    },
    NumberDeviceClass.TEMPERATURE: set(UnitOfTemperature),
    NumberDeviceClass.TEMPERATURE_DELTA: set(UnitOfTemperature),
    NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {
        UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
        UnitOfDensity.MILLIGRAMS_PER_CUBIC_METER,
    },
    NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS: {
        UnitOfRatio.PARTS_PER_BILLION,
        UnitOfRatio.PARTS_PER_MILLION,
    },
    NumberDeviceClass.VOLTAGE: set(UnitOfElectricPotential),
    NumberDeviceClass.VOLUME: set(UnitOfVolume),
    NumberDeviceClass.VOLUME_STORAGE: set(UnitOfVolume),
    NumberDeviceClass.VOLUME_FLOW_RATE: set(UnitOfVolumeFlowRate),
    NumberDeviceClass.WATER: {
        UnitOfVolume.CENTUM_CUBIC_FEET,
        UnitOfVolume.CUBIC_FEET,
        UnitOfVolume.CUBIC_METERS,
        UnitOfVolume.GALLONS,
        UnitOfVolume.LITERS,
        UnitOfVolume.MILLE_CUBIC_FEET,
    },
    NumberDeviceClass.WEIGHT: set(UnitOfMass),
    NumberDeviceClass.WIND_DIRECTION: {DEGREE},
    NumberDeviceClass.WIND_SPEED: set(UnitOfSpeed),
}

UNIT_CONVERTERS: dict[NumberDeviceClass, type[BaseUnitConverter]] = {
    NumberDeviceClass.APPARENT_POWER: ApparentPowerConverter,
    NumberDeviceClass.ABSOLUTE_HUMIDITY: MassVolumeConcentrationConverter,
    NumberDeviceClass.AREA: AreaConverter,
    NumberDeviceClass.ATMOSPHERIC_PRESSURE: PressureConverter,
    NumberDeviceClass.BLOOD_GLUCOSE_CONCENTRATION: BloodGlucoseConcentrationConverter,
    NumberDeviceClass.CO: CarbonMonoxideConcentrationConverter,
    NumberDeviceClass.CONDUCTIVITY: ConductivityConverter,
    NumberDeviceClass.CURRENT: ElectricCurrentConverter,
    NumberDeviceClass.DATA_RATE: DataRateConverter,
    NumberDeviceClass.DATA_SIZE: InformationConverter,
    NumberDeviceClass.DISTANCE: DistanceConverter,
    NumberDeviceClass.DURATION: DurationConverter,
    NumberDeviceClass.ENERGY: EnergyConverter,
    NumberDeviceClass.ENERGY_DISTANCE: EnergyDistanceConverter,
    NumberDeviceClass.ENERGY_STORAGE: EnergyConverter,
    NumberDeviceClass.FREQUENCY: FrequencyConverter,
    NumberDeviceClass.GAS: VolumeConverter,
    NumberDeviceClass.NITROGEN_DIOXIDE: NitrogenDioxideConcentrationConverter,
    NumberDeviceClass.NITROGEN_MONOXIDE: NitrogenMonoxideConcentrationConverter,
    NumberDeviceClass.OZONE: OzoneConcentrationConverter,
    NumberDeviceClass.POWER: PowerConverter,
    NumberDeviceClass.POWER_FACTOR: UnitlessRatioConverter,
    NumberDeviceClass.PRECIPITATION: DistanceConverter,
    NumberDeviceClass.PRECIPITATION_INTENSITY: SpeedConverter,
    NumberDeviceClass.PRESSURE: PressureConverter,
    NumberDeviceClass.RADON: RadiationConcentrationConverter,
    NumberDeviceClass.REACTIVE_ENERGY: ReactiveEnergyConverter,
    NumberDeviceClass.REACTIVE_POWER: ReactivePowerConverter,
    NumberDeviceClass.SULPHUR_DIOXIDE: SulphurDioxideConcentrationConverter,
    NumberDeviceClass.SPEED: SpeedConverter,
    NumberDeviceClass.TEMPERATURE: TemperatureConverter,
    NumberDeviceClass.TEMPERATURE_DELTA: TemperatureDeltaConverter,
    NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: MassVolumeConcentrationConverter,
    NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS: UnitlessRatioConverter,
    NumberDeviceClass.VOLTAGE: ElectricPotentialConverter,
    NumberDeviceClass.VOLUME: VolumeConverter,
    NumberDeviceClass.VOLUME_STORAGE: VolumeConverter,
    NumberDeviceClass.VOLUME_FLOW_RATE: VolumeFlowRateConverter,
    NumberDeviceClass.WATER: VolumeConverter,
    NumberDeviceClass.WEIGHT: MassConverter,
    NumberDeviceClass.WIND_SPEED: SpeedConverter,
}

# We translate units that were using using the legacy coding of μ \u00b5
# to units using recommended coding of μ \u03bc and
# we convert alternative accepted units to the preferred unit.
AMBIGUOUS_UNITS: dict[str | None, str] = {
    "\u00b5Sv/h": "μSv/h",  # aranet: radiation rate
    "\u00b5S/cm": UnitOfConductivity.MICROSIEMENS_PER_CM,
    "\u00b5V": UnitOfElectricPotential.MICROVOLT,
    "\u00b5g/ft³": UnitOfDensity.MICROGRAMS_PER_CUBIC_FOOT,
    "\u00b5g/m³": UnitOfDensity.MICROGRAMS_PER_CUBIC_METER,
    "\u00b5mol/s⋅m²": "μmol/s⋅m²",  # fyta: light
    "\u00b5g": UnitOfMass.MICROGRAMS,
    "\u00b5s": UnitOfTime.MICROSECONDS,
    "mVAr": UnitOfReactivePower.MILLIVOLT_AMPERE_REACTIVE,
    "VAr": UnitOfReactivePower.VOLT_AMPERE_REACTIVE,
    "kVAr": UnitOfReactivePower.KILO_VOLT_AMPERE_REACTIVE,
    "VArh": UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR,
    "kVArh": UnitOfReactiveEnergy.KILO_VOLT_AMPERE_REACTIVE_HOUR,
}
