1 """Support for Renault devices."""
4 from renault_api.gigya.exceptions
import GigyaException
13 from .const
import CONF_LOCALE, DOMAIN, PLATFORMS
14 from .renault_hub
import RenaultHub
15 from .services
import setup_services
17 CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
18 type RenaultConfigEntry = ConfigEntry[RenaultHub]
21 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
22 """Set up the Renault component."""
28 hass: HomeAssistant, config_entry: RenaultConfigEntry
30 """Load a config entry."""
31 renault_hub =
RenaultHub(hass, config_entry.data[CONF_LOCALE])
33 login_success = await renault_hub.attempt_login(
34 config_entry.data[CONF_USERNAME], config_entry.data[CONF_PASSWORD]
36 except (aiohttp.ClientConnectionError, GigyaException)
as exc:
37 raise ConfigEntryNotReady
from exc
40 raise ConfigEntryAuthFailed
43 await renault_hub.async_initialise(config_entry)
44 except aiohttp.ClientError
as exc:
45 raise ConfigEntryNotReady
from exc
47 config_entry.runtime_data = renault_hub
49 await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
55 hass: HomeAssistant, config_entry: RenaultConfigEntry
57 """Unload a config entry."""
58 return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
62 hass: HomeAssistant, config_entry: RenaultConfigEntry, device_entry: dr.DeviceEntry
64 """Remove a config entry from a device."""
65 return not device_entry.identifiers.intersection(
66 (DOMAIN, vin)
for vin
in config_entry.runtime_data.vehicles
None setup_services(HomeAssistant hass)
bool async_unload_entry(HomeAssistant hass, RenaultConfigEntry config_entry)
bool async_setup(HomeAssistant hass, ConfigType config)
bool async_remove_config_entry_device(HomeAssistant hass, RenaultConfigEntry config_entry, dr.DeviceEntry device_entry)
bool async_setup_entry(HomeAssistant hass, RenaultConfigEntry config_entry)