1
mirror of https://github.com/home-assistant/core synced 2024-10-07 10:13:38 +02:00
ha-core/homeassistant/components/co2signal/util.py
Paulus Schoutsen c49decb7f0
Convert CO2Signal to data update coordinator and add fossil fuel percentage (#53370)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Daniel Hjelseth Høyer <mail@dahoiv.net>
2021-07-23 14:35:11 -07:00

20 lines
538 B
Python

"""Utils for CO2 signal."""
from __future__ import annotations
from collections.abc import Mapping
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from .const import CONF_COUNTRY_CODE
def get_extra_name(config: Mapping) -> str | None:
"""Return the extra name describing the location if not home."""
if CONF_COUNTRY_CODE in config:
return config[CONF_COUNTRY_CODE]
if CONF_LATITUDE in config:
return f"{round(config[CONF_LATITUDE], 2)}, {round(config[CONF_LONGITUDE], 2)}"
return None