Auto reload YAML config changes (#573)

* Update __init__.py

* Update __init__.py

* skip installing codecov

* remove in CI

* test 2023.4.6

---------

Co-authored-by: Bas Nijholt <bas@nijho.lt>
This commit is contained in:
Benjamin Auquite 2023-04-26 21:10:52 -05:00 committed by GitHub
commit adf0d0cf30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View file

@ -36,6 +36,8 @@ runs:
run: |
echo "::warning::### WARNING! Deprecation warnings muted with option '--use-pep517' please address this at some point in pytest.yaml. ###"
pip install -r core/requirements.txt --use-pep517
# because they decided to pull codecov the package from PyPI...
sed -i '/codecov/d' core/requirements_test.txt
pip install -r core/requirements_test.txt --use-pep517
pip install -e core/ --use-pep517
pip install ulid-transform # this is in Adaptive-lighting's manifest.json

View file

@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.10"]
core-version: ["2023.2.5", "2023.3.6", "2023.4.0", "dev"]
core-version: ["2023.2.5", "2023.3.6", "2023.4.6", "dev"]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3

View file

@ -6,7 +6,6 @@ from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import CONF_SOURCE
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import async_setup_reload_service
import voluptuous as vol
from .const import (
@ -36,10 +35,13 @@ CONFIG_SCHEMA = vol.Schema(
)
async def reload_configuration_yaml(event: dict, hass: HomeAssistant):
"""Reload configuration.yaml."""
await hass.services.async_call("homeassistant", "check_config", {})
async def async_setup(hass: HomeAssistant, config: dict[str, Any]):
"""Import integration from config."""
# This will reload any changes the user made to any YAML configurations.
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
if DOMAIN in config:
for entry in config[DOMAIN]:
@ -55,6 +57,10 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Set up the component."""
data = hass.data.setdefault(DOMAIN, {})
# This will reload any changes the user made to any YAML configurations.
# Called during 'quick reload' or hass.reload_config_entry
hass.bus.async_listen("hass.config.entry_updated", reload_configuration_yaml)
undo_listener = config_entry.add_update_listener(async_update_options)
data[config_entry.entry_id] = {UNDO_UPDATE_LISTENER: undo_listener}
for platform in PLATFORMS: