<commit_before>"""The Litter-Robot integration."""
from __future__ import annotations

from pylitterbot import FeederRobot, LitterRobot, LitterRobot3, Robot

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import ConfigType

from .const import DOMAIN
from .hub import LitterRobotHub

PLATFORMS_BY_TYPE = {
    Robot: (
        Platform.BINARY_SENSOR,
        Platform.SELECT,
        Platform.SENSOR,
        Platform.SWITCH,
    ),
    LitterRobot: (Platform.VACUUM,),
    LitterRobot3: (Platform.BUTTON,),
    FeederRobot: (Platform.BUTTON,),
}


def get_platforms_for_robots(robots: list[Robot]) -> set[Platform]:
    """Get platforms for robots."""
    return {
        platform
        for robot in robots
        for robot_type, platforms in PLATFORMS_BY_TYPE.items()
        if isinstance(robot, robot_type)
        for platform in platforms
    }


async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the Litter-Robot integration."""
    async_create_issue(
        hass,
        DOMAIN,
        "migrated_attributes",
        breaks_in_ha_version="2022.12.0",
        is_fixable=False,
        severity=IssueSeverity.WARNING,
        translation_key="migrated_attributes",
    )

    return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Set up Litter-Robot from a config entry."""
    hass.data.setdefault(DOMAIN, {})
    hub = hass.data[DOMAIN][entry.entry_id] = LitterRobotHub(hass, entry.data)
    await hub.login(load_robots=True, subscribe_for_updates=True)

    if platforms := get_platforms_for_robots(hub.account.robots):
        await hass.config_entries.async_forward_entry_setups(entry, platforms)
    return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Unload a config entry."""
    hub: LitterRobotHub = hass.data[DOMAIN][entry.entry_id]
    await hub.account.disconnect()

    platforms = get_platforms_for_robots(hub.account.robots)
    unload_ok = await hass.config_entries.async_unload_platforms(entry, platforms)
<commit_msg>Remove repairs issue per PR review request (#79561)<commit_after>"""The Litter-Robot integration."""
from __future__ import annotations

from pylitterbot import FeederRobot, LitterRobot, LitterRobot3, Robot

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant

from .const import DOMAIN
from .hub import LitterRobotHub

PLATFORMS_BY_TYPE = {
    Robot: (
        Platform.BINARY_SENSOR,
        Platform.SELECT,
        Platform.SENSOR,
        Platform.SWITCH,
    ),
    LitterRobot: (Platform.VACUUM,),
    LitterRobot3: (Platform.BUTTON,),
    FeederRobot: (Platform.BUTTON,),
}


def get_platforms_for_robots(robots: list[Robot]) -> set[Platform]:
    """Get platforms for robots."""
    return {
        platform
        for robot in robots
        for robot_type, platforms in PLATFORMS_BY_TYPE.items()
        if isinstance(robot, robot_type)
        for platform in platforms
    }


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Set up Litter-Robot from a config entry."""
    hass.data.setdefault(DOMAIN, {})
    hub = hass.data[DOMAIN][entry.entry_id] = LitterRobotHub(hass, entry.data)
    await hub.login(load_robots=True, subscribe_for_updates=True)

    if platforms := get_platforms_for_robots(hub.account.robots):
        await hass.config_entries.async_forward_entry_setups(entry, platforms)
    return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Unload a config entry."""
    hub: LitterRobotHub = hass.data[DOMAIN][entry.entry_id]
    await hub.account.disconnect()

    platforms = get_platforms_for_robots(hub.account.robots)
    unload_ok = await hass.config_entries.async_unload_platforms(entry, platforms)

{'fraction_non_alphanumeric': 0.09377289377289377, 'fraction_numerical': 0.003907203907203907, 'mean_word_length': 3.970873786407767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7479982', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1298, 'n_words': 286}