Add config flow and MQTT autodiscover to dsmr_reader integration (#71617)
Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
f26fadbdfc
commit
7aa53feff4
13 changed files with 185 additions and 6 deletions
|
@ -3,15 +3,16 @@ from __future__ import annotations
|
|||
|
||||
from homeassistant.components import mqtt
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import slugify
|
||||
|
||||
from .const import DOMAIN
|
||||
from .definitions import SENSORS, DSMRReaderSensorEntityDescription
|
||||
|
||||
DOMAIN = "dsmr_reader"
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
|
@ -19,7 +20,31 @@ async def async_setup_platform(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up DSMR Reader sensors."""
|
||||
"""Set up DSMR Reader sensors via configuration.yaml and show deprecation warning."""
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"deprecated_yaml",
|
||||
breaks_in_ha_version="2022.12.0",
|
||||
is_fixable=False,
|
||||
severity=IssueSeverity.WARNING,
|
||||
translation_key="deprecated_yaml",
|
||||
)
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=config,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up DSMR Reader sensors from config entry."""
|
||||
async_add_entities(DSMRSensor(description) for description in SENSORS)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue