Move co2signal models to their own file (#100478)

pull/98596/head
Jan-Philipp Benecke 2023-09-16 11:49:49 +02:00 committed by GitHub
parent 57337b5cee
commit b5c6e82374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 23 deletions

View File

@ -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)

View File

@ -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