示例#1
0
    async def async_step_user(self,
                              user_input: dict[str, Any] | None = None
                              ) -> FlowResult:
        """Handle the initial step."""
        if is_hassio(self.hass):
            return await self.async_step_on_supervisor()

        return await self.async_step_manual()
    async def async_step_user(
        self, user_input: Optional[Dict[str, Any]] = None
    ) -> Dict[str, Any]:
        """Handle the initial step."""
        assert self.hass  # typing
        if is_hassio(self.hass):  # type: ignore  # no-untyped-call
            return await self.async_step_on_supervisor()

        return await self.async_step_manual()
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Initialize default configuration."""
    if not is_hassio(hass):
        await async_setup_component(hass, "backup", config)

    if av is None:
        return True

    return await async_setup_component(hass, "stream", config)
示例#4
0
    async def async_step_user(self, user_input=None):
        """Handle the initial step."""
        if self._async_current_entries():
            return self.async_abort(reason="single_instance_allowed")

        # Set a unique_id to make sure discovery flow is aborted on progress.
        await self.async_set_unique_id(DOMAIN, raise_on_progress=False)

        if not hassio.is_hassio(self.hass):
            return self._async_use_mqtt_integration()

        return await self.async_step_on_supervisor()
示例#5
0
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the Backup integration."""
    if is_hassio(hass):
        LOGGER.error(
            "The backup integration is not supported on this installation method, "
            "please remove it from your configuration")
        return False

    hass.data[DOMAIN] = BackupManager(hass)

    async_register_websocket_handlers(hass)
    async_register_http_views(hass)

    return True
示例#6
0
    async def async_step_usb(self, discovery_info: dict[str,
                                                        str]) -> FlowResult:
        """Handle USB Discovery."""
        if not is_hassio(self.hass):
            return self.async_abort(reason="discovery_requires_supervisor")
        if self._async_current_entries():
            return self.async_abort(reason="already_configured")
        if self._async_in_progress():
            return self.async_abort(reason="already_in_progress")

        vid = discovery_info["vid"]
        pid = discovery_info["pid"]
        serial_number = discovery_info["serial_number"]
        device = discovery_info["device"]
        manufacturer = discovery_info["manufacturer"]
        description = discovery_info["description"]
        # The Nortek sticks are a special case since they
        # have a Z-Wave and a Zigbee radio. We need to reject
        # the Zigbee radio.
        if vid == "10C4" and pid == "8A2A" and "Z-Wave" not in description:
            return self.async_abort(reason="not_zwave_device")
        # Zooz uses this vid/pid, but so do 2652 sticks
        if vid == "10C4" and pid == "EA60" and "2652" in description:
            return self.async_abort(reason="not_zwave_device")

        addon_info = await self._async_get_addon_info()
        if addon_info.state not in (AddonState.NOT_INSTALLED,
                                    AddonState.NOT_RUNNING):
            return self.async_abort(reason="already_configured")

        await self.async_set_unique_id(
            f"{vid}:{pid}_{serial_number}_{manufacturer}_{description}")
        self._abort_if_unique_id_configured()
        dev_path = await self.hass.async_add_executor_job(
            usb.get_serial_by_id, device)
        self.usb_path = dev_path
        self._title = usb.human_readable_device_name(
            dev_path,
            serial_number,
            manufacturer,
            description,
            vid,
            pid,
        )
        self.context["title_placeholders"] = {CONF_NAME: self._title}
        return await self.async_step_usb_confirm()
示例#7
0
    async def async_step_usb(self,
                             discovery_info: usb.UsbServiceInfo) -> FlowResult:
        """Handle USB Discovery."""
        if not is_hassio(self.hass):
            return self.async_abort(reason="discovery_requires_supervisor")
        if self._async_current_entries():
            return self.async_abort(reason="already_configured")
        if self._async_in_progress():
            return self.async_abort(reason="already_in_progress")

        vid = discovery_info.vid
        pid = discovery_info.pid
        serial_number = discovery_info.serial_number
        device = discovery_info.device
        manufacturer = discovery_info.manufacturer
        description = discovery_info.description
        # Zooz uses this vid/pid, but so do 2652 sticks
        if vid == "10C4" and pid == "EA60" and description and "2652" in description:
            return self.async_abort(reason="not_zwave_device")

        addon_info = await self._async_get_addon_info()
        if addon_info.state not in (AddonState.NOT_INSTALLED,
                                    AddonState.NOT_RUNNING):
            return self.async_abort(reason="already_configured")

        await self.async_set_unique_id(
            f"{vid}:{pid}_{serial_number}_{manufacturer}_{description}")
        self._abort_if_unique_id_configured()
        dev_path = await self.hass.async_add_executor_job(
            usb.get_serial_by_id, device)
        self.usb_path = dev_path
        self._title = usb.human_readable_device_name(
            dev_path,
            serial_number,
            manufacturer,
            description,
            vid,
            pid,
        )
        self.context["title_placeholders"] = {
            CONF_NAME: self._title.split(" - ")[0].strip()
        }
        return await self.async_step_usb_confirm()
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the Backup integration."""
    if is_hassio(hass):
        LOGGER.error(
            "The backup integration is not supported on this installation method, "
            "please remove it from your configuration")
        return False

    backup_manager = BackupManager(hass)
    hass.data[DOMAIN] = backup_manager

    async def async_handle_create_service(call: ServiceCall) -> None:
        """Service handler for creating backups."""
        await backup_manager.generate_backup()

    hass.services.async_register(DOMAIN, "create", async_handle_create_service)

    async_register_websocket_handlers(hass)
    async_register_http_views(hass)

    return True
示例#9
0
    async def post(self, request):
        """Handle finishing core config step."""
        hass = request.app["hass"]

        async with self._lock:
            if self._async_is_done():
                return self.json_message("Core config step already done",
                                         HTTPStatus.FORBIDDEN)

            await self._async_mark_done(hass)

            await hass.config_entries.flow.async_init(
                "met", context={"source": "onboarding"})

            # pylint: disable=import-outside-toplevel
            from homeassistant.components import hassio

            if (hassio.is_hassio(hass) and "raspberrypi"
                    in hassio.get_core_info(hass)["machine"]):
                await hass.config_entries.flow.async_init(
                    "rpi_power", context={"source": "onboarding"})

            return self.json({})
示例#10
0
 def supervisor(self) -> bool:
     """Return bool if a supervisor is present."""
     return hassio.is_hassio(self.hass)