mirror of
https://github.com/home-assistant/core.git
synced 2026-06-05 15:14:37 +01:00
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""The Konnected.io integration."""
|
|
|
|
import voluptuous as vol
|
|
|
|
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import config_validation as cv, issue_registry as ir
|
|
from homeassistant.helpers.typing import ConfigType
|
|
|
|
from .const import DOMAIN
|
|
|
|
CONFIG_SCHEMA = vol.Schema({DOMAIN: cv.match_all}, extra=vol.ALLOW_EXTRA)
|
|
|
|
|
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|
"""Set up the Konnected.io integration."""
|
|
if DOMAIN in config:
|
|
_create_issue(hass)
|
|
return True
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up Konnected.io from a config entry."""
|
|
_create_issue(hass)
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Unload a config entry."""
|
|
if all(
|
|
config_entry.state is ConfigEntryState.NOT_LOADED
|
|
for config_entry in hass.config_entries.async_entries(DOMAIN)
|
|
if config_entry.entry_id != entry.entry_id
|
|
):
|
|
ir.async_delete_issue(hass, DOMAIN, DOMAIN)
|
|
|
|
return True
|
|
|
|
|
|
def _create_issue(hass: HomeAssistant) -> None:
|
|
"""Create the integration removed repair issue."""
|
|
ir.async_create_issue(
|
|
hass,
|
|
DOMAIN,
|
|
DOMAIN,
|
|
is_fixable=False,
|
|
severity=ir.IssueSeverity.ERROR,
|
|
translation_key="integration_removed",
|
|
translation_placeholders={
|
|
"entries": "/config/integrations/integration/konnected",
|
|
"kb_page_url": "https://support.konnected.io/migrating-from-konnected-legacy-home-assistant-integration-to-esphome",
|
|
},
|
|
)
|