mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Add basic type hints to utility_meter (#69325)
Co-authored-by: Diogo Gomes <diogogomes@gmail.com>
This commit is contained in:
parent
28350b9792
commit
2cf3057ff1
@ -20,6 +20,7 @@ from homeassistant.helpers.entity import Entity
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_state_change_event
|
from homeassistant.helpers.event import async_track_state_change_event
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_TARIFF,
|
ATTR_TARIFF,
|
||||||
@ -50,8 +51,20 @@ async def async_setup_entry(
|
|||||||
async_add_entities([tariff_select])
|
async_add_entities([tariff_select])
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(hass, conf, async_add_entities, discovery_info=None):
|
async def async_setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
conf: ConfigType,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the utility meter select."""
|
"""Set up the utility meter select."""
|
||||||
|
if discovery_info is None:
|
||||||
|
_LOGGER.error(
|
||||||
|
"This platform is not available to configure "
|
||||||
|
"from 'select:' in configuration.yaml"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
legacy_component = hass.data[DATA_LEGACY_COMPONENT]
|
legacy_component = hass.data[DATA_LEGACY_COMPONENT]
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
|
@ -176,7 +176,10 @@ async def async_setup_platform(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the utility meter sensor."""
|
"""Set up the utility meter sensor."""
|
||||||
if discovery_info is None:
|
if discovery_info is None:
|
||||||
_LOGGER.error("This platform is only available through discovery")
|
_LOGGER.error(
|
||||||
|
"This platform is not available to configure "
|
||||||
|
"from 'sensor:' in configuration.yaml"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
meters = []
|
meters = []
|
||||||
|
@ -17,6 +17,7 @@ from homeassistant.components.utility_meter.const import (
|
|||||||
SERVICE_SELECT_TARIFF,
|
SERVICE_SELECT_TARIFF,
|
||||||
SIGNAL_RESET_METER,
|
SIGNAL_RESET_METER,
|
||||||
)
|
)
|
||||||
|
import homeassistant.components.utility_meter.select as um_select
|
||||||
import homeassistant.components.utility_meter.sensor as um_sensor
|
import homeassistant.components.utility_meter.sensor as um_sensor
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
@ -380,6 +381,7 @@ async def test_bad_cron(hass, legacy_patchable_time):
|
|||||||
|
|
||||||
async def test_setup_missing_discovery(hass):
|
async def test_setup_missing_discovery(hass):
|
||||||
"""Test setup with configuration missing discovery_info."""
|
"""Test setup with configuration missing discovery_info."""
|
||||||
|
assert not await um_select.async_setup_platform(hass, {CONF_PLATFORM: DOMAIN}, None)
|
||||||
assert not await um_sensor.async_setup_platform(hass, {CONF_PLATFORM: DOMAIN}, None)
|
assert not await um_sensor.async_setup_platform(hass, {CONF_PLATFORM: DOMAIN}, None)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user