Fix file yaml import fails on scan_interval (#120154)

This commit is contained in:
Jan Bouwhuis 2024-06-22 12:28:41 +02:00 committed by GitHub
parent f676760ab1
commit 57eb8dab6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

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

View file

@ -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"),
} }