Get the metric or temperature system used in home-assistant

Hi all,

Is there a way to get the current metric system or temperature system configured in HA ?
I see this dcoumentation but there no informations on temperature system used : homeassistant.core — Home Assistant 2022.3.0.dev0 documentation

Thank’s in advance.

Here is an example


        self.is_metric: bool = None
        if self._hass.config.units is US_CUSTOMARY_SYSTEM:
            _LOGGER.info("Manager::init setting units to english - HASS Units [%s]", self._hass.config.units._name)
            self.is_metric = False
        else:
            _LOGGER.info("Manager::init setting units to metric - HASS Units [%s]", self._hass.config.units._name)
            self.is_metric = True

Thank you it does the trick !

Another way to use this is the following:

if self.hass.config.units.temperature_unit == UnitOfTemperature.CELSIUS

1 Like