Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .strict-typing
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ homeassistant.components.ruuvi_gateway.*
homeassistant.components.ruuvitag_ble.*
homeassistant.components.samsungtv.*
homeassistant.components.saunum.*
homeassistant.components.scaleway_object_storage.*
homeassistant.components.scene.*
homeassistant.components.schedule.*
homeassistant.components.schlage.*
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions homeassistant/components/scaleway_object_storage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""The Scaleway Object Storage integration."""

from typing import TYPE_CHECKING
Comment thread
BjoernPetersen marked this conversation as resolved.

from homeassistant.config_entries import ConfigEntry
from homeassistant.exceptions import (
ConfigEntryAuthFailed,
ConfigEntryError,
ConfigEntryNotReady,
)
from homeassistant.helpers import aiohttp_client

if TYPE_CHECKING:
from aiohttp_s3_client import S3Client

from homeassistant.core import HomeAssistant

from . import exceptions, helpers
from .const import DATA_BACKUP_AGENT_LISTENERS, DOMAIN

type ScalewayConfigEntry = ConfigEntry[S3Client]
Comment thread
BjoernPetersen marked this conversation as resolved.


async def async_setup_entry(hass: HomeAssistant, entry: ScalewayConfigEntry) -> bool:
Comment thread
BjoernPetersen marked this conversation as resolved.
"""Set up an integration config entry."""
session = aiohttp_client.async_get_clientsession(hass)
client = helpers.create_client(session, entry.data)
try:
await helpers.check_connection(client)
except ConfigEntryNotReady, ConfigEntryError, ConfigEntryAuthFailed:
Comment thread
BjoernPetersen marked this conversation as resolved.
# Re-raise as they are
raise
except exceptions.ScalewayException as e:
# All other exceptions are translated
raise ConfigEntryError(
translation_domain=DOMAIN,
translation_key=e.translation_key,
Comment thread
BjoernPetersen marked this conversation as resolved.
translation_placeholders=e.translation_placeholders,
) from e

entry.runtime_data = client

# Notify backup listeners
def notify_backup_listeners() -> None:
listeners = hass.data.get(DATA_BACKUP_AGENT_LISTENERS, [])
for listener in list(listeners):
listener()

entry.async_on_unload(entry.async_on_state_change(notify_backup_listeners))

return True


async def async_unload_entry(hass: HomeAssistant, entry: ScalewayConfigEntry) -> bool:
"""Unload a config entry."""
return True
Loading
Loading