HOW do you modify configuration of integrations? It's impossible

For example, the ISY insteon configuration gives me errors and instructions to modify configuration. HOW? There are no configuration variables from the integration page nor config.yaml. Most integrations are like this for some reason; no way to access login information etc. You have to DELETE the integration and re-add to input config parameters.
What am I missing here?
Thanks

2 Likes

Nothing. It is the developer who has missed the functionality.

I faced the same issue with the Synology DSM integration yesterday.
Any workaround to avoid having to delete the integration when you need to change something?

The only way to do that if the integration doesn’t allow you to modify the config from the UI is to manually edit the config entries in the .storage files.

This is not recommended because if you mess it up you can break HA.

Usually it’s better to just delete and re-install the integration.

There are some integrations that will allow you to create a new instance of the same integration with the desired changes and when you do that it replaces the prior integration with the newly updated integration. I’m pretty sure zwavejs does that…I think…

2 Likes

It would be nice if HA had some UI standards. Devs should always allow initial configuration variables to be updated via UI, for example. Stunned this is isn’t a thing.

8 Likes

From an integration developer perspective, how can I modify the config values? It seems that after you’ve added an integration the only way to change settings from the UI is implementing an OptionsFlow.

This then calls an update_listener function in the __init__.py that I’ve implemented like so:

async def update_listener(hass: HomeAssistant, config: ConfigEntry) -> None:
    """Try to change a config option... doesn't work!"""
    hass.data[DOMAIN][MY_BOOLEAN_SETTING] = False

In the example, the config identified by the MY_BOOLEAN_SETTING string constant is set to True during the integration initial configuration. When I click the Configure button in the Home Assistant UI, the OptionsFlow is called and the update_listener function too, so the HA config for the integration should be set to False.

But the problem is that when I restart HA the value is still True. So what is the correct way to set and persist the configuration values?
I’m pretty much dissatisfied with the HA documentation :frowning_face:

The integration developer or Home Assistant developer?

You can reconfigure some integrations, so the functionality is not missing from ha itself. All I can suggest is looking at the implementation of, say, google cast. It enables reconfiguration.

Yes, after some digging I have understood that you cannot change the configuration itself, which is immutable after adding the integration.
But you can refer to the options (data created by the OptionsFlow) and use them instead.

So, for other devs who may come here in the future:

  • config.data[KEY] contains the settings dictionary created when adding the integration (i.e. in ConfigFlow) and is immutable
  • config.options[KEY] contains the settings dictionary created after accessing the options in the UI (i.e. the OptionsFlow) and is mutable and persisted, but may not be present during the first configuration, as the OptionsFlow has not be invoked
  • So, if you use the same key for a setting that is both asked during configuration and edited using the UI, you can use config.options.get(KEY, config.data[KEY]) to get the current value in the code

Again, this is not documented well IMHO, but I think is the correct way to handle it (or at least it works).

2 Likes