How do I get "optional" settings in a schema to work with nested configuration?

I need to make a nested configuration in order to add configuration for an optional part of my hardware module .
Everything works as expected as long as I have the optional module enabled but without I get a configuration error:

 expected a dictionary for dictionary value @ data['ihc']['secondary']. Got None. (See /config/configuration.yaml, line 37)

The setup in configuration.yaml look like below. It fails when removing “secondary”:

ihc:
  url: http://...(primary controller)
  username: xyz
  password: secret_password
  secondary: 
    url: http://...(secondary linked controller)
    username:  zyx
    password: secret_password

The “secondary” setting must be optional (and a part of the primary module) and when enabled it must have additional settings (some required and some optional).

The schema is set with “secondary” as optional. It does however fail if I remove it in configuration.

IHC_SCHEMA = vol.Schema({
    vol.Required(CONF_URL): cv.string,
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
    vol.Optional(CONF_AUTOSETUP, default=True): cv.boolean,
    vol.Optional(CONF_INFO, default=True): cv.boolean,    
    vol.Optional('secondary', default=[]):
        vol.All({
            vol.Required(CONF_URL): cv.string,
            vol.Required(CONF_USERNAME): cv.string,
            vol.Required(CONF_PASSWORD): cv.string,
            vol.Optional(CONF_AUTOSETUP, default=True): cv.boolean,
            vol.Optional(CONF_INFO, default=True): cv.boolean,    
        })
}, extra=vol.ALLOW_EXTRA)    

“Optional” apparently doesn’t work as I expect it on nested configuration.
What have I missed?

Sigh… Must have been blind. :roll_eyes:
I forgot removing the default. Without it everything works as expected. :face_with_raised_eyebrow:

vol.Optional('secondary'):

Problem solved and closed