The system cannot restart because the configuration is not valid - config schema definition

Hi i’m developing integrations and run into the problem that cannot fix. In my config file I have:

foxess:
   - username: joe
     password: secret123
     deviceID: 32f1bbc87
   - name: FoxESS-2
     username: stefan-batory
     password: password^password
     deviceID: 55560e929

Config schema definition in the code looks like this:


FOXESS_SCHEMA =  vol.Schema(
    {
        vol.Optional(CONF_NAME,default=DEFAULT_NAME): cv.string,
        vol.Required(CONF_USERNAME): cv.string,
        vol.Required(CONF_PASSWORD): cv.string,
        vol.Required(CONF_DEVICEID): cv.string
    }
)

CONFIG_SCHEMA = vol.Schema(
    {DOMAIN: vol.All( cv.ensure_list,[FOXESS_SCHEMA])}, 
    extra=vol.ALLOW_EXTRA
)

The integration is staring and running properly but when I try to restart HA from UI I receive:

2022-05-27 20:50:57 ERROR (MainThread) [homeassistant.components.homeassistant] The system cannot restart because the configuration is not valid: Invalid config for [foxess]: [username] is an invalid option for [foxess]. Check: foxess->username. (See ?, line ?).
2022-05-27 20:50:57 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [3833414896] The system cannot restart because the configuration is not valid: Invalid config for [foxess]: [username] is an invalid option for [foxess]. Check: foxess->username. (See ?, line ?).
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 189, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1627, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1664, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 747, in admin_handler
    await result
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/__init__.py", line 173, in async_handle_core_service
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Invalid config for [foxess]: [username] is an invalid option for [foxess]. Check: foxess->username. (See ?, line ?).

What I’m doing wrong ?

  • Did you change the code and alter the config before restarting? The new code will only be used after the restart.
  • Do you import CONF_USERNAME from homeassistant.const ?

Did you change the code and alter the config before restarting? The new code will only be used after the restart.

No

Do you import CONF_USERNAME from homeassistant.const ?

Yes, I tried to change it to my constans but it didn’t help :frowning:

Anyone else has any idea what i could do wrong?

Show the complete code (github maybe, or pastebin).
At first it looks like CONF_USERNAME is not set to “username”.

1 Like

https://github.com/macxq/foxess-ha/blob/a2edc5b961750310fb56f2a7b061b01ad1e4abb4/custom_components/foxess/init.py

Tried to import the custom component from GitHub - macxq/foxess-ha at 19-feature-request-battery-storage-charging-management into my HA dev container but the integration is not loading: 2022-06-08 08:42:59 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration foxess: No setup or config entry setup function defined.

From what I see in that code, it’s a work in progress. I don’t see any entities added to hass for example.
If you have the exact code that was running, from your initial post, I think this is not it.

@clau-bucur i have pushed to branch exact version that i’m running and in the logs I can see:

2022-07-12 09:30:11 WARNING (SyncWorker_4) [homeassistant.loader] We found a custom integration foxess which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

On the GitHub actions you can also see that i have some problem - they are failing

Just a quick update for anyone jumping here now.
There is a new and more up to date version of this, it scraps the yaml in favour of a more user friendly approach and includes way more features and controls.
You can find more info here: