diff --git a/homeassistant/components/renault/__init__.py b/homeassistant/components/renault/__init__.py index 62425d9c20e..4b7ff8f5648 100644 --- a/homeassistant/components/renault/__init__.py +++ b/homeassistant/components/renault/__init__.py @@ -7,10 +7,20 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady +from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.typing import ConfigType from .const import CONF_LOCALE, DOMAIN, PLATFORMS from .renault_hub import RenaultHub -from .services import SERVICE_AC_START, setup_services, unload_services +from .services import setup_services + +CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) + + +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: + """Set up the Renault component.""" + setup_services(hass) + return True async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: @@ -36,21 +46,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS) - if not hass.services.has_service(DOMAIN, SERVICE_AC_START): - setup_services(hass) - return True async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Unload a config entry.""" - unload_ok = await hass.config_entries.async_unload_platforms( - config_entry, PLATFORMS - ) - - if unload_ok: - hass.data[DOMAIN].pop(config_entry.entry_id) - if not hass.data[DOMAIN]: - unload_services(hass) - - return unload_ok + return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS) diff --git a/homeassistant/components/renault/services.py b/homeassistant/components/renault/services.py index b49088ddb7d..c274e75b380 100644 --- a/homeassistant/components/renault/services.py +++ b/homeassistant/components/renault/services.py @@ -141,9 +141,3 @@ def setup_services(hass: HomeAssistant) -> None: charge_set_schedules, schema=SERVICE_CHARGE_SET_SCHEDULES_SCHEMA, ) - - -def unload_services(hass: HomeAssistant) -> None: - """Unload Renault services.""" - for service in SERVICES: - hass.services.async_remove(DOMAIN, service) diff --git a/tests/components/renault/test_services.py b/tests/components/renault/test_services.py index e97988a09f7..a1715a479f2 100644 --- a/tests/components/renault/test_services.py +++ b/tests/components/renault/test_services.py @@ -18,7 +18,6 @@ from homeassistant.components.renault.services import ( SERVICE_AC_CANCEL, SERVICE_AC_START, SERVICE_CHARGE_SET_SCHEDULES, - SERVICES, ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( @@ -60,25 +59,6 @@ def get_device_id(hass: HomeAssistant) -> str: return device.id -async def test_service_registration( - hass: HomeAssistant, config_entry: ConfigEntry -) -> None: - """Test entry setup and unload.""" - await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done() - - # Check that all services are registered. - for service in SERVICES: - assert hass.services.has_service(DOMAIN, service) - - # Unload the entry - await hass.config_entries.async_unload(config_entry.entry_id) - - # Check that all services are un-registered. - for service in SERVICES: - assert not hass.services.has_service(DOMAIN, service) - - async def test_service_set_ac_cancel( hass: HomeAssistant, config_entry: ConfigEntry ) -> None: