Add options flow to File (#120269)
* Add options flow to File * Review comments
This commit is contained in:
parent
e39bfeac08
commit
24a20c75eb
9 changed files with 307 additions and 38 deletions
|
@ -60,14 +60,15 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up the file sensor."""
|
||||
config = dict(entry.data)
|
||||
options = dict(entry.options)
|
||||
file_path: str = config[CONF_FILE_PATH]
|
||||
unique_id: str = entry.entry_id
|
||||
name: str = config.get(CONF_NAME, DEFAULT_NAME)
|
||||
unit: str | None = config.get(CONF_UNIT_OF_MEASUREMENT)
|
||||
unit: str | None = options.get(CONF_UNIT_OF_MEASUREMENT)
|
||||
value_template: Template | None = None
|
||||
|
||||
if CONF_VALUE_TEMPLATE in config:
|
||||
value_template = Template(config[CONF_VALUE_TEMPLATE], hass)
|
||||
if CONF_VALUE_TEMPLATE in options:
|
||||
value_template = Template(options[CONF_VALUE_TEMPLATE], hass)
|
||||
|
||||
async_add_entities(
|
||||
[FileSensor(unique_id, name, file_path, unit, value_template)], True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue