from .const import API_WS_URL as API_WS_URL, All_LIGHT_TYPES as All_LIGHT_TYPES, BASIC_INPUTS_EVENTS_TYPES as BASIC_INPUTS_EVENTS_TYPES, COIOT_UNCONFIGURED_ISSUE_ID as COIOT_UNCONFIGURED_ISSUE_ID, COMPONENT_ID_PATTERN as COMPONENT_ID_PATTERN, CONF_COAP_PORT as CONF_COAP_PORT, CONF_GEN as CONF_GEN, DEVICES_WITHOUT_FIRMWARE_CHANGELOG as DEVICES_WITHOUT_FIRMWARE_CHANGELOG, DEVICE_UNIT_MAP as DEVICE_UNIT_MAP, DOMAIN as DOMAIN, FIRMWARE_UNSUPPORTED_ISSUE_ID as FIRMWARE_UNSUPPORTED_ISSUE_ID, GEN1_RELEASE_URL as GEN1_RELEASE_URL, GEN2_BETA_RELEASE_URL as GEN2_BETA_RELEASE_URL, GEN2_RELEASE_URL as GEN2_RELEASE_URL, LOGGER as LOGGER, MAX_SCRIPT_SIZE as MAX_SCRIPT_SIZE, PUSH_UPDATE_ISSUE_ID as PUSH_UPDATE_ISSUE_ID, ROLE_GENERIC as ROLE_GENERIC, RPC_INPUTS_EVENTS_TYPES as RPC_INPUTS_EVENTS_TYPES, SHAIR_MAX_WORK_HOURS as SHAIR_MAX_WORK_HOURS, SHBTN_INPUTS_EVENTS_TYPES as SHBTN_INPUTS_EVENTS_TYPES, SHBTN_MODELS as SHBTN_MODELS, SHELLY_EMIT_EVENT_PATTERN as SHELLY_EMIT_EVENT_PATTERN, SHIX3_1_INPUTS_EVENTS_TYPES as SHIX3_1_INPUTS_EVENTS_TYPES, UPTIME_DEVIATION as UPTIME_DEVIATION, VIRTUAL_COMPONENTS as VIRTUAL_COMPONENTS, VIRTUAL_COMPONENTS_MAP as VIRTUAL_COMPONENTS_MAP
from _typeshed import Incomplete
from aiohttp.web import Request as Request, WebSocketResponse as WebSocketResponse
from aioshelly.block_device import Block as Block, BlockDevice as BlockDevice, COAP
from aioshelly.rpc_device import RpcDevice, WsServer
from collections.abc import Iterable, Mapping
from datetime import datetime
from homeassistant.components import network as network
from homeassistant.components.http import HomeAssistantView as HomeAssistantView
from homeassistant.components.network import async_get_source_ip as async_get_source_ip
from homeassistant.config_entries import ConfigEntry as ConfigEntry
from homeassistant.const import CONF_HOST as CONF_HOST, CONF_MODEL as CONF_MODEL, CONF_PORT as CONF_PORT, EVENT_HOMEASSISTANT_STOP as EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event as Event, HomeAssistant as HomeAssistant, callback as callback
from homeassistant.helpers import entity_registry as er, singleton as singleton
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH as CONNECTION_BLUETOOTH, CONNECTION_NETWORK_MAC as CONNECTION_NETWORK_MAC, DeviceInfo as DeviceInfo
from homeassistant.helpers.network import NoURLAvailableError as NoURLAvailableError, get_url as get_url
from homeassistant.util.dt import utcnow as utcnow
from typing import Any
from yarl import URL

@callback
def async_remove_shelly_entity(hass: HomeAssistant, domain: str, unique_id: str) -> None: ...
def get_block_number_of_channels(device: BlockDevice, block: Block) -> int: ...
def get_block_custom_name(device: BlockDevice, block: Block | None) -> str | None: ...
def get_block_channel(block: Block | None, base: str = '1') -> str: ...
def get_block_sub_device_name(device: BlockDevice, block: Block) -> str: ...
def is_block_momentary_input(settings: dict[str, Any], block: Block, include_detached: bool = False) -> bool: ...
def is_block_exclude_from_relay(settings: dict[str, Any], block: Block) -> bool: ...
def get_device_uptime(uptime: float, last_uptime: datetime | None) -> datetime: ...
def get_block_input_triggers(device: BlockDevice, block: Block) -> list[tuple[str, str]]: ...
def get_shbtn_input_triggers() -> list[tuple[str, str]]: ...
def get_coiot_port(hass: HomeAssistant) -> int: ...
async def get_coap_context(hass: HomeAssistant) -> COAP: ...

class ShellyReceiver(HomeAssistantView):
    requires_auth: bool
    url = API_WS_URL
    name: str
    _ws_server: Incomplete
    def __init__(self, ws_server: WsServer) -> None: ...
    async def get(self, request: Request) -> WebSocketResponse: ...

async def get_ws_context(hass: HomeAssistant) -> WsServer: ...
def get_block_device_sleep_period(settings: dict[str, Any]) -> int: ...
def get_rpc_device_wakeup_period(status: dict[str, Any]) -> int: ...
def get_info_auth(info: dict[str, Any]) -> bool: ...
def get_info_gen(info: dict[str, Any]) -> int: ...
def get_model_name(info: dict[str, Any]) -> str: ...
def get_shelly_model_name(model: str, sleep_period: int, device: BlockDevice | RpcDevice) -> str | None: ...
def get_rpc_key(value: str) -> tuple[bool, str, str]: ...
def get_rpc_key_id(value: str) -> int: ...
def get_rpc_custom_name(device: RpcDevice, key: str) -> str | None: ...
def get_rpc_number_of_channels(device: RpcDevice, component: str) -> int: ...
def get_rpc_channel_name(device: RpcDevice, key: str) -> str | None: ...
def get_rpc_key_normalized(key: str) -> str: ...
def get_rpc_sub_device_name(device: RpcDevice, key: str, emeter_phase: str | None = None) -> str: ...
def get_device_entry_gen(entry: ConfigEntry) -> int: ...
def get_rpc_key_instances(keys_dict: dict[str, Any], key: str, all_lights: bool = False) -> list[str]: ...
def get_rpc_key_ids(keys_dict: dict[str, Any], key: str) -> list[int]: ...
def get_rpc_key_by_role(keys_dict: dict[str, Any], role: str) -> str | None: ...
def get_rpc_role_by_key(keys_dict: dict[str, Any], key: str) -> str: ...
def is_rpc_momentary_input(config: dict[str, Any], status: dict[str, Any], key: str) -> bool: ...
def is_block_channel_type_light(settings: dict[str, Any], block: Block) -> bool: ...
def is_rpc_channel_type_light(config: dict[str, Any], channel: int) -> bool: ...
def is_rpc_thermostat_internal_actuator(status: dict[str, Any]) -> bool: ...
def get_rpc_input_triggers(device: RpcDevice) -> list[tuple[str, str]]: ...
@callback
def update_device_fw_info(hass: HomeAssistant, shellydevice: BlockDevice | RpcDevice, entry: ConfigEntry) -> None: ...
def brightness_to_percentage(brightness: int) -> int: ...
def percentage_to_brightness(percentage: int) -> int: ...
def mac_address_from_name(name: str) -> str | None: ...
def get_release_url(gen: int, model: str, beta: bool) -> str | None: ...
@callback
def async_create_issue_unsupported_firmware(hass: HomeAssistant, entry: ConfigEntry) -> None: ...
def is_rpc_wifi_stations_disabled(config: dict[str, Any], _status: dict[str, Any], key: str) -> bool: ...
def get_http_port(data: Mapping[str, Any]) -> int: ...
def get_host(host: str) -> str: ...
@callback
def async_remove_shelly_rpc_entities(hass: HomeAssistant, domain: str, mac: str, keys: list[str]) -> None: ...
def get_virtual_component_ids(config: dict[str, Any], platform: str) -> list[str]: ...
def is_view_for_platform(config: dict[str, Any], key: str, platform: str) -> bool: ...
def get_virtual_component_unit(config: dict[str, Any]) -> str | None: ...
@callback
def async_remove_orphaned_entities(hass: HomeAssistant, config_entry_id: str, mac: str, platform: str, keys: Iterable[str], key_suffix: str | None = None) -> None: ...
def _get_homeassistant_url(hass: HomeAssistant) -> URL | None: ...
async def get_coiot_address(hass: HomeAssistant) -> str | None: ...
def get_rpc_ws_url(hass: HomeAssistant) -> str | None: ...
async def get_rpc_script_event_types(device: RpcDevice, id: int) -> list[str]: ...
def is_rpc_exclude_from_relay(settings: dict[str, Any], status: dict[str, Any], channel: str) -> bool: ...
def get_shelly_air_lamp_life(lamp_seconds: int) -> float: ...
async def get_rpc_scripts_event_types(device: RpcDevice, ignore_scripts: list[str]) -> dict[int, list[str]]: ...
def get_irrigation_zone_id(device: RpcDevice, key: str) -> int | None: ...
def get_rpc_device_info(device: RpcDevice, mac: str, configuration_url: str, model: str, model_name: str | None = None, key: str | None = None, emeter_phase: str | None = None, suggested_area: str | None = None) -> DeviceInfo: ...
def get_blu_trv_device_info(config: dict[str, Any], ble_addr: str, parent_mac: str, fw_ver: str | None) -> DeviceInfo: ...
def is_block_single_device(device: BlockDevice, block: Block | None = None) -> bool: ...
def get_block_device_info(device: BlockDevice, mac: str, configuration_url: str, model: str, model_name: str | None = None, block: Block | None = None, suggested_area: str | None = None) -> DeviceInfo: ...
@callback
def remove_stale_blu_trv_devices(hass: HomeAssistant, rpc_device: RpcDevice, entry: ConfigEntry) -> None: ...
@callback
def remove_empty_sub_devices(hass: HomeAssistant, entry: ConfigEntry) -> None: ...
def format_ble_addr(ble_addr: str) -> str: ...
@callback
def async_migrate_rpc_sensor_description_unique_ids(entity_entry: er.RegistryEntry) -> dict[str, Any] | None: ...
@callback
def async_migrate_rpc_virtual_components_unique_ids(config: dict[str, Any], entity_entry: er.RegistryEntry) -> dict[str, Any] | None: ...
def is_rpc_ble_scanner_supported(entry: ConfigEntry) -> bool: ...
async def check_coiot_config(device: BlockDevice, hass: HomeAssistant) -> bool: ...
async def async_manage_coiot_issues_task(hass: HomeAssistant, entry: ConfigEntry) -> None: ...
