Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when trying to use with recent HA version like 2023.09 #2

Open
thomluther opened this issue Oct 10, 2023 · 0 comments
Open

Comments

@thomluther
Copy link

Seems the last change to this is quite old and it causes configuration load exceptions for the home assistant object since it has now mandatory arguments as described here:
https://developers.home-assistant.io/blog/2023/08/29/homeassistant-changed-signature?_highlight=homeassistant%28

With following changes I could get the ha-constant-modifier to work with HA 2023.10:
Updated imports:

from homeassistant.core import HomeAssistant
from homeassistant.config import load_yaml_config_file, YAML_CONFIG_FILE
from homeassistant.__main__ import get_arguments
from homeassistant.util.yaml import SECRET_YAML, Secrets, load_yaml

here is the updated def get_ha_config() to use the required config file parameter and the secrets parameter.
PS: From the code it appears that Secret is optional and defaults to Null, but since I use Secrets includes in my config I guess this must be specified as well when you want to duplicate the changed HA startup sequence

def get_ha_config():
    """
    Duplicate enough of the HA startup sequence to extract the config *really* early.
    """

    args = get_arguments()

    try:
        hass = HomeAssistant()  # pylint: disable=no-value-for-parameter
        hass.config.config_dir = os.path.abspath(os.path.join(os.getcwd(), args.config))
    except TypeError:
        hass = HomeAssistant(os.path.abspath(os.path.join(os.getcwd(), args.config)))  # pylint: disable=too-many-function-args

    return load_yaml_config_file(hass.config.path(YAML_CONFIG_FILE),Secrets(hass.config.path(hass.config.config_dir)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant