From b5c6e8237471e9734ce4244986055035715c6cac Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Sat, 16 Sep 2023 11:49:49 +0200 Subject: [PATCH] Move co2signal models to their own file (#100478) --- .../components/co2signal/__init__.py | 25 ++----------------- homeassistant/components/co2signal/models.py | 24 ++++++++++++++++++ 2 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 homeassistant/components/co2signal/models.py diff --git a/homeassistant/components/co2signal/__init__.py b/homeassistant/components/co2signal/__init__.py index 943fa13e240..79c56ec63d4 100644 --- a/homeassistant/components/co2signal/__init__.py +++ b/homeassistant/components/co2signal/__init__.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Mapping from datetime import timedelta import logging -from typing import Any, TypedDict, cast +from typing import Any, cast import CO2Signal @@ -16,33 +16,12 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda from .const import CONF_COUNTRY_CODE, DOMAIN from .exceptions import APIRatelimitExceeded, CO2Error, InvalidAuth, UnknownError +from .models import CO2SignalResponse PLATFORMS = [Platform.SENSOR] _LOGGER = logging.getLogger(__name__) -class CO2SignalData(TypedDict): - """Data field.""" - - carbonIntensity: float - fossilFuelPercentage: float - - -class CO2SignalUnit(TypedDict): - """Unit field.""" - - carbonIntensity: str - - -class CO2SignalResponse(TypedDict): - """API response.""" - - status: str - countryCode: str - data: CO2SignalData - units: CO2SignalUnit - - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up CO2 Signal from a config entry.""" coordinator = CO2SignalCoordinator(hass, entry) diff --git a/homeassistant/components/co2signal/models.py b/homeassistant/components/co2signal/models.py new file mode 100644 index 00000000000..758bb15c5f0 --- /dev/null +++ b/homeassistant/components/co2signal/models.py @@ -0,0 +1,24 @@ +"""Models to the co2signal integration.""" +from typing import TypedDict + + +class CO2SignalData(TypedDict): + """Data field.""" + + carbonIntensity: float + fossilFuelPercentage: float + + +class CO2SignalUnit(TypedDict): + """Unit field.""" + + carbonIntensity: str + + +class CO2SignalResponse(TypedDict): + """API response.""" + + status: str + countryCode: str + data: CO2SignalData + units: CO2SignalUnit