Home Assistant Unofficial Reference 2024.12.1
util.py
Go to the documentation of this file.
1 """Utils for CO2 signal."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Mapping
6 from typing import Any
7 
8 from homeassistant.const import CONF_COUNTRY_CODE, CONF_LATITUDE, CONF_LONGITUDE
9 
10 
11 def get_extra_name(config: Mapping[str, Any]) -> str | None:
12  """Return the extra name describing the location if not home."""
13  if CONF_COUNTRY_CODE in config:
14  return config[CONF_COUNTRY_CODE] # type: ignore[no-any-return]
15 
16  if CONF_LATITUDE in config:
17  return f"{round(config[CONF_LATITUDE], 2)}, {round(config[CONF_LONGITUDE], 2)}"
18 
19  return None
str|None get_extra_name(Mapping[str, Any] config)
Definition: util.py:11