コード例 #1
0
    async def _async_choose_step(self):
        """Choose a sequence."""
        # pylint: disable=protected-access
        choose_data = await self._script._async_get_choose_data(self._step)

        for conditions, script in choose_data["choices"]:
            if all(condition(self._hass, self._variables) for condition in conditions):
                await self._async_run_script(script)
                return

        if choose_data["default"]:
            await self._async_run_script(choose_data["default"])
コード例 #2
0
    async def _async_choose_step(self) -> None:
        """Choose a sequence."""
        # pylint: disable=protected-access
        choose_data = await self._script._async_get_choose_data(self._step)

        for conditions, script in choose_data["choices"]:
            try:
                if all(
                        condition(self._hass, self._variables)
                        for condition in conditions):
                    await self._async_run_script(script)
                    return
            except exceptions.ConditionError as ex:
                _LOGGER.warning("Error in 'choose' evaluation:\n%s", ex)

        if choose_data["default"]:
            await self._async_run_script(choose_data["default"])