Exemplo n.º 1
0
    async def configure(self,
                        ssid: str,
                        password: str,
                        *,
                        silent: bool = True) -> dict:
        """Configure the device to a wireless network.

        :param ssid: The SSID to connect to
        :type ssid: ``str``
        :param password: The SSID's password
        :type password: ``str``
        :param silent: If ``True``, silence "beep" tones associated with this command
        :type silent: ``bool``
        :rtype: ``dict``
        """
        params = {PARAM_SSID: ssid, PARAM_PASSWORD: password}

        try:
            WIFI_CONFIGURE_PARAM_SCHEMA(params)
        except vol.Invalid as err:
            raise CommandError(f"Invalid parameters provided: {err}") from None

        return await self._execute_command(Command.wifi_configure,
                                           params=params,
                                           silent=silent)
Exemplo n.º 2
0
def get_command_from_code(command_code: int) -> Command:
    """Return the command for a particular code.

    :param command_code: The command code to search for
    :type command_code: ``int``
    :rtype: :meth:`aioguardian.helpers.command.Command`
    """
    try:
        command = Command(command_code)
    except ValueError:
        raise CommandError(f"Unknown command code: {command_code}") from None
    return command
Exemplo n.º 3
0
def get_command_from_name(command_name: str) -> Command:
    """Return the command for a particular name.

    :param command_name: The command name to search for
    :type command_name: ``str``
    :rtype: :meth:`aioguardian.helpers.command.Command`
    """
    try:
        command = Command[command_name]
    except KeyError:
        raise CommandError(f"Unknown command name: {command_name}") from None
    return command
Exemplo n.º 4
0
    async def unpair_sensor(self, uid: str, *, silent: bool = True) -> dict:
        """Unpair a sensor from the device.

        :param uid: The UID of the sensor to unpair
        :type uid: ``str``
        :param silent: If ``True``, silence "beep" tones associated with this command
        :type silent: ``bool``
        :rtype: ``dict``
        """
        params = {PARAM_UID: uid}

        try:
            PAIRED_SENSOR_UID_SCHEMA(params)
        except vol.Invalid as err:
            raise CommandError(f"Invalid parameters provided: {err}") from None

        return await self._execute_command(Command.sensor_unpair_sensor,
                                           params=params,
                                           silent=silent)
Exemplo n.º 5
0
    async def paired_sensor_status(self,
                                   uid: str,
                                   *,
                                   silent: bool = True) -> dict:
        """Get the status (leak, temperature, etc.) of a paired sensor.

        :param uid: The UID of the sensor to pair
        :type uid: ``str``
        :param silent: If ``True``, silence "beep" tones associated with this command
        :type silent: ``bool``
        :rtype: ``dict``
        """
        params = {PARAM_UID: uid}

        try:
            PAIRED_SENSOR_UID_SCHEMA(params)
        except vol.Invalid as err:
            raise CommandError(f"Invalid parameters provided: {err}") from None

        return await self._execute_command(Command.sensor_paired_sensor_status,
                                           params=params,
                                           silent=silent)
Exemplo n.º 6
0
    async def upgrade_firmware(
        self,
        *,
        url: Optional[str] = None,
        port: Optional[int] = None,
        filename: Optional[str] = None,
        silent: bool = True,
    ) -> Dict[str, Any]:
        """Upgrade the firmware on the device.

        :param url: The firmware file's optional URL
        :type url: ``str``
        :param port: The firmware file's optional port
        :type port: ``int``
        :param filename: The firmware file's optional filename
        :type filename: ``str``
        :param silent: If ``True``, silence "beep" tones associated with this command
        :type silent: ``bool``
        :rtype: ``dict``
        """
        params: Dict[str, Union[int, str]] = {}
        if url:
            params["url"] = url
        if port:
            params["port"] = port
        if filename:
            params["filename"] = filename

        try:
            UPGRADE_FIRMWARE_PARAM_SCHEMA(params)
        except vol.Invalid as err:
            raise CommandError(f"Invalid parameters provided: {err}") from None

        data = await self._execute_command(
            Command.system_upgrade_firmware, params=params, silent=silent
        )
        return cast(Dict[str, Any], data)