1 """The file component."""
3 from copy
import deepcopy
11 from .const
import DOMAIN
13 PLATFORMS = [Platform.NOTIFY, Platform.SENSOR]
17 """Set up a file component entry."""
18 config = {**entry.data, **entry.options}
19 filepath: str = config[CONF_FILE_PATH]
20 if filepath
and not await hass.async_add_executor_job(
21 hass.config.is_allowed_path, filepath
24 translation_domain=DOMAIN,
25 translation_key=
"dir_not_allowed",
26 translation_placeholders={
"filename": filepath},
29 await hass.config_entries.async_forward_entry_setups(
30 entry, [
Platform(entry.data[CONF_PLATFORM])]
32 entry.async_on_unload(entry.add_update_listener(update_listener))
38 """Unload a config entry."""
39 return await hass.config_entries.async_unload_platforms(
40 entry, [entry.data[CONF_PLATFORM]]
45 """Handle options update."""
46 await hass.config_entries.async_reload(entry.entry_id)
50 """Migrate config entry."""
51 if config_entry.version > 2:
55 if config_entry.version < 2:
57 data: dict[str, Any] = deepcopy(
dict(config_entry.data))
59 for key, value
in config_entry.data.items():
60 if key
not in (CONF_FILE_PATH, CONF_PLATFORM, CONF_NAME):
64 hass.config_entries.async_update_entry(
65 config_entry, version=2, data=data, options=options
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_migrate_entry(HomeAssistant hass, ConfigEntry config_entry)
None update_listener(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)