Fix file yaml import fails on scan_interval (#120154)
This commit is contained in:
parent
f676760ab1
commit
57eb8dab6a
2 changed files with 10 additions and 1 deletions
|
@ -2,7 +2,13 @@
|
||||||
|
|
||||||
from homeassistant.components.notify import migrate_notify_issue
|
from homeassistant.components.notify import migrate_notify_issue
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import CONF_FILE_PATH, CONF_NAME, CONF_PLATFORM, Platform
|
from homeassistant.const import (
|
||||||
|
CONF_FILE_PATH,
|
||||||
|
CONF_NAME,
|
||||||
|
CONF_PLATFORM,
|
||||||
|
CONF_SCAN_INTERVAL,
|
||||||
|
Platform,
|
||||||
|
)
|
||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
|
@ -63,6 +69,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
if item[CONF_PLATFORM] == DOMAIN:
|
if item[CONF_PLATFORM] == DOMAIN:
|
||||||
file_config_item = IMPORT_SCHEMA[domain](item)
|
file_config_item = IMPORT_SCHEMA[domain](item)
|
||||||
file_config_item[CONF_PLATFORM] = domain
|
file_config_item[CONF_PLATFORM] = domain
|
||||||
|
if CONF_SCAN_INTERVAL in file_config_item:
|
||||||
|
del file_config_item[CONF_SCAN_INTERVAL]
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
|
|
@ -21,6 +21,7 @@ async def test_file_value_yaml_setup(
|
||||||
config = {
|
config = {
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"platform": "file",
|
"platform": "file",
|
||||||
|
"scan_interval": 30,
|
||||||
"name": "file1",
|
"name": "file1",
|
||||||
"file_path": get_fixture_path("file_value.txt", "file"),
|
"file_path": get_fixture_path("file_value.txt", "file"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue