strings and options

This commit is contained in:
G Johansson 2025-07-07 20:30:10 +00:00
parent 611b72dc65
commit ec8ca241c8
3 changed files with 30 additions and 79 deletions

View File

@ -106,7 +106,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ScrapeConfigEntry) -> bool:
"""Set up Scrape from a config entry."""
config: dict[str, Any] = dict(entry.data)
config: dict[str, Any] = dict(entry.options)
config.update(config.pop("advanced", {}))
config.update(config.pop("auth", {}))
@ -178,7 +178,7 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ScrapeConfigEntry) ->
new_config_entry_data.pop(SENSOR_DOMAIN)
hass.config_entries.async_update_entry(
entry, version=2, data=new_config_entry_data, options={}
entry, version=2, options=new_config_entry_data
)
return True

View File

@ -227,7 +227,7 @@ class ScrapeConfigFlow(ConfigFlow, domain=DOMAIN):
errors = await validate_rest_setup(self.hass, user_input)
title = user_input[CONF_RESOURCE]
if not errors:
return self.async_create_entry(data=user_input, title=title)
return self.async_create_entry(data={}, options=user_input, title=title)
return self.async_show_form(
step_id="user", data_schema=RESOURCE_SETUP, errors=errors

View File

@ -29,28 +29,33 @@
"encoding": "Character encoding to use. Defaults to UTF-8.",
"payload": "Payload to use when method is POST."
}
},
"sensor": {
"data": {
"name": "[%key:common::config_flow::data::name%]",
"attribute": "Attribute",
"index": "Index",
"select": "Select",
"value_template": "Value template",
"availability": "Availability template",
"device_class": "Device class",
"state_class": "State class",
"unit_of_measurement": "Unit of measurement"
},
"data_description": {
"select": "Defines what tag to search for. Check Beautifulsoup CSS selectors for details.",
"attribute": "Get value of an attribute on the selected tag.",
"index": "Defines which of the elements returned by the CSS selector to use.",
"value_template": "Defines a template to get the state of the sensor.",
"availability": "Defines a template to get the availability of the sensor.",
"device_class": "The type/class of the sensor to set the icon in the frontend.",
"state_class": "The state_class of the sensor.",
"unit_of_measurement": "Choose unit of measurement or create your own."
}
}
},
"config_subentries": {
"entity": {
"step": {
"user": {
"data": {
"attribute": "Attribute",
"index": "Index",
"select": "Select",
"value_template": "Value template",
"availability": "Availability template",
"device_class": "Device class",
"state_class": "State class",
"unit_of_measurement": "Unit of measurement"
},
"data_description": {
"select": "Defines what tag to search for. Check Beautifulsoup CSS selectors for details.",
"attribute": "Get value of an attribute on the selected tag.",
"index": "Defines which of the elements returned by the CSS selector to use.",
"value_template": "Defines a template to get the state of the sensor.",
"availability": "Defines a template to get the availability of the sensor.",
"device_class": "The type/class of the sensor to set the icon in the frontend.",
"state_class": "The state_class of the sensor.",
"unit_of_measurement": "Choose unit of measurement or create your own."
}
}
}
}
@ -58,60 +63,6 @@
"options": {
"step": {
"init": {
"menu_options": {
"add_sensor": "Add sensor",
"select_edit_sensor": "Configure sensor",
"remove_sensor": "Remove sensor",
"resource": "Configure resource"
}
},
"add_sensor": {
"data": {
"name": "[%key:common::config_flow::data::name%]",
"attribute": "[%key:component::scrape::config::step::sensor::data::attribute%]",
"index": "[%key:component::scrape::config::step::sensor::data::index%]",
"select": "[%key:component::scrape::config::step::sensor::data::select%]",
"value_template": "[%key:component::scrape::config::step::sensor::data::value_template%]",
"availability": "[%key:component::scrape::config::step::sensor::data::availability%]",
"device_class": "[%key:component::scrape::config::step::sensor::data::device_class%]",
"state_class": "[%key:component::scrape::config::step::sensor::data::state_class%]",
"unit_of_measurement": "[%key:component::scrape::config::step::sensor::data::unit_of_measurement%]"
},
"data_description": {
"select": "[%key:component::scrape::config::step::sensor::data_description::select%]",
"attribute": "[%key:component::scrape::config::step::sensor::data_description::attribute%]",
"index": "[%key:component::scrape::config::step::sensor::data_description::index%]",
"value_template": "[%key:component::scrape::config::step::sensor::data_description::value_template%]",
"availability": "[%key:component::scrape::config::step::sensor::data_description::availability%]",
"device_class": "[%key:component::scrape::config::step::sensor::data_description::device_class%]",
"state_class": "[%key:component::scrape::config::step::sensor::data_description::state_class%]",
"unit_of_measurement": "[%key:component::scrape::config::step::sensor::data_description::unit_of_measurement%]"
}
},
"edit_sensor": {
"data": {
"name": "[%key:common::config_flow::data::name%]",
"attribute": "[%key:component::scrape::config::step::sensor::data::attribute%]",
"index": "[%key:component::scrape::config::step::sensor::data::index%]",
"select": "[%key:component::scrape::config::step::sensor::data::select%]",
"value_template": "[%key:component::scrape::config::step::sensor::data::value_template%]",
"availability": "[%key:component::scrape::config::step::sensor::data::availability%]",
"device_class": "[%key:component::scrape::config::step::sensor::data::device_class%]",
"state_class": "[%key:component::scrape::config::step::sensor::data::state_class%]",
"unit_of_measurement": "[%key:component::scrape::config::step::sensor::data::unit_of_measurement%]"
},
"data_description": {
"select": "[%key:component::scrape::config::step::sensor::data_description::select%]",
"attribute": "[%key:component::scrape::config::step::sensor::data_description::attribute%]",
"index": "[%key:component::scrape::config::step::sensor::data_description::index%]",
"value_template": "[%key:component::scrape::config::step::sensor::data_description::value_template%]",
"availability": "[%key:component::scrape::config::step::sensor::data_description::availability%]",
"device_class": "[%key:component::scrape::config::step::sensor::data_description::device_class%]",
"state_class": "[%key:component::scrape::config::step::sensor::data_description::state_class%]",
"unit_of_measurement": "[%key:component::scrape::config::step::sensor::data_description::unit_of_measurement%]"
}
},
"resource": {
"data": {
"resource": "[%key:component::scrape::config::step::user::data::resource%]",
"method": "[%key:component::scrape::config::step::user::data::method%]",