Section in Schema not working

Hi,

I tried to collapse some input fields to get an better overview.
So far the collapsing itself is working but it doesn’t store/update any of the variables in the section.

        current_data = self.config_entry.data
        transport_types = DEFAULT_CONF_TRANSPORTTYPES.split(',')
        selected_transport_types = current_data.get(CONF_TRANSPORTTYPES, '').split(',')

        self.options_schema = vol.Schema({
            vol.Required(CONF_NAME, default=current_data.get(CONF_NAME)): str,
            vol.Required(CONF_GLOBALID, default=current_data.get(CONF_GLOBALID)): str,
            vol.Optional(CONF_TRANSPORTTYPES, default=selected_transport_types): selector({
                "select": {
                    "options": transport_types,
                    "multiple": True,
                    "custom_value": True
                }
            }),
            vol.Optional(CONF_LIMIT, default=current_data.get(CONF_LIMIT, DEFAULT_LIMIT)): int,
            vol.Optional(CONF_ONLYLINE,            description={"suggested_value": current_data.get(CONF_ONLYLINE, "")}): str,
            vol.Optional(CONF_HIDEDESTINATION,     description={"suggested_value": current_data.get(CONF_HIDEDESTINATION, "")}): str,
            vol.Optional(CONF_ONLYDESTINATION,     description={"suggested_value": current_data.get(CONF_ONLYDESTINATION, "")}): str,
            # Items can be grouped by collapsible sections
            "advanced_options": section(
                vol.Schema(
				    {
					    vol.Optional(CONF_HIDENAME,            description={"suggested_value": current_data.get(CONF_HIDENAME, "")}): bool,
                        vol.Optional(CONF_GLOBALID2,           description={"suggested_value": current_data.get(CONF_GLOBALID2, "")}): str,
                        vol.Optional(CONF_DOUBLESTATIONNUMBER, description={"suggested_value": current_data.get(CONF_DOUBLESTATIONNUMBER, "")}): str,
                        vol.Optional(CONF_TIMEZONE_FROM,       description={"suggested_value": current_data.get(CONF_TIMEZONE_FROM, "")}): str,
                        vol.Optional(CONF_TIMEZONE_TO,         description={"suggested_value": current_data.get(CONF_TIMEZONE_TO, "")}): str,
                        vol.Optional(CONF_ALERT_FOR,           description={"suggested_value": current_data.get(CONF_ALERT_FOR, "")}): str,
					}
                ),
                # Whether or not the section is initially collapsed (default = False)
                {"collapsed": True},
            )
        })

        return self.async_show_form(
            step_id="init",
            data_schema=self.options_schema
        )

I assume its only an optical section. Or does HA stores the variables in an advanced_options array or something like that ?

I only want to (optical) collapse some of the fields.

dosnt contain the needed information

I just noticed that also the current value like

vol.Optional(CONF_TIMEZONE_FROM,       description={"suggested_value": current_data.get(CONF_TIMEZONE_FROM, "")}): str,

is not shown in the form if I use sections.
Without sections everything is working fine.

Any ideas ?

EDIT:

even this

vol.Optional(CONF_TIMEZONE_FROM,       default="TEST"): str,

or this

vol.Optional(CONF_TIMEZONE_FROM,       description={"suggested_value": "TEST"}): str,

is not showing the value when inside a section

I too had a similar issue, it is storing the data but I could not get it to display on the options screen.

It appears the documentation is incorrect and you should do it like the solution in this issue:

EDIT: Also note that it stores the data in options under the section key.

Ie

"options": {
    "option1": "1",
    "advanced_settings": {
        "hide_name": true,
        "global_id2": 1234
    }
}

Thx for your answer. This was my issue.
I only forgot to post the solution here.

from homeassistant.helpers.selector import selector
from homeassistant import data_entry_flow
...
        self.options_schema = vol.Schema({
            vol.Required(CONF_NAME,           default=current_data.get(CONF_NAME)): str,
            vol.Required(CONF_GLOBALID,       default=current_data.get(CONF_GLOBALID)): str,
            vol.Optional(CONF_TRANSPORTTYPES, default=selected_transport_types): selector({
                "select": {
                    "options": transport_types,
                    "multiple": True,
                    "custom_value": True
                }
            }),
            vol.Optional(CONF_LIMIT,               default=current_data.get(CONF_LIMIT, DEFAULT_LIMIT)): int,
			# Filter
            vol.Required("filter_options"): data_entry_flow.section(
                vol.Schema(
				    {
                        vol.Optional(CONF_ONLYLINE,            description={"suggested_value": current_data.get(CONF_ONLYLINE, "")}): str,
                        vol.Optional(CONF_HIDEDESTINATION,     description={"suggested_value": current_data.get(CONF_HIDEDESTINATION, "")}): str,
                        vol.Optional(CONF_ONLYDESTINATION,     description={"suggested_value": current_data.get(CONF_ONLYDESTINATION, "")}): str,
					}
                ),
                # Whether or not the section is initially collapsed (default = False)
                {"collapsed": True},
            ),
            # Advanced Options
            vol.Required("advanced_options"): data_entry_flow.section(
                vol.Schema(
				    {
					    vol.Optional(CONF_HIDENAME,            description={"suggested_value": current_data.get(CONF_HIDENAME, "")}): bool,
                        vol.Optional(CONF_GLOBALID2,           description={"suggested_value": current_data.get(CONF_GLOBALID2, "")}): str,
                        vol.Optional(CONF_DOUBLESTATIONNUMBER, description={"suggested_value": current_data.get(CONF_DOUBLESTATIONNUMBER, "")}): str,
                        vol.Optional(CONF_TIMEZONE_FROM,       description={"suggested_value": current_data.get(CONF_TIMEZONE_FROM, "")}): str,
                        vol.Optional(CONF_TIMEZONE_TO,         description={"suggested_value": current_data.get(CONF_TIMEZONE_TO, "")}): str,
                        vol.Optional(CONF_ALERT_FOR,           description={"suggested_value": current_data.get(CONF_ALERT_FOR, "")}): str,
					}
                ),
                # Whether or not the section is initially collapsed (default = False)
                {"collapsed": True},
            )
        })