mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Move co2signal models to their own file (#100478)
This commit is contained in:
parent
57337b5cee
commit
b5c6e82374
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, TypedDict, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import CO2Signal
|
import CO2Signal
|
||||||
|
|
||||||
@ -16,33 +16,12 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
|||||||
|
|
||||||
from .const import CONF_COUNTRY_CODE, DOMAIN
|
from .const import CONF_COUNTRY_CODE, DOMAIN
|
||||||
from .exceptions import APIRatelimitExceeded, CO2Error, InvalidAuth, UnknownError
|
from .exceptions import APIRatelimitExceeded, CO2Error, InvalidAuth, UnknownError
|
||||||
|
from .models import CO2SignalResponse
|
||||||
|
|
||||||
PLATFORMS = [Platform.SENSOR]
|
PLATFORMS = [Platform.SENSOR]
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_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:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up CO2 Signal from a config entry."""
|
"""Set up CO2 Signal from a config entry."""
|
||||||
coordinator = CO2SignalCoordinator(hass, entry)
|
coordinator = CO2SignalCoordinator(hass, entry)
|
||||||
|
24
homeassistant/components/co2signal/models.py
Normal file
24
homeassistant/components/co2signal/models.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user