Skip to content

VeSync Air Purifiers

Contents:

pyvesync.base_devices.purifier_base.PurifierState

Bases: DeviceState

Base state class for Purifiers.

Attributes:

Name Type Description
active_time int

Active time of device, defaults to None.

connection_status str

Connection status of device.

device VeSyncOutlet

Device object.

device_status str

Device status.

features dict

Features of device.

last_update_ts int

Last update timestamp of device, defaults to None.

mode str

Current mode of the purifier.

fan_level int

Current fan level of the purifier.

fan_set_level int

Set fan level of the purifier.

filter_life int

Filter life percentage of the purifier.

auto_preference_type str

Auto preference type of the purifier.

auto_room_size int

Auto room size of the purifier.

air_quality_level AirQualityLevel

Air quality level of the purifier.

child_lock bool

Child lock status of the purifier.

display_status str

Display status of the purifier.

display_set_state str

Display set state of the purifier.

display_forever bool

Display forever status of the purifier.

timer Timer

Timer object for the purifier.

pm25 int

PM2.5 value of the purifier.

pm1 int

PM1 value of the purifier.

pm10 int

PM10 value of the purifier.

aq_percent int

Air quality percentage of the purifier.

light_detection_switch str

Light detection switch status of the purifier.

light_detection_status str

Light detection status of the purifier.

nightlight_status str

Nightlight status of the purifier.

fan_rotate_angle int

Fan rotate angle of the purifier.

Note

Not all attributes are supported by all models.

Source code in src\pyvesync\base_devices\purifier_base.py
class PurifierState(DeviceState):
    """Base state class for Purifiers.

    Attributes:
        active_time (int): Active time of device, defaults to None.
        connection_status (str): Connection status of device.
        device (VeSyncOutlet): Device object.
        device_status (str): Device status.
        features (dict): Features of device.
        last_update_ts (int): Last update timestamp of device, defaults to None.
        mode (str): Current mode of the purifier.
        fan_level (int): Current fan level of the purifier.
        fan_set_level (int): Set fan level of the purifier.
        filter_life (int): Filter life percentage of the purifier.
        auto_preference_type (str): Auto preference type of the purifier.
        auto_room_size (int): Auto room size of the purifier.
        air_quality_level (AirQualityLevel): Air quality level of the purifier.
        child_lock (bool): Child lock status of the purifier.
        display_status (str): Display status of the purifier.
        display_set_state (str): Display set state of the purifier.
        display_forever (bool): Display forever status of the purifier.
        timer (Timer): Timer object for the purifier.
        pm25 (int): PM2.5 value of the purifier.
        pm1 (int): PM1 value of the purifier.
        pm10 (int): PM10 value of the purifier.
        aq_percent (int): Air quality percentage of the purifier.
        light_detection_switch (str): Light detection switch status of the purifier.
        light_detection_status (str): Light detection status of the purifier.
        nightlight_status (str): Nightlight status of the purifier.
        fan_rotate_angle (int): Fan rotate angle of the purifier.

    Note:
        Not all attributes are supported by all models.
    """

    __slots__ = (
        "_air_quality_level",
        "aq_percent",
        "auto_preference_type",
        "auto_room_size",
        "child_lock",
        "display_forever",
        "display_set_state",
        "display_status",
        "fan_level",
        "fan_rotate_angle",
        "fan_set_level",
        "filter_life",
        "filter_open_state",
        "light_detection_status",
        "light_detection_switch",
        "mode",
        "nightlight_status",
        "pm1",
        "pm10",
        "pm25",
    )

    def __init__(
        self,
        device: VeSyncPurifier,
        details: ResponseDeviceDetailsModel,
        feature_map: PurifierMap,
    ) -> None:
        """Initialize Purifier State."""
        super().__init__(device, details, feature_map)
        self.mode: str = PurifierModes.UNKNOWN
        self.fan_level: int | None = None
        self.fan_set_level: int | None = None
        self.filter_life: int | None = None
        self.auto_preference_type: str | None = PurifierAutoPreference.UNKNOWN
        self.auto_room_size: int | None = None
        self._air_quality_level: AirQualityLevel = AirQualityLevel.UNKNOWN
        self.child_lock: bool = False
        self.filter_open_state: bool = False
        self.display_status: str = DeviceStatus.UNKNOWN
        self.display_set_state: str = DeviceStatus.UNKNOWN
        self.display_forever: bool = False
        # Attributes not supported by all purifiers
        # When update is first called, devices that support these attributes will
        # update them from NOT_SUPPORTED, whether to None or another value.
        self.pm25: int | None = IntFlag.NOT_SUPPORTED
        self.pm1: int | None = IntFlag.NOT_SUPPORTED
        self.pm10: int | None = IntFlag.NOT_SUPPORTED
        self.aq_percent: int | None = IntFlag.NOT_SUPPORTED
        self.light_detection_switch: str = StrFlag.NOT_SUPPORTED
        self.light_detection_status: str = StrFlag.NOT_SUPPORTED
        self.nightlight_status: str = StrFlag.NOT_SUPPORTED
        self.fan_rotate_angle: int | None = IntFlag.NOT_SUPPORTED

    @property
    def air_quality_level(self) -> int:
        """Return air quality level in integer from 1-4.

        Returns -1 if unknown.
        """
        if self._air_quality_level is None:
            return -1
        return int(self._air_quality_level)

    @air_quality_level.setter
    def air_quality_level(self, value: int | None) -> None:
        """Set air quality level."""
        if isinstance(value, str):
            self._air_quality_level = AirQualityLevel.from_int(value)

    def set_air_quality_level(self, value: int | str | None) -> None:
        """Set air quality level."""
        if isinstance(value, str):
            self._air_quality_level = AirQualityLevel.from_string(value)
        elif isinstance(value, int):
            self._air_quality_level = AirQualityLevel.from_int(value)

    @property
    def air_quality_string(self) -> str:
        """Return air quality level as string."""
        return str(self._air_quality_level)

    @property
    @deprecated("Use state.air_quality_level instead.")
    def air_quality(self) -> int | str | None:
        """Return air quality level."""
        return self.air_quality_level

    @property
    @deprecated("Use light_detection_switch instead.")
    def light_detection(self) -> bool:
        """Return light detection status."""
        return self.light_detection_switch == DeviceStatus.ON

    @property
    @deprecated("Use state.pm25 instead.")
    def air_quality_value(self) -> int | None:
        """Return air quality value."""
        return self.pm25

    @property
    @deprecated("Use PurifierState.fan_level instead.")
    def speed(self) -> int | None:
        """Return fan speed."""
        return self.fan_level

    @property
    @deprecated("Use PurifierState.nightlight_status instead.")
    def night_light(self) -> str:
        """Return night light status."""
        return self.nightlight_status

    @property
    @deprecated("Use display_status instead.")
    def display_state(self) -> str:
        """Return display status."""
        return self.display_status

    @property
    @deprecated("Use display_set_state instead.")
    def display_switch(self) -> str:
        """Return display switch status."""
        return self.display_set_state

Attributes

active_time instance-attribute

active_time: int | None = None

Inherited From DeviceState

air_quality property

air_quality: int | str | None

Return air quality level.

air_quality_level property writable

air_quality_level: int

Return air quality level in integer from 1-4.

Returns -1 if unknown.

air_quality_string property

air_quality_string: str

Return air quality level as string.

air_quality_value property

air_quality_value: int | None

Return air quality value.

aq_percent instance-attribute

aq_percent: int | None = NOT_SUPPORTED

auto_preference_type instance-attribute

auto_preference_type: str | None = UNKNOWN

auto_room_size instance-attribute

auto_room_size: int | None = None

child_lock instance-attribute

child_lock: bool = False

connection_status instance-attribute

connection_status: str = connectionStatus or UNKNOWN

Inherited From DeviceState

device instance-attribute

device = device

Inherited From DeviceState

device_status instance-attribute

device_status: str = deviceStatus or UNKNOWN

Inherited From DeviceState

display_forever instance-attribute

display_forever: bool = False

display_set_state instance-attribute

display_set_state: str = UNKNOWN

display_state property

display_state: str

Return display status.

display_status instance-attribute

display_status: str = UNKNOWN

display_switch property

display_switch: str

Return display switch status.

fan_level instance-attribute

fan_level: int | None = None

fan_rotate_angle instance-attribute

fan_rotate_angle: int | None = NOT_SUPPORTED

fan_set_level instance-attribute

fan_set_level: int | None = None

features instance-attribute

features = features

Inherited From DeviceState

filter_life instance-attribute

filter_life: int | None = None

filter_open_state instance-attribute

filter_open_state: bool = False

last_update_ts instance-attribute

last_update_ts: int | None = None

Inherited From DeviceState

light_detection property

light_detection: bool

Return light detection status.

light_detection_status instance-attribute

light_detection_status: str = NOT_SUPPORTED

light_detection_switch instance-attribute

light_detection_switch: str = NOT_SUPPORTED

mode instance-attribute

mode: str = UNKNOWN

night_light property

night_light: str

Return night light status.

nightlight_status instance-attribute

nightlight_status: str = NOT_SUPPORTED

pm1 instance-attribute

pm1: int | None = NOT_SUPPORTED

pm10 instance-attribute

pm10: int | None = NOT_SUPPORTED

pm25 instance-attribute

pm25: int | None = NOT_SUPPORTED

speed property

speed: int | None

Return fan speed.

timer instance-attribute

timer: Timer | None = None

Inherited From DeviceState

Functions

as_tuple

as_tuple() -> tuple[tuple[str, Any], ...]

Inherited From DeviceState

Convert state to tuple of (name, value) tuples.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def as_tuple(self) -> tuple[tuple[str, Any], ...]:
    """Convert state to tuple of (name, value) tuples."""
    return tuple((k, v) for k, v in self._serialize().items())

display

display() -> None

Inherited From DeviceState

Print formatted state to stdout.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def display(self) -> None:
    """Print formatted state to stdout."""
    for name, val in self._serialize().items():
        print(f'{name:.<30} {val}')

set_air_quality_level

set_air_quality_level(value: int | str | None) -> None

Set air quality level.

Source code in src\pyvesync\base_devices\purifier_base.py
def set_air_quality_level(self, value: int | str | None) -> None:
    """Set air quality level."""
    if isinstance(value, str):
        self._air_quality_level = AirQualityLevel.from_string(value)
    elif isinstance(value, int):
        self._air_quality_level = AirQualityLevel.from_int(value)

to_dict

to_dict() -> dict[str, Any]

Inherited From DeviceState

Convert state to dictionary.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_dict(self) -> dict[str, Any]:
    """Convert state to dictionary."""
    return self._serialize()

to_json

to_json(indent: bool = False) -> str

Inherited From DeviceState

Dump state to JSON string.

Parameters:

Name Type Description Default
indent bool

If True, indent JSON output, defaults to False.

False

Returns:

Name Type Description
str str

JSON formatted string of device state.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_json(self, indent: bool = False) -> str:
    """Dump state to JSON string.

    Args:
        indent (bool): If True, indent JSON output, defaults to False.

    Returns:
        str: JSON formatted string of device state.
    """
    return self.to_jsonb(indent=indent).decode()

to_jsonb

to_jsonb(indent: bool = False) -> bytes

Inherited From DeviceState

Convert state to JSON bytes.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_jsonb(self, indent: bool = False) -> bytes:
    """Convert state to JSON bytes."""
    if indent:
        return orjson.dumps(
            self._serialize(), option=orjson.OPT_NON_STR_KEYS | orjson.OPT_INDENT_2
        )
    return orjson.dumps(self._serialize(), option=orjson.OPT_NON_STR_KEYS)

update_ts

update_ts() -> None

Inherited From DeviceState

Update last update timestamp.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def update_ts(self) -> None:
    """Update last update timestamp."""
    self.last_update_ts = int(dt.now(
        tz=ZoneInfo(self.device.manager.time_zone)).timestamp())

pyvesync.devices.vesyncpurifier.VeSyncAirBypass

Bases: BypassV2Mixin, VeSyncPurifier

Initialize air purifier devices.

Instantiated by VeSync manager object. Inherits from VeSyncBaseDevice class. This is the primary class for most air purifiers, using the Bypass V2 API, except the original LV-PUR131S.

Parameters:

Name Type Description Default
details dict

Dictionary of device details

required
manager VeSync

Instantiated VeSync object used to make API calls

required
feature_map PurifierMap

Device map template

required

Attributes:

Name Type Description
state PurifierState

State of the device.

last_response ResponseInfo

Last response from API call.

manager VeSync

Manager object for API calls.

device_name str

Name of device.

device_image str

URL for device image.

cid str

Device ID.

connection_type str

Connection type of device.

device_type str

Type of device.

type str

Type of device.

uuid str

UUID of device, not always present.

config_module str

Configuration module of device.

mac_id str

MAC ID of device.

current_firm_version str

Current firmware version of device.

device_region str

Region of device. (US, EU, etc.)

pid str

Product ID of device, pulled by some devices on update.

sub_device_no int

Sub-device number of device.

product_type str

Product type of device.

features dict

Features of device.

modes list[str]

List of modes supported by the device.

fan_levels list[int]

List of fan levels supported by the device.

nightlight_modes list[str]

List of nightlight modes supported by the device.

auto_preferences list[str]

List of auto preferences supported by the device.

Notes

The details attribute holds device information that is updated when the update() method is called. An example of the details attribute:

    json.dumps(self.details, indent=4)
    {
        'filter_life': 0,
        'mode': 'manual',
        'level': 0,
        'display': False,
        'child_lock': False,
        'night_light': 'off',
        'air_quality': 0 # air quality level
        'air_quality_value': 0, # PM2.5 value from device,
        'display_forever': False
    }
Source code in src\pyvesync\devices\vesyncpurifier.py
class VeSyncAirBypass(BypassV2Mixin, VeSyncPurifier):
    """Initialize air purifier devices.

    Instantiated by VeSync manager object. Inherits from
    VeSyncBaseDevice class. This is the primary class for most
    air purifiers, using the Bypass V2 API, except the original LV-PUR131S.

    Parameters:
        details (dict): Dictionary of device details
        manager (VeSync): Instantiated VeSync object used to make API calls
        feature_map (PurifierMap): Device map template

    Attributes:
        state (PurifierState): State of the device.
        last_response (ResponseInfo): Last response from API call.
        manager (VeSync): Manager object for API calls.
        device_name (str): Name of device.
        device_image (str): URL for device image.
        cid (str): Device ID.
        connection_type (str): Connection type of device.
        device_type (str): Type of device.
        type (str): Type of device.
        uuid (str): UUID of device, not always present.
        config_module (str): Configuration module of device.
        mac_id (str): MAC ID of device.
        current_firm_version (str): Current firmware version of device.
        device_region (str): Region of device. (US, EU, etc.)
        pid (str): Product ID of device, pulled by some devices on update.
        sub_device_no (int): Sub-device number of device.
        product_type (str): Product type of device.
        features (dict): Features of device.
        modes (list[str]): List of modes supported by the device.
        fan_levels (list[int]): List of fan levels supported by the device.
        nightlight_modes (list[str]): List of nightlight modes supported by the device.
        auto_preferences (list[str]): List of auto preferences supported by the device.

    Notes:
        The `details` attribute holds device information that is updated when
        the `update()` method is called. An example of the `details` attribute:
    ```python
        json.dumps(self.details, indent=4)
        {
            'filter_life': 0,
            'mode': 'manual',
            'level': 0,
            'display': False,
            'child_lock': False,
            'night_light': 'off',
            'air_quality': 0 # air quality level
            'air_quality_value': 0, # PM2.5 value from device,
            'display_forever': False
        }
    ```
    """

    __slots__ = ()

    def __init__(self, details: ResponseDeviceDetailsModel,
                 manager: VeSync, feature_map: PurifierMap) -> None:
        """Initialize VeSync Air Purifier Bypass Base Class."""
        super().__init__(details, manager, feature_map)

    def _set_purifier_state(self, result: PurifierCoreDetailsResult) -> None:
        """Populate PurifierState with details from API response.

        Populates `self.state` and instance variables with device details.

        Args:
            result (InnerPurifierResult): Data model for inner result in purifier
                details response.
        """
        self.state.device_status = DeviceStatus.ON if result.enabled else DeviceStatus.OFF
        self.state.filter_life = result.filter_life or 0
        self.state.mode = result.mode
        self.state.fan_level = result.level or 0
        self.state.display_status = DeviceStatus.ON if result.display \
            else DeviceStatus.OFF
        self.state.child_lock = result.child_lock or False
        config = result.configuration
        if config is not None:
            self.state.display_set_state = DeviceStatus.ON if config.display \
                else DeviceStatus.OFF
            self.state.display_forever = config.display_forever
            if config.auto_preference is not None:
                self.state.auto_preference_type = config.auto_preference.type
                self.state.auto_room_size = config.auto_preference.room_size
        if self.supports_air_quality is True:
            self.state.pm25 = result.air_quality_value
            self.state.set_air_quality_level(result.air_quality)
        if result.night_light != StrFlag.NOT_SUPPORTED:
            self.state.nightlight_status = DeviceStatus.ON if result.night_light \
                else DeviceStatus.OFF

    async def get_details(self) -> None:
        r_dict = await self.call_bypassv2_api('getPurifierStatus')
        resp_model = process_bypassv2_result(
            self, _LOGGER, "get_details", r_dict, PurifierCoreDetailsResult
        )
        if resp_model is None:
            return
        self._set_purifier_state(resp_model)

    async def get_timer(self) -> Timer | None:
        r_bytes = await self.call_bypassv2_api('getTimer')
        resp_model = process_bypassv2_result(
            self, _LOGGER, "get_timer", r_bytes, ResultV2GetTimer
        )
        if resp_model is None:
            return None
        timers = resp_model.timers
        if not timers:
            _LOGGER.debug('No timers found')
            self.state.timer = None
            return None
        timer = timers[0]
        self.state.timer = Timer(
            timer_duration=timer.total,
            action=timer.action,
            id=timer.id,
            remaining=timer.remain,
        )
        self.state.device_status = DeviceStatus.ON
        self.state.connection_status = ConnectionStatus.ONLINE
        _LOGGER.debug("Timer found: %s", str(self.state.timer))
        return self.state.timer

    async def set_timer(self, duration: int, action: str | None = None) -> bool:
        action = DeviceStatus.OFF  # No other actions available for this device
        if self.state.device_status != DeviceStatus.ON:
            _LOGGER.debug("Can't set timer when device is off")
        # head, body = self.build_api_dict('addTimer')
        payload_data = {
            "action": str(action),
            "total": duration
        }
        r_dict = await self.call_bypassv2_api('addTimer', payload_data)
        resp_model = process_bypassv2_result(
            self, _LOGGER, "set_timer", r_dict, ResultV2SetTimer
        )
        if resp_model is None:
            return False
        self.state.timer = Timer(
                timer_duration=duration, action="off", id=resp_model.id
                )
        self.state.device_status = DeviceStatus.ON
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def clear_timer(self) -> bool:
        if self.state.timer is None:
            _LOGGER.debug('No timer to clear, run `get_timer()` to get active timer')
            return False
        payload_data = {
            "id": self.state.timer.id
        }

        r_dict = await self.call_bypassv2_api('delTimer', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "clear_timer", self, r_dict)
        if r is None:
            return False

        _LOGGER.debug("Timer cleared")
        self.state.timer = None
        self.state.device_status = DeviceStatus.ON
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def set_auto_preference(self, preference: str, room_size: int = 800) -> bool:
        if self.state.device_status != DeviceStatus.ON:
            _LOGGER.debug("Can't set auto preference when device is off")
        payload_data = {
            "type": preference,
            "room_size": room_size
        }
        r_dict = await self.call_bypassv2_api('setAutoPreference', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "set_auto_preference", self, r_dict)
        if r is None:
            return False
        self.state.connection_status = ConnectionStatus.ONLINE
        self.state.auto_preference_type = preference
        self.state.auto_room_size = room_size
        return True

    async def set_fan_speed(self, speed: None | int = None) -> bool:
        speeds: list = self.fan_levels
        current_speed = self.state.fan_level

        if speed is not None:
            if speed not in speeds:
                _LOGGER.debug(
                    "%s is invalid speed - valid speeds are %s", speed, str(speeds))
                return False
            new_speed = speed
        else:
            new_speed = Helpers.bump_level(current_speed, self.fan_levels)

        data = {
            "id": 0,
            "level": new_speed,
            "type": "wind",
        }
        r_dict = await self.call_bypassv2_api('setLevel', data)
        r = Helpers.process_dev_response(_LOGGER, "set_fan_speed", self, r_dict)
        if r is None:
            return False

        self.state.fan_level = new_speed
        self.state.mode = PurifierModes.MANUAL  # Set mode to manual to set fan speed
        self.state.device_status = DeviceStatus.ON
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def toggle_child_lock(self, toggle: bool | None = None) -> bool:
        """Toggle child lock.

        Set child lock to on or off. Internal method used by `turn_on_child_lock` and
        `turn_off_child_lock`.

        Args:
            toggle (bool): True to turn child lock on, False to turn off

        Returns:
            bool : True if child lock is set, False if not
        """
        if toggle is None:
            toggle = self.state.child_lock is False
        data = {"child_lock": toggle}

        r_dict = await self.call_bypassv2_api('setChildLock', data)
        r = Helpers.process_dev_response(_LOGGER, "toggle_child_lock", self, r_dict)
        if r is None:
            return False

        self.state.child_lock = toggle
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def reset_filter(self) -> bool:
        """Reset filter to 100%.

        Returns:
            bool : True if filter is reset, False if not
        """
        r_dict = await self.call_bypassv2_api('resetFilter')
        r = Helpers.process_dev_response(_LOGGER, "reset_filter", self, r_dict)
        return bool(r)

    @deprecated("Use set_mode(mode: str) instead.")
    async def mode_toggle(self, mode: str) -> bool:
        """Deprecated method for setting purifier mode."""
        return await self.set_mode(mode)

    async def set_mode(self, mode: str) -> bool:
        if mode.lower() not in self.modes:
            _LOGGER.debug("Invalid purifier mode used - %s", mode)
            return False

        if mode.lower() == PurifierModes.MANUAL:
            return await self.set_fan_speed(self.state.fan_level or 1)

        data = {
            "mode": mode,
        }
        r_dict = await self.call_bypassv2_api('setPurifierMode', data)

        r = Helpers.process_dev_response(_LOGGER, "set_mode", self, r_dict)
        if r is None:
            return False

        self.state.mode = mode
        self.state.device_status = DeviceStatus.ON
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def toggle_switch(self, toggle: bool | None = None) -> bool:
        if toggle is None:
            toggle = self.state.device_status != DeviceStatus.ON
        if not isinstance(toggle, bool):
            _LOGGER.debug('Invalid toggle value for purifier switch')
            return False

        data = {
            "enabled": toggle,
            "id": 0
        }
        r_dict = await self.call_bypassv2_api('setSwitch', data)
        r = Helpers.process_dev_response(_LOGGER, "toggle_switch", self, r_dict)
        if r is None:
            return False

        self.state.device_status = DeviceStatus.ON if toggle else DeviceStatus.OFF
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def toggle_display(self, mode: bool) -> bool:
        if not isinstance(mode, bool):
            _LOGGER.debug("Mode must be True or False")
            return False

        data = {
            "state": mode
        }
        r_dict = await self.call_bypassv2_api('setDisplay', data)
        r = Helpers.process_dev_response(_LOGGER, "set_display", self, r_dict)
        if r is None:
            return False
        self.state.connection_status = ConnectionStatus.ONLINE
        self.state.display_set_state = DeviceStatus.from_bool(mode)
        return True

    async def set_nightlight_mode(self, mode: str) -> bool:
        if not self.supports_nightlight:
            _LOGGER.debug("Device does not support night light")
            return False
        if mode.lower() not in self.nightlight_modes:
            _LOGGER.warning("Invalid nightlight mode used (on, off or dim)- %s", mode)
            return False

        r_dict = await self.call_bypassv2_api(
            'setNightLight', {'night_light': mode.lower()}
            )
        r = Helpers.process_dev_response(_LOGGER, "set_night_light", self, r_dict)
        if r is None:
            return False

        self.state.nightlight_status = mode
        return True

    @property
    @deprecated("Use self.state.air_quality instead.")
    def air_quality(self) -> int | None:
        """Get air quality value PM2.5 (ug/m3)."""
        return self.state.pm25

    @property
    @deprecated("Use self.state.fan_level instead.")
    def fan_level(self) -> int | None:
        """Get current fan level."""
        return self.state.fan_level

    @property
    @deprecated("Use self.state.filter_life instead.")
    def filter_life(self) -> int | None:
        """Get percentage of filter life remaining."""
        return self.state.filter_life

    @property
    @deprecated("Use self.state.display_status instead.")
    def display_state(self) -> bool:
        """Get display state.

        See [pyvesync.VeSyncAirBypass.display_status][`self.display_status`]
        """
        return self.state.display_status == DeviceStatus.ON

    @property
    @deprecated("Use self.state.display_status instead.")
    def screen_status(self) -> bool:
        """Get display status.

        Returns:
            bool : True if display is on, False if off
        """
        return self.state.display_status == DeviceStatus.ON

Attributes

air_quality property

air_quality: int | None

Inherited From VeSyncAirBypass

Get air quality value PM2.5 (ug/m3).

auto_preferences instance-attribute

auto_preferences: list[str] = auto_preferences

Inherited From VeSyncPurifier

child_lock property

child_lock: bool

Inherited From VeSyncPurifier

Get child lock state.

Returns:

Name Type Description
bool bool

True if child lock is enabled, False if not.

cid instance-attribute

cid: str = cid

Inherited From VeSyncBaseDevice

config_module instance-attribute

config_module: str = configModule

Inherited From VeSyncBaseDevice

connection_type instance-attribute

connection_type: str | None = connectionType

Inherited From VeSyncBaseDevice

current_firm_version instance-attribute

current_firm_version = currentFirmVersion

Inherited From VeSyncBaseDevice

device_image instance-attribute

device_image: str | None = deviceImg

Inherited From VeSyncBaseDevice

device_name instance-attribute

device_name: str = deviceName

Inherited From VeSyncBaseDevice

device_region instance-attribute

device_region: str | None = deviceRegion

Inherited From VeSyncBaseDevice

device_type instance-attribute

device_type: str = deviceType

Inherited From VeSyncBaseDevice

display_state property

display_state: bool

Inherited From VeSyncAirBypass

Get display state.

See [pyvesync.VeSyncAirBypass.display_status][self.display_status]

enabled instance-attribute

enabled: bool = True

Inherited From VeSyncBaseDevice

fan_level property

fan_level: int | None

Inherited From VeSyncAirBypass

Get current fan level.

fan_levels instance-attribute

fan_levels: list[int] = fan_levels

Inherited From VeSyncPurifier

features instance-attribute

features: list[str] = features

Inherited From VeSyncBaseDevice

filter_life property

filter_life: int | None

Inherited From VeSyncAirBypass

Get percentage of filter life remaining.

firmware_update property

firmware_update: bool

Inherited From VeSyncBaseDevice

Return True if firmware update available.

This is going to be updated.

is_on property

is_on: bool

Inherited From VeSyncBaseDevice

Return true if device is on.

last_response instance-attribute

last_response: ResponseInfo | None = None

Inherited From VeSyncBaseDevice

mac_id instance-attribute

mac_id: str | None = macID

Inherited From VeSyncBaseDevice

manager instance-attribute

manager: VeSync

Inherited From BypassV2Mixin

modes instance-attribute

modes: list[str] = modes

Inherited From VeSyncPurifier

night_light property

night_light: str

Inherited From VeSyncPurifier

Get night light state.

Returns:

Name Type Description
str str

Night light state (on, dim, off)

nightlight_modes instance-attribute

nightlight_modes: list[str] = nightlight_modes

Inherited From VeSyncPurifier

pid instance-attribute

pid: str | None = None

Inherited From VeSyncBaseDevice

product_type instance-attribute

product_type: str = product_type

Inherited From VeSyncBaseDevice

request_keys class-attribute

request_keys: list[str] = [
    'acceptLanguage',
    'appVersion',
    'phoneBrand',
    'phoneOS',
    'accountID',
    'cid',
    'configModule',
    'debugMode',
    'traceId',
    'timeZone',
    'token',
    'userCountryCode',
    'configModel',
    'deviceId',
]

Inherited From BypassV2Mixin

screen_status property

screen_status: bool

Inherited From VeSyncAirBypass

Get display status.

Returns:

Name Type Description
bool bool

True if display is on, False if off

state instance-attribute

state: PurifierState = PurifierState(
    self, details, feature_map
)

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_air_quality property

supports_air_quality: bool

Inherited From VeSyncPurifier

Return True if device supports air quality.

supports_fan_rotate property

supports_fan_rotate: bool

Inherited From VeSyncPurifier

Return True if device supports fan rotation.

supports_light_detection property

supports_light_detection: bool

Inherited From VeSyncPurifier

Returns True if device supports light detection.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncPurifier

Return True if device supports nightlight.

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

Functions

auto_mode async deprecated

auto_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_auto_mode instead.

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_auto_mode instead.")
async def auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    return await self.set_auto_mode()

call_bypassv2_api async

call_bypassv2_api(
    payload_method: str,
    data: dict | None = None,
    method: str = 'bypassV2',
    endpoint: str = 'bypassV2',
) -> dict | None

Inherited From BypassV2Mixin

Send Bypass V2 API request.

This uses the _build_request method to send API requests to the Bypass V2 API.

Parameters:

Name Type Description Default
payload_method str

The method to use in the payload dict.

required
data dict | None

The data to send in the request.

None
method str

The method to use in the outer body.

'bypassV2'
endpoint str | None

The last part of the API url, defaults to bypassV2, e.g. /cloud/v2/deviceManaged/bypassV2.

'bypassV2'

Returns:

Name Type Description
bytes dict | None

The response from the API request.

Source code in src\pyvesync\utils\device_mixins.py
async def call_bypassv2_api(
    self,
    payload_method: str,
    data: dict | None = None,
    method: str = "bypassV2",
    endpoint: str = "bypassV2",
) -> dict | None:
    """Send Bypass V2 API request.

    This uses the `_build_request` method to send API requests to the Bypass V2 API.

    Args:
        payload_method (str): The method to use in the payload dict.
        data (dict | None): The data to send in the request.
        method (str): The method to use in the outer body.
        endpoint (str | None): The last part of the API url, defaults to
            `bypassV2`, e.g. `/cloud/v2/deviceManaged/bypassV2`.

    Returns:
        bytes: The response from the API request.
    """
    request = self._build_request(payload_method, data, method)
    endpoint = BYPASS_V2_BASE + endpoint
    resp_dict, _ = await self.manager.async_call_api(
        endpoint, "post", request, Helpers.req_header_bypass()
    )
    return resp_dict

change_fan_speed async deprecated

change_fan_speed(speed: int | None = None) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_fan_speed() instead.

Deprecated method for changing fan speed.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_fan_speed()` instead.")
async def change_fan_speed(self, speed: int | None = None) -> bool:
    """Deprecated method for changing fan speed."""
    return await self.set_fan_speed(speed)

change_mode async deprecated

change_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_mode(mode: str) instead.

Deprecated method for changing purifier mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_mode(mode: str)` instead.")
async def change_mode(self, mode: str) -> bool:
    """Deprecated method for changing purifier mode."""
    return await self.set_mode(mode)

child_lock_off async deprecated

child_lock_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_child_lock() instead.

Turn off child lock (display lock).

This has been deprecated, use turn_off_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_off_child_lock()` instead.")
async def child_lock_off(self) -> bool:
    """Turn off child lock (display lock).

    This has been deprecated, use `turn_off_child_lock()` instead.
    """
    return await self.toggle_child_lock(False)

child_lock_on async deprecated

child_lock_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_child_lock() instead.

Turn on child lock (display lock).

This has been deprecated, use turn_on_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_on_child_lock()` instead.")
async def child_lock_on(self) -> bool:
    """Turn on child lock (display lock).

    This has been deprecated, use `turn_on_child_lock()` instead.
    """
    return await self.toggle_child_lock(True)

clear_timer async

clear_timer() -> bool

Inherited From VeSyncBaseDevice

Clear timer for device from API.

This may not be implemented for all devices. Please open an issue if there is an error.

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def clear_timer(self) -> bool:
    if self.state.timer is None:
        _LOGGER.debug('No timer to clear, run `get_timer()` to get active timer')
        return False
    payload_data = {
        "id": self.state.timer.id
    }

    r_dict = await self.call_bypassv2_api('delTimer', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "clear_timer", self, r_dict)
    if r is None:
        return False

    _LOGGER.debug("Timer cleared")
    self.state.timer = None
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

display

display(state: bool = True) -> None

Inherited From VeSyncBaseDevice

Print formatted static device info to stdout.

Parameters:

Name Type Description Default
state bool

If True, include state in display, defaults to True.

True

Example:

Device Name:..................Living Room Lamp
Model:........................ESL100
Subdevice No:.................0
Type:.........................wifi
CID:..........................1234567890abcdef

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def display(self, state: bool = True) -> None:
    """Print formatted static device info to stdout.

    Args:
        state (bool): If True, include state in display, defaults to True.

    Example:
    ```
    Device Name:..................Living Room Lamp
    Model:........................ESL100
    Subdevice No:.................0
    Type:.........................wifi
    CID:..........................1234567890abcdef
    ```
    """
    # noinspection SpellCheckingInspection
    display_list = [
        ('Device Name:', self.device_name),
        ('Product Type: ', self.product_type),
        ('Model: ', self.device_type),
        ('Subdevice No: ', str(self.sub_device_no)),
        ('Type: ', self.type),
        ('CID: ', self.cid),
        ('Config Module: ', self.config_module),
        ('Connection Type: ', self.connection_type),
        ('Features', self.features),
        ('Last Response: ', self.last_response),
    ]
    if self.uuid is not None:
        display_list.append(('UUID: ', self.uuid))

    for line in display_list:
        print(f'{line[0]:.<30} {line[1]}')
    if state:
        self.state.display()

displayJSON deprecated

displayJSON(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Deprecated

Use to_json() instead

Return JSON details for device. - Deprecated use to_json().

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
@deprecated("Use to_json() instead")
def displayJSON(self, state: bool = True, indent: bool = True) -> str:  # pylint: disable=invalid-name
    """Return JSON details for device. - Deprecated use to_json()."""
    return self.to_json(state, indent)

get_details async

get_details() -> None

Inherited From VeSyncBaseDevice

Get device details.

This method is defined in each device class to contain the logic to pull the device state from the API and update the device's state attribute. The update() method should be called to update the device state.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def get_details(self) -> None:
    r_dict = await self.call_bypassv2_api('getPurifierStatus')
    resp_model = process_bypassv2_result(
        self, _LOGGER, "get_details", r_dict, PurifierCoreDetailsResult
    )
    if resp_model is None:
        return
    self._set_purifier_state(resp_model)

get_state

get_state(state_attr: str) -> Any

Inherited From VeSyncBaseDevice

Get device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def get_state(self, state_attr: str) -> Any:  # noqa: ANN401
    """Get device state attribute."""
    return getattr(self.state, state_attr)

get_timer async

get_timer() -> Timer | None

Inherited From VeSyncBaseDevice

Get timer for device from API and set the state.Timer attribute.

This may not be implemented for all devices. Please open an issue if there is an error.

Note

This method may not be implemented for all devices. Please open an issue if there is an error.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def get_timer(self) -> Timer | None:
    r_bytes = await self.call_bypassv2_api('getTimer')
    resp_model = process_bypassv2_result(
        self, _LOGGER, "get_timer", r_bytes, ResultV2GetTimer
    )
    if resp_model is None:
        return None
    timers = resp_model.timers
    if not timers:
        _LOGGER.debug('No timers found')
        self.state.timer = None
        return None
    timer = timers[0]
    self.state.timer = Timer(
        timer_duration=timer.total,
        action=timer.action,
        id=timer.id,
        remaining=timer.remain,
    )
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    _LOGGER.debug("Timer found: %s", str(self.state.timer))
    return self.state.timer

manual_mode async deprecated

manual_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_manual_mode instead.

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_manual_mode instead.")
async def manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    return await self.set_manual_mode()

mode_toggle async deprecated

mode_toggle(mode: str) -> bool

Inherited From VeSyncAirBypass

Deprecated

Use set_mode(mode: str) instead.

Deprecated method for setting purifier mode.

Source code in src\pyvesync\devices\vesyncpurifier.py
@deprecated("Use set_mode(mode: str) instead.")
async def mode_toggle(self, mode: str) -> bool:
    """Deprecated method for setting purifier mode."""
    return await self.set_mode(mode)

nightlight_mode async deprecated

nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_nightlight_mode instead.

Set Nightlight Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_nightlight_mode instead.")
async def nightlight_mode(self, mode: str) -> bool:
    """Set Nightlight Mode."""
    return await self.set_nightlight_mode(mode)

pet_mode async deprecated

pet_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_pet_mode instead.

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_pet_mode instead.")
async def pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    return await self.set_pet_mode()

reset_filter async

reset_filter() -> bool

Inherited From VeSyncPurifier

Reset filter life.

Reset filter to 100%.

Returns:

Name Type Description
bool bool

True if filter is reset, False if not

Source code in src\pyvesync\devices\vesyncpurifier.py
async def reset_filter(self) -> bool:
    """Reset filter to 100%.

    Returns:
        bool : True if filter is reset, False if not
    """
    r_dict = await self.call_bypassv2_api('resetFilter')
    r = Helpers.process_dev_response(_LOGGER, "reset_filter", self, r_dict)
    return bool(r)

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    if PurifierModes.AUTO in self.modes:
        return await self.set_mode(PurifierModes.AUTO)
    logger.error("Auto mode not supported for this device.")
    return False

set_auto_preference async

set_auto_preference(
    preference: str, room_size: int = 800
) -> bool

Inherited From VeSyncPurifier

Set auto preference.

Parameters:

Name Type Description Default
preference str

Auto preference to set, available preference is found in self.auto_preferences.

required
room_size int

Room size to set, defaults to 800ft2.

800

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_auto_preference(self, preference: str, room_size: int = 800) -> bool:
    if self.state.device_status != DeviceStatus.ON:
        _LOGGER.debug("Can't set auto preference when device is off")
    payload_data = {
        "type": preference,
        "room_size": room_size
    }
    r_dict = await self.call_bypassv2_api('setAutoPreference', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "set_auto_preference", self, r_dict)
    if r is None:
        return False
    self.state.connection_status = ConnectionStatus.ONLINE
    self.state.auto_preference_type = preference
    self.state.auto_room_size = room_size
    return True

set_child_lock async deprecated

set_child_lock(toggle: bool) -> bool

Inherited From VeSyncPurifier

Deprecated

Use toggle_child_lock() instead.

Set child lock (display lock).

This has been deprecated in favor of toggle_child_lock().

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `toggle_child_lock()` instead.")
async def set_child_lock(self, toggle: bool) -> bool:
    """Set child lock (display lock).

    This has been deprecated in favor of `toggle_child_lock()`.
    """
    return await self.toggle_child_lock(toggle)

set_fan_speed async

set_fan_speed(speed: None | int = None) -> bool

Inherited From VeSyncPurifier

Set Purifier Fan Speed.

Parameters:

Name Type Description Default
speed int | None

Fan speed to set. If None, use default speed.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_fan_speed(self, speed: None | int = None) -> bool:
    speeds: list = self.fan_levels
    current_speed = self.state.fan_level

    if speed is not None:
        if speed not in speeds:
            _LOGGER.debug(
                "%s is invalid speed - valid speeds are %s", speed, str(speeds))
            return False
        new_speed = speed
    else:
        new_speed = Helpers.bump_level(current_speed, self.fan_levels)

    data = {
        "id": 0,
        "level": new_speed,
        "type": "wind",
    }
    r_dict = await self.call_bypassv2_api('setLevel', data)
    r = Helpers.process_dev_response(_LOGGER, "set_fan_speed", self, r_dict)
    if r is None:
        return False

    self.state.fan_level = new_speed
    self.state.mode = PurifierModes.MANUAL  # Set mode to manual to set fan speed
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_light_detection_off async deprecated

set_light_detection_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_light_detection() instead.

Turn off light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_off_light_detection() instead.")
async def set_light_detection_off(self) -> bool:
    """Turn off light detection feature."""
    return await self.toggle_light_detection(False)

set_light_detection_on async deprecated

set_light_detection_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_light_detection() instead.

Turn on light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_on_light_detection() instead.")
async def set_light_detection_on(self) -> bool:
    """Turn on light detection feature."""
    return await self.toggle_light_detection(True)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    if PurifierModes.MANUAL in self.modes:
        return await self.set_mode(PurifierModes.MANUAL)
    logger.error("Manual mode not supported for this device.")
    return False

set_mode async

set_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Set Purifier Mode.

Allowed modes are found in the device.modes attribute.

Parameters:

Name Type Description Default
mode str

Mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_mode(self, mode: str) -> bool:
    if mode.lower() not in self.modes:
        _LOGGER.debug("Invalid purifier mode used - %s", mode)
        return False

    if mode.lower() == PurifierModes.MANUAL:
        return await self.set_fan_speed(self.state.fan_level or 1)

    data = {
        "mode": mode,
    }
    r_dict = await self.call_bypassv2_api('setPurifierMode', data)

    r = Helpers.process_dev_response(_LOGGER, "set_mode", self, r_dict)
    if r is None:
        return False

    self.state.mode = mode
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_nightlight_dim async

set_nightlight_dim() -> bool

Inherited From VeSyncPurifier

Set Nightlight Dim.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_nightlight_dim(self) -> bool:
    """Set Nightlight Dim."""
    return await self.set_nightlight_mode(NightlightModes.DIM)

set_nightlight_mode async

set_nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Set Nightlight Mode.

Modes are defined in the device.nightlight_modes attribute.

Parameters:

Name Type Description Default
mode str

Nightlight mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_nightlight_mode(self, mode: str) -> bool:
    if not self.supports_nightlight:
        _LOGGER.debug("Device does not support night light")
        return False
    if mode.lower() not in self.nightlight_modes:
        _LOGGER.warning("Invalid nightlight mode used (on, off or dim)- %s", mode)
        return False

    r_dict = await self.call_bypassv2_api(
        'setNightLight', {'night_light': mode.lower()}
        )
    r = Helpers.process_dev_response(_LOGGER, "set_night_light", self, r_dict)
    if r is None:
        return False

    self.state.nightlight_status = mode
    return True

set_pet_mode async

set_pet_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    if PurifierModes.PET in self.modes:
        return await self.set_mode(PurifierModes.PET)
    logger.error("Pet mode not supported for this device.")
    return False

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    if PurifierModes.SLEEP in self.modes:
        return await self.set_mode(PurifierModes.SLEEP)
    logger.error("Sleep mode not supported for this device.")
    return False

set_state

set_state(state_attr: str, stat_value: Any) -> None

Inherited From VeSyncBaseDevice

Set device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def set_state(self, state_attr: str, stat_value: Any) -> None:  # noqa: ANN401
    """Set device state attribute."""
    setattr(self, state_attr, stat_value)

set_timer async

set_timer(duration: int, action: str | None = None) -> bool

Inherited From VeSyncBaseDevice

Set timer for device.

This may not be implemented for all devices. Please open an issue if there is an error.

Parameters:

Name Type Description Default
duration int

Duration in seconds.

required
action str | None

Action to take when timer expires.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    action = DeviceStatus.OFF  # No other actions available for this device
    if self.state.device_status != DeviceStatus.ON:
        _LOGGER.debug("Can't set timer when device is off")
    # head, body = self.build_api_dict('addTimer')
    payload_data = {
        "action": str(action),
        "total": duration
    }
    r_dict = await self.call_bypassv2_api('addTimer', payload_data)
    resp_model = process_bypassv2_result(
        self, _LOGGER, "set_timer", r_dict, ResultV2SetTimer
    )
    if resp_model is None:
        return False
    self.state.timer = Timer(
            timer_duration=duration, action="off", id=resp_model.id
            )
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_turbo_mode async

set_turbo_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    if PurifierModes.TURBO in self.modes:
        return await self.set_mode(PurifierModes.TURBO)
    logger.error("Turbo mode not supported for this device.")
    return False

sleep_mode async deprecated

sleep_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_sleep_mode instead.

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_sleep_mode instead.")
async def sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    return await self.set_sleep_mode()

to_dict

to_dict(state: bool = True) -> dict[str, Any]

Inherited From VeSyncBaseDevice

Return device information as a dictionary.

Parameters:

Name Type Description Default
state bool

If True, include state in dictionary, defaults to True.

True

Returns:

Type Description
dict[str, Any]

dict[str, Any]: Dictionary containing device information.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_dict(self, state: bool = True) -> dict[str, Any]:
    """Return device information as a dictionary.

    Args:
        state (bool): If True, include state in dictionary, defaults to True.

    Returns:
        dict[str, Any]: Dictionary containing device information.
    """
    device_dict = {
        "device_name": self.device_name,
        "product_type": self.product_type,
        "model": self.device_type,
        "subdevice_no": str(self.sub_device_no),
        "type": self.type,
        "cid": self.cid,
        "features:": self.features,
        "config_module": self.config_module,
        "connection_type": self.connection_type,
        "last_response": self.last_response,
    }
    state_dict = self.state.to_dict() if state else {}
    return device_dict | state_dict

to_json

to_json(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Print JSON API string for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
str str

JSON formatted string of device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_json(self, state: bool = True, indent: bool = True) -> str:
    """Print JSON API string for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        str: JSON formatted string of device details.
    """
    return self.to_jsonb(state, indent).decode()

to_jsonb

to_jsonb(state: bool = True, indent: bool = True) -> bytes

Inherited From VeSyncBaseDevice

JSON API bytes for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
bytes bytes

JSON formatted bytes of device details.

Example

This is an example without state.

{
    "Device Name": "Living Room Lamp",
    "Model": "ESL100",
    "Subdevice No": "0",
    "Type": "wifi",
    "CID": "1234567890abcdef"
}

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_jsonb(self, state: bool = True, indent: bool = True) -> bytes:
    """JSON API bytes for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        bytes: JSON formatted bytes of device details.

    Example:
        This is an example without state.
        ```
        {
            "Device Name": "Living Room Lamp",
            "Model": "ESL100",
            "Subdevice No": "0",
            "Type": "wifi",
            "CID": "1234567890abcdef"
        }
        ```
    """
    return_dict = self.to_dict(state=state)
    if indent:
        return orjson.dumps(
            return_dict,
            option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS,
        )

    return orjson.dumps(return_dict, option=orjson.OPT_NON_STR_KEYS)

toggle_child_lock async

toggle_child_lock(toggle: bool | None = None) -> bool

Inherited From VeSyncPurifier

Toggle Child Lock (Display Lock).

Parameters:

Name Type Description Default
toggle bool | None

Toggle child lock. If None, toggle state.

None

Toggle child lock.

Set child lock to on or off. Internal method used by turn_on_child_lock and turn_off_child_lock.

Parameters:

Name Type Description Default
toggle bool

True to turn child lock on, False to turn off

None

Returns:

Name Type Description
bool bool

True if child lock is set, False if not

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_child_lock(self, toggle: bool | None = None) -> bool:
    """Toggle child lock.

    Set child lock to on or off. Internal method used by `turn_on_child_lock` and
    `turn_off_child_lock`.

    Args:
        toggle (bool): True to turn child lock on, False to turn off

    Returns:
        bool : True if child lock is set, False if not
    """
    if toggle is None:
        toggle = self.state.child_lock is False
    data = {"child_lock": toggle}

    r_dict = await self.call_bypassv2_api('setChildLock', data)
    r = Helpers.process_dev_response(_LOGGER, "toggle_child_lock", self, r_dict)
    if r is None:
        return False

    self.state.child_lock = toggle
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_display async

toggle_display(mode: bool) -> bool

Inherited From VeSyncPurifier

Set Display Mode.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_display(self, mode: bool) -> bool:
    if not isinstance(mode, bool):
        _LOGGER.debug("Mode must be True or False")
        return False

    data = {
        "state": mode
    }
    r_dict = await self.call_bypassv2_api('setDisplay', data)
    r = Helpers.process_dev_response(_LOGGER, "set_display", self, r_dict)
    if r is None:
        return False
    self.state.connection_status = ConnectionStatus.ONLINE
    self.state.display_set_state = DeviceStatus.from_bool(mode)
    return True

toggle_light_detection async

toggle_light_detection(toggle: bool | None = None) -> bool

Inherited From VeSyncPurifier

Set Light Detection Mode.

Parameters:

Name Type Description Default
toggle bool | None

Toggle light detection. If None, toggle state.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
async def toggle_light_detection(self, toggle: bool | None = None) -> bool:
    """Set Light Detection Mode.

    Args:
        toggle (bool | None): Toggle light detection. If None, toggle state.

    Returns:
        bool: True if successful, False otherwise.
    """
    del toggle
    if not self.supports_light_detection:
        logger.debug("Light detection not supported for this device.")
    else:
        logger.debug("Light detection not configured for this device.")
    return False

toggle_switch async

toggle_switch(toggle: bool | None = None) -> bool

Inherited From VeSyncBaseToggleDevice

Toggle device power on or off.

Parameters:

Name Type Description Default
toggle bool | None

True to turn on, False to turn off, None to toggle.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.device_status != DeviceStatus.ON
    if not isinstance(toggle, bool):
        _LOGGER.debug('Invalid toggle value for purifier switch')
        return False

    data = {
        "enabled": toggle,
        "id": 0
    }
    r_dict = await self.call_bypassv2_api('setSwitch', data)
    r = Helpers.process_dev_response(_LOGGER, "toggle_switch", self, r_dict)
    if r is None:
        return False

    self.state.device_status = DeviceStatus.ON if toggle else DeviceStatus.OFF
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

turbo_mode async deprecated

turbo_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_turbo_mode instead.

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_turbo_mode instead.")
async def turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    return await self.set_turbo_mode()

turn_off async

turn_off() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device off.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_off(self) -> bool:
    """Turn device off."""
    return await self.toggle_switch(False)

turn_off_child_lock async

turn_off_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to OFF.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_child_lock(self) -> bool:
    """Set child lock (display lock) to OFF."""
    return await self.toggle_child_lock(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncPurifier

Turn off Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off Display."""
    return await self.toggle_display(False)

turn_off_light_detection async

turn_off_light_detection() -> bool

Inherited From VeSyncPurifier

Turn off Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_light_detection(self) -> bool:
    """Turn off Light Detection."""
    return await self.toggle_light_detection(False)

turn_off_nightlight async

turn_off_nightlight() -> bool

Inherited From VeSyncPurifier

Turn off Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_nightlight(self) -> bool:
    """Turn off Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.OFF)

turn_on async

turn_on() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device on.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_on(self) -> bool:
    """Turn device on."""
    return await self.toggle_switch(True)

turn_on_child_lock async

turn_on_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to ON.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_child_lock(self) -> bool:
    """Set child lock (display lock) to ON."""
    return await self.toggle_child_lock(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncPurifier

Turn on Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on Display."""
    return await self.toggle_display(True)

turn_on_light_detection async

turn_on_light_detection() -> bool

Inherited From VeSyncPurifier

Turn on Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_light_detection(self) -> bool:
    """Turn on Light Detection."""
    return await self.toggle_light_detection(True)

turn_on_nightlight async

turn_on_nightlight() -> bool

Inherited From VeSyncPurifier

Turn on Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_nightlight(self) -> bool:
    """Turn on Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.ON)

update async

update() -> None

Inherited From VeSyncBaseDevice

Update device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def update(self) -> None:
    """Update device details."""
    await self.get_details()

pyvesync.devices.vesyncpurifier.VeSyncAirBaseV2

Bases: VeSyncAirBypass

Levoit V2 Air Purifier Class.

Inherits from VeSyncAirBypass and VeSyncBaseDevice class. For newer devices that use camel-case API calls.

Parameters:

Name Type Description Default
details dict

Dictionary of device details

required
manager VeSync

Instantiated VeSync object

required
feature_map PurifierMap

Device map template

required

Attributes:

Name Type Description
state PurifierState

State of the device.

last_response ResponseInfo

Last response from API call.

manager VeSync

Manager object for API calls.

device_name str

Name of device.

device_image str

URL for device image.

cid str

Device ID.

connection_type str

Connection type of device.

device_type str

Type of device.

type str

Type of device.

uuid str

UUID of device, not always present.

config_module str

Configuration module of device.

mac_id str

MAC ID of device.

current_firm_version str

Current firmware version of device.

device_region str

Region of device. (US, EU, etc.)

pid str

Product ID of device, pulled by some devices on update.

sub_device_no int

Sub-device number of device.

product_type str

Product type of device.

features dict

Features of device.

modes list[str]

List of modes supported by the device.

fan_levels list[int]

List of fan levels supported by the device.

nightlight_modes list[str]

List of nightlight modes supported by the device.

auto_preferences list[str]

List of auto preferences supported by the device.

Source code in src\pyvesync\devices\vesyncpurifier.py
class VeSyncAirBaseV2(VeSyncAirBypass):
    """Levoit V2 Air Purifier Class.

    Inherits from VeSyncAirBypass and VeSyncBaseDevice class. For
    newer devices that use camel-case API calls.

    Args:
        details (dict): Dictionary of device details
        manager (VeSync): Instantiated VeSync object
        feature_map (PurifierMap): Device map template

    Attributes:
        state (PurifierState): State of the device.
        last_response (ResponseInfo): Last response from API call.
        manager (VeSync): Manager object for API calls.
        device_name (str): Name of device.
        device_image (str): URL for device image.
        cid (str): Device ID.
        connection_type (str): Connection type of device.
        device_type (str): Type of device.
        type (str): Type of device.
        uuid (str): UUID of device, not always present.
        config_module (str): Configuration module of device.
        mac_id (str): MAC ID of device.
        current_firm_version (str): Current firmware version of device.
        device_region (str): Region of device. (US, EU, etc.)
        pid (str): Product ID of device, pulled by some devices on update.
        sub_device_no (int): Sub-device number of device.
        product_type (str): Product type of device.
        features (dict): Features of device.
        modes (list[str]): List of modes supported by the device.
        fan_levels (list[int]): List of fan levels supported by the device.
        nightlight_modes (list[str]): List of nightlight modes supported by the device.
        auto_preferences (list[str]): List of auto preferences supported by the device.
    """

    __slots__ = ()

    def __init__(
        self,
        details: ResponseDeviceDetailsModel,
        manager: VeSync,
        feature_map: PurifierMap,
    ) -> None:
        """Initialize the VeSync Base API V2 Air Purifier Class."""
        super().__init__(details, manager, feature_map)

    def _set_state(self, details: PurifierV2DetailsResult) -> None:
        """Set Purifier state from details response."""
        self.state.connection_status = ConnectionStatus.ONLINE
        self.state.device_status = DeviceStatus.from_int(details.powerSwitch)
        self.state.mode = details.workMode
        self.state.filter_life = details.filterLifePercent
        if details.fanSpeedLevel == 255:
            self.state.fan_level = 0
        else:
            self.state.fan_level = details.fanSpeedLevel
        self.state.fan_set_level = details.manualSpeedLevel
        self.state.child_lock = bool(details.childLockSwitch)
        self.state.air_quality_level = details.AQLevel
        self.state.pm25 = details.PM25
        self.state.light_detection_switch = DeviceStatus.from_int(
            details.lightDetectionSwitch
            )
        self.state.light_detection_status = DeviceStatus.from_int(
            details.environmentLightState
            )
        self.state.display_set_state = DeviceStatus.from_int(details.screenSwitch)
        self.state.display_status = DeviceStatus.from_int(details.screenState)
        auto_pref = details.autoPreference
        if auto_pref is not None:
            self.state.auto_preference_type = auto_pref.autoPreferenceType
            self.state.auto_room_size = auto_pref.roomSize

        self.state.pm1 = details.PM1
        self.state.pm10 = details.PM10
        self.state.aq_percent = details.AQPercent
        self.state.fan_rotate_angle = details.fanRotateAngle
        if details.filterOpenState != IntFlag.NOT_SUPPORTED:
            self.state.filter_open_state = bool(details.filterOpenState)
        if details.timerRemain > 0:
            self.state.timer = Timer(details.timerRemain, 'off')

    @property
    @deprecated("Use self.state.fan_set_level instead.")
    def set_speed_level(self) -> int | None:
        """Get set speed level."""
        return self.state.fan_set_level

    @property
    @deprecated("Use self.state.light_detection_switch, this returns 'on' or 'off")
    def light_detection(self) -> bool:
        """Return true if light detection feature is enabled."""
        return self.state.light_detection_switch == DeviceStatus.ON

    @property
    @deprecated("Use self.state.light_detection_status, this returns 'on' or 'off'")
    def light_detection_state(self) -> bool:
        """Return true if light is detected."""
        return self.state.light_detection_status == DeviceStatus.ON

    async def get_details(self) -> None:
        """Build API V2 Purifier details dictionary."""
        r_dict = await self.call_bypassv2_api('getPurifierStatus')
        r_model = process_bypassv2_result(
            self, _LOGGER, "get_details", r_dict, PurifierV2DetailsResult
        )
        if r_model is None:
            return

        self._set_state(r_model)

    @deprecated("Use toggle_light_detection(toggle) instead.")
    async def set_light_detection(self, toggle: bool) -> bool:
        """Set light detection feature."""
        return await self.toggle_light_detection(toggle)

    async def toggle_light_detection(self, toggle: bool | None = None) -> bool:
        """Enable/Disable Light Detection Feature."""
        if toggle is None:
            toggle = not bool(self.state.light_detection_status)
        payload_data = {"lightDetectionSwitch": int(toggle)}
        r_dict = await self.call_bypassv2_api('setLightDetection', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "set_light_detection", self, r_dict)
        if r is None:
            return False

        self.state.light_detection_switch = DeviceStatus.ON if toggle \
            else DeviceStatus.OFF
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def toggle_switch(self, toggle: bool | None = None) -> bool:
        if toggle is None:
            toggle = not bool(self.state.device_status)
        if not isinstance(toggle, bool):
            _LOGGER.debug('Invalid toggle value for purifier switch')
            return False
        if toggle == bool(self.state.device_status):
            _LOGGER.debug('Purifier is already %s', self.state.device_status)
            return True

        payload_data = {
                'powerSwitch': int(toggle),
                'switchIdx': 0
            }
        r_dict = await self.call_bypassv2_api('setSwitch', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "toggle_switch", self, r_dict)
        if r is None:
            return False

        self.state.device_status = DeviceStatus.from_bool(toggle)
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def toggle_child_lock(self, toggle: bool | None = None) -> bool:
        """Levoit 100S/200S set Child Lock.

        Parameters:
            toggle (bool): True to turn child lock on, False to turn off

        Returns:
            bool : True if successful, False if not
        """
        if toggle is None:
            toggle = not bool(self.state.child_lock)
        payload_data = {'childLockSwitch': int(toggle)}
        r_dict = await self.call_bypassv2_api('setChildLock', payload_data)

        r = Helpers.process_dev_response(_LOGGER, "toggle_child_lock", self, r_dict)
        if r is None:
            return False

        self.state.child_lock = toggle
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def toggle_display(self, mode: bool) -> bool:
        if bool(self.state.display_set_state) == mode:
            _LOGGER.debug('Display is already %s', mode)
            return True

        payload_data = {
            'screenSwitch': int(mode)
        }
        r_dict = await self.call_bypassv2_api('setDisplay', payload_data)

        r = Helpers.process_dev_response(_LOGGER, "set_display", self, r_dict)
        if r is None:
            return False

        self.state.display_set_state = DeviceStatus.from_bool(mode)
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def set_timer(
        self, duration: int, action: str | None = None
    ) -> bool:
        action = DeviceStatus.OFF  # No other actions available for this device
        if action not in [DeviceStatus.ON, DeviceStatus.OFF]:
            _LOGGER.debug('Invalid action for timer')
            return False

        method = 'powerSwitch'
        action_int = 1 if action == DeviceStatus.ON else 0
        action_item = PurifierV2TimerActionItems(type=method, act=action_int)
        timing = PurifierV2EventTiming(clkSec=duration)
        payload_data = PurifierV2TimerPayloadData(
            enabled=True, startAct=[action_item], tmgEvt=timing,
        )

        r_dict = await self.call_bypassv2_api('addTimerV2', payload_data.to_dict())
        r = Helpers.process_dev_response(_LOGGER, "set_timer", self, r_dict)
        if r is None:
            return False

        r_model = ResultV2SetTimer.from_dict(r)

        self.state.timer = Timer(duration, action=action, id=r_model.id)
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def clear_timer(self) -> bool:
        if self.state.timer is None:
            _LOGGER.warning("No timer found, run get_timer() to retrieve timer.")
            return False

        payload_data = {
            "id": self.state.timer.id,
            "subDeviceNo": 0
        }
        r_dict = await self.call_bypassv2_api('delTimerV2', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "clear_timer", self, r_dict)
        if r is None:
            return False

        self.state.timer = None
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def set_auto_preference(self, preference: str = PurifierAutoPreference.DEFAULT,
                                  room_size: int = 600) -> bool:
        """Set Levoit Vital 100S/200S auto mode.

        Parameters:
            preference (str | None | PurifierAutoPreference):
                Preference for auto mode, default 'default' (default, efficient, quiet)
            room_size (int | None):
                Room size in square feet, by default 600
        """
        if preference not in self.auto_preferences:
            _LOGGER.debug(
                "%s is invalid preference -"
                " valid preferences are default, efficient, quiet",
                preference,
            )
            return False
        payload_data = {
            "autoPreference": preference,
            "roomSize": room_size
        }
        r_dict = await self.call_bypassv2_api('setAutoPreference', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "set_auto_preference", self, r_dict)
        if r is None:
            return False

        self.state.auto_preference_type = preference
        self.state.auto_room_size = room_size
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def set_fan_speed(self, speed: None | int = None) -> bool:
        if speed is not None:
            if speed not in self.fan_levels:
                _LOGGER.debug(
                    "%s is invalid speed - valid speeds are %s",
                    speed,
                    str(self.fan_levels),
                )
                return False
            new_speed = speed
        elif self.state.fan_level is None:
            new_speed = self.fan_levels[0]
        else:
            new_speed = Helpers.bump_level(self.state.fan_level, self.fan_levels)

        payload_data = {
            "levelIdx": 0,
            "manualSpeedLevel": new_speed,
            "levelType": "wind"
        }
        r_dict = await self.call_bypassv2_api('setLevel', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "set_fan_speed", self, r_dict)
        if r is None:
            return False

        self.state.fan_set_level = new_speed
        self.state.mode = PurifierModes.MANUAL
        self.state.device_status = DeviceStatus.ON
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def set_mode(self, mode: str) -> bool:
        if mode.lower() not in self.modes:
            _LOGGER.debug("Invalid purifier mode used - %s", mode)
            return False

        # Call change_fan_speed if mode is set to manual
        if mode == PurifierModes.MANUAL:
            if self.state.fan_set_level is None or self.state.fan_level == 0:
                return await self.set_fan_speed(1)
            return await self.set_fan_speed(self.state.fan_set_level)

        payload_data = {
            "workMode": mode
        }
        r_dict = await self.call_bypassv2_api('setPurifierMode', payload_data)
        r = Helpers.process_dev_response(_LOGGER, "mode_toggle", self, r_dict)
        if r is None:
            return False

        self.state.mode = mode
        self.state.connection_status = ConnectionStatus.ONLINE
        self.state.device_status = DeviceStatus.ON
        return True

Attributes

air_quality property

air_quality: int | None

Inherited From VeSyncAirBypass

Get air quality value PM2.5 (ug/m3).

auto_preferences instance-attribute

auto_preferences: list[str] = auto_preferences

Inherited From VeSyncPurifier

child_lock property

child_lock: bool

Inherited From VeSyncPurifier

Get child lock state.

Returns:

Name Type Description
bool bool

True if child lock is enabled, False if not.

cid instance-attribute

cid: str = cid

Inherited From VeSyncBaseDevice

config_module instance-attribute

config_module: str = configModule

Inherited From VeSyncBaseDevice

connection_type instance-attribute

connection_type: str | None = connectionType

Inherited From VeSyncBaseDevice

current_firm_version instance-attribute

current_firm_version = currentFirmVersion

Inherited From VeSyncBaseDevice

device_image instance-attribute

device_image: str | None = deviceImg

Inherited From VeSyncBaseDevice

device_name instance-attribute

device_name: str = deviceName

Inherited From VeSyncBaseDevice

device_region instance-attribute

device_region: str | None = deviceRegion

Inherited From VeSyncBaseDevice

device_type instance-attribute

device_type: str = deviceType

Inherited From VeSyncBaseDevice

display_state property

display_state: bool

Inherited From VeSyncAirBypass

Get display state.

See [pyvesync.VeSyncAirBypass.display_status][self.display_status]

enabled instance-attribute

enabled: bool = True

Inherited From VeSyncBaseDevice

fan_level property

fan_level: int | None

Inherited From VeSyncAirBypass

Get current fan level.

fan_levels instance-attribute

fan_levels: list[int] = fan_levels

Inherited From VeSyncPurifier

features instance-attribute

features: list[str] = features

Inherited From VeSyncBaseDevice

filter_life property

filter_life: int | None

Inherited From VeSyncAirBypass

Get percentage of filter life remaining.

firmware_update property

firmware_update: bool

Inherited From VeSyncBaseDevice

Return True if firmware update available.

This is going to be updated.

is_on property

is_on: bool

Inherited From VeSyncBaseDevice

Return true if device is on.

last_response instance-attribute

last_response: ResponseInfo | None = None

Inherited From VeSyncBaseDevice

light_detection property

light_detection: bool

Return true if light detection feature is enabled.

light_detection_state property

light_detection_state: bool

Return true if light is detected.

mac_id instance-attribute

mac_id: str | None = macID

Inherited From VeSyncBaseDevice

manager instance-attribute

manager: VeSync

Inherited From BypassV2Mixin

modes instance-attribute

modes: list[str] = modes

Inherited From VeSyncPurifier

night_light property

night_light: str

Inherited From VeSyncPurifier

Get night light state.

Returns:

Name Type Description
str str

Night light state (on, dim, off)

nightlight_modes instance-attribute

nightlight_modes: list[str] = nightlight_modes

Inherited From VeSyncPurifier

pid instance-attribute

pid: str | None = None

Inherited From VeSyncBaseDevice

product_type instance-attribute

product_type: str = product_type

Inherited From VeSyncBaseDevice

request_keys class-attribute

request_keys: list[str] = [
    'acceptLanguage',
    'appVersion',
    'phoneBrand',
    'phoneOS',
    'accountID',
    'cid',
    'configModule',
    'debugMode',
    'traceId',
    'timeZone',
    'token',
    'userCountryCode',
    'configModel',
    'deviceId',
]

Inherited From BypassV2Mixin

screen_status property

screen_status: bool

Inherited From VeSyncAirBypass

Get display status.

Returns:

Name Type Description
bool bool

True if display is on, False if off

set_speed_level property

set_speed_level: int | None

Get set speed level.

state instance-attribute

state: PurifierState = PurifierState(
    self, details, feature_map
)

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_air_quality property

supports_air_quality: bool

Inherited From VeSyncPurifier

Return True if device supports air quality.

supports_fan_rotate property

supports_fan_rotate: bool

Inherited From VeSyncPurifier

Return True if device supports fan rotation.

supports_light_detection property

supports_light_detection: bool

Inherited From VeSyncPurifier

Returns True if device supports light detection.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncPurifier

Return True if device supports nightlight.

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

Functions

auto_mode async deprecated

auto_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_auto_mode instead.

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_auto_mode instead.")
async def auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    return await self.set_auto_mode()

call_bypassv2_api async

call_bypassv2_api(
    payload_method: str,
    data: dict | None = None,
    method: str = 'bypassV2',
    endpoint: str = 'bypassV2',
) -> dict | None

Inherited From BypassV2Mixin

Send Bypass V2 API request.

This uses the _build_request method to send API requests to the Bypass V2 API.

Parameters:

Name Type Description Default
payload_method str

The method to use in the payload dict.

required
data dict | None

The data to send in the request.

None
method str

The method to use in the outer body.

'bypassV2'
endpoint str | None

The last part of the API url, defaults to bypassV2, e.g. /cloud/v2/deviceManaged/bypassV2.

'bypassV2'

Returns:

Name Type Description
bytes dict | None

The response from the API request.

Source code in src\pyvesync\utils\device_mixins.py
async def call_bypassv2_api(
    self,
    payload_method: str,
    data: dict | None = None,
    method: str = "bypassV2",
    endpoint: str = "bypassV2",
) -> dict | None:
    """Send Bypass V2 API request.

    This uses the `_build_request` method to send API requests to the Bypass V2 API.

    Args:
        payload_method (str): The method to use in the payload dict.
        data (dict | None): The data to send in the request.
        method (str): The method to use in the outer body.
        endpoint (str | None): The last part of the API url, defaults to
            `bypassV2`, e.g. `/cloud/v2/deviceManaged/bypassV2`.

    Returns:
        bytes: The response from the API request.
    """
    request = self._build_request(payload_method, data, method)
    endpoint = BYPASS_V2_BASE + endpoint
    resp_dict, _ = await self.manager.async_call_api(
        endpoint, "post", request, Helpers.req_header_bypass()
    )
    return resp_dict

change_fan_speed async deprecated

change_fan_speed(speed: int | None = None) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_fan_speed() instead.

Deprecated method for changing fan speed.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_fan_speed()` instead.")
async def change_fan_speed(self, speed: int | None = None) -> bool:
    """Deprecated method for changing fan speed."""
    return await self.set_fan_speed(speed)

change_mode async deprecated

change_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_mode(mode: str) instead.

Deprecated method for changing purifier mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_mode(mode: str)` instead.")
async def change_mode(self, mode: str) -> bool:
    """Deprecated method for changing purifier mode."""
    return await self.set_mode(mode)

child_lock_off async deprecated

child_lock_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_child_lock() instead.

Turn off child lock (display lock).

This has been deprecated, use turn_off_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_off_child_lock()` instead.")
async def child_lock_off(self) -> bool:
    """Turn off child lock (display lock).

    This has been deprecated, use `turn_off_child_lock()` instead.
    """
    return await self.toggle_child_lock(False)

child_lock_on async deprecated

child_lock_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_child_lock() instead.

Turn on child lock (display lock).

This has been deprecated, use turn_on_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_on_child_lock()` instead.")
async def child_lock_on(self) -> bool:
    """Turn on child lock (display lock).

    This has been deprecated, use `turn_on_child_lock()` instead.
    """
    return await self.toggle_child_lock(True)

clear_timer async

clear_timer() -> bool

Inherited From VeSyncAirBypass

Clear timer for device from API.

This may not be implemented for all devices. Please open an issue if there is an error.

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def clear_timer(self) -> bool:
    if self.state.timer is None:
        _LOGGER.warning("No timer found, run get_timer() to retrieve timer.")
        return False

    payload_data = {
        "id": self.state.timer.id,
        "subDeviceNo": 0
    }
    r_dict = await self.call_bypassv2_api('delTimerV2', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "clear_timer", self, r_dict)
    if r is None:
        return False

    self.state.timer = None
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

display

display(state: bool = True) -> None

Inherited From VeSyncBaseDevice

Print formatted static device info to stdout.

Parameters:

Name Type Description Default
state bool

If True, include state in display, defaults to True.

True

Example:

Device Name:..................Living Room Lamp
Model:........................ESL100
Subdevice No:.................0
Type:.........................wifi
CID:..........................1234567890abcdef

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def display(self, state: bool = True) -> None:
    """Print formatted static device info to stdout.

    Args:
        state (bool): If True, include state in display, defaults to True.

    Example:
    ```
    Device Name:..................Living Room Lamp
    Model:........................ESL100
    Subdevice No:.................0
    Type:.........................wifi
    CID:..........................1234567890abcdef
    ```
    """
    # noinspection SpellCheckingInspection
    display_list = [
        ('Device Name:', self.device_name),
        ('Product Type: ', self.product_type),
        ('Model: ', self.device_type),
        ('Subdevice No: ', str(self.sub_device_no)),
        ('Type: ', self.type),
        ('CID: ', self.cid),
        ('Config Module: ', self.config_module),
        ('Connection Type: ', self.connection_type),
        ('Features', self.features),
        ('Last Response: ', self.last_response),
    ]
    if self.uuid is not None:
        display_list.append(('UUID: ', self.uuid))

    for line in display_list:
        print(f'{line[0]:.<30} {line[1]}')
    if state:
        self.state.display()

displayJSON deprecated

displayJSON(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Deprecated

Use to_json() instead

Return JSON details for device. - Deprecated use to_json().

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
@deprecated("Use to_json() instead")
def displayJSON(self, state: bool = True, indent: bool = True) -> str:  # pylint: disable=invalid-name
    """Return JSON details for device. - Deprecated use to_json()."""
    return self.to_json(state, indent)

get_details async

get_details() -> None

Inherited From VeSyncAirBypass

Get device details.

This method is defined in each device class to contain the logic to pull the device state from the API and update the device's state attribute. The update() method should be called to update the device state.

Build API V2 Purifier details dictionary.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def get_details(self) -> None:
    """Build API V2 Purifier details dictionary."""
    r_dict = await self.call_bypassv2_api('getPurifierStatus')
    r_model = process_bypassv2_result(
        self, _LOGGER, "get_details", r_dict, PurifierV2DetailsResult
    )
    if r_model is None:
        return

    self._set_state(r_model)

get_state

get_state(state_attr: str) -> Any

Inherited From VeSyncBaseDevice

Get device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def get_state(self, state_attr: str) -> Any:  # noqa: ANN401
    """Get device state attribute."""
    return getattr(self.state, state_attr)

get_timer async

get_timer() -> Timer | None

Inherited From VeSyncBaseDevice

Get timer for device from API and set the state.Timer attribute.

This may not be implemented for all devices. Please open an issue if there is an error.

Note

This method may not be implemented for all devices. Please open an issue if there is an error.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def get_timer(self) -> Timer | None:
    r_bytes = await self.call_bypassv2_api('getTimer')
    resp_model = process_bypassv2_result(
        self, _LOGGER, "get_timer", r_bytes, ResultV2GetTimer
    )
    if resp_model is None:
        return None
    timers = resp_model.timers
    if not timers:
        _LOGGER.debug('No timers found')
        self.state.timer = None
        return None
    timer = timers[0]
    self.state.timer = Timer(
        timer_duration=timer.total,
        action=timer.action,
        id=timer.id,
        remaining=timer.remain,
    )
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    _LOGGER.debug("Timer found: %s", str(self.state.timer))
    return self.state.timer

manual_mode async deprecated

manual_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_manual_mode instead.

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_manual_mode instead.")
async def manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    return await self.set_manual_mode()

mode_toggle async deprecated

mode_toggle(mode: str) -> bool

Inherited From VeSyncAirBypass

Deprecated

Use set_mode(mode: str) instead.

Deprecated method for setting purifier mode.

Source code in src\pyvesync\devices\vesyncpurifier.py
@deprecated("Use set_mode(mode: str) instead.")
async def mode_toggle(self, mode: str) -> bool:
    """Deprecated method for setting purifier mode."""
    return await self.set_mode(mode)

nightlight_mode async deprecated

nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_nightlight_mode instead.

Set Nightlight Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_nightlight_mode instead.")
async def nightlight_mode(self, mode: str) -> bool:
    """Set Nightlight Mode."""
    return await self.set_nightlight_mode(mode)

pet_mode async deprecated

pet_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_pet_mode instead.

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_pet_mode instead.")
async def pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    return await self.set_pet_mode()

reset_filter async

reset_filter() -> bool

Inherited From VeSyncPurifier

Reset filter life.

Reset filter to 100%.

Returns:

Name Type Description
bool bool

True if filter is reset, False if not

Source code in src\pyvesync\devices\vesyncpurifier.py
async def reset_filter(self) -> bool:
    """Reset filter to 100%.

    Returns:
        bool : True if filter is reset, False if not
    """
    r_dict = await self.call_bypassv2_api('resetFilter')
    r = Helpers.process_dev_response(_LOGGER, "reset_filter", self, r_dict)
    return bool(r)

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    if PurifierModes.AUTO in self.modes:
        return await self.set_mode(PurifierModes.AUTO)
    logger.error("Auto mode not supported for this device.")
    return False

set_auto_preference async

set_auto_preference(
    preference: str = DEFAULT, room_size: int = 600
) -> bool

Inherited From VeSyncAirBypass

Set auto preference.

Parameters:

Name Type Description Default
preference str

Auto preference to set, available preference is found in self.auto_preferences.

DEFAULT
room_size int

Room size to set, defaults to 800ft2.

600

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Set Levoit Vital 100S/200S auto mode.

Parameters:

Name Type Description Default
preference str | None | PurifierAutoPreference

Preference for auto mode, default 'default' (default, efficient, quiet)

DEFAULT
room_size int | None

Room size in square feet, by default 600

600
Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_auto_preference(self, preference: str = PurifierAutoPreference.DEFAULT,
                              room_size: int = 600) -> bool:
    """Set Levoit Vital 100S/200S auto mode.

    Parameters:
        preference (str | None | PurifierAutoPreference):
            Preference for auto mode, default 'default' (default, efficient, quiet)
        room_size (int | None):
            Room size in square feet, by default 600
    """
    if preference not in self.auto_preferences:
        _LOGGER.debug(
            "%s is invalid preference -"
            " valid preferences are default, efficient, quiet",
            preference,
        )
        return False
    payload_data = {
        "autoPreference": preference,
        "roomSize": room_size
    }
    r_dict = await self.call_bypassv2_api('setAutoPreference', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "set_auto_preference", self, r_dict)
    if r is None:
        return False

    self.state.auto_preference_type = preference
    self.state.auto_room_size = room_size
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_child_lock async deprecated

set_child_lock(toggle: bool) -> bool

Inherited From VeSyncPurifier

Deprecated

Use toggle_child_lock() instead.

Set child lock (display lock).

This has been deprecated in favor of toggle_child_lock().

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `toggle_child_lock()` instead.")
async def set_child_lock(self, toggle: bool) -> bool:
    """Set child lock (display lock).

    This has been deprecated in favor of `toggle_child_lock()`.
    """
    return await self.toggle_child_lock(toggle)

set_fan_speed async

set_fan_speed(speed: None | int = None) -> bool

Inherited From VeSyncAirBypass

Set Purifier Fan Speed.

Parameters:

Name Type Description Default
speed int | None

Fan speed to set. If None, use default speed.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_fan_speed(self, speed: None | int = None) -> bool:
    if speed is not None:
        if speed not in self.fan_levels:
            _LOGGER.debug(
                "%s is invalid speed - valid speeds are %s",
                speed,
                str(self.fan_levels),
            )
            return False
        new_speed = speed
    elif self.state.fan_level is None:
        new_speed = self.fan_levels[0]
    else:
        new_speed = Helpers.bump_level(self.state.fan_level, self.fan_levels)

    payload_data = {
        "levelIdx": 0,
        "manualSpeedLevel": new_speed,
        "levelType": "wind"
    }
    r_dict = await self.call_bypassv2_api('setLevel', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "set_fan_speed", self, r_dict)
    if r is None:
        return False

    self.state.fan_set_level = new_speed
    self.state.mode = PurifierModes.MANUAL
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_light_detection async deprecated

set_light_detection(toggle: bool) -> bool
Deprecated

Use toggle_light_detection(toggle) instead.

Set light detection feature.

Source code in src\pyvesync\devices\vesyncpurifier.py
@deprecated("Use toggle_light_detection(toggle) instead.")
async def set_light_detection(self, toggle: bool) -> bool:
    """Set light detection feature."""
    return await self.toggle_light_detection(toggle)

set_light_detection_off async deprecated

set_light_detection_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_light_detection() instead.

Turn off light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_off_light_detection() instead.")
async def set_light_detection_off(self) -> bool:
    """Turn off light detection feature."""
    return await self.toggle_light_detection(False)

set_light_detection_on async deprecated

set_light_detection_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_light_detection() instead.

Turn on light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_on_light_detection() instead.")
async def set_light_detection_on(self) -> bool:
    """Turn on light detection feature."""
    return await self.toggle_light_detection(True)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    if PurifierModes.MANUAL in self.modes:
        return await self.set_mode(PurifierModes.MANUAL)
    logger.error("Manual mode not supported for this device.")
    return False

set_mode async

set_mode(mode: str) -> bool

Inherited From VeSyncAirBypass

Set Purifier Mode.

Allowed modes are found in the device.modes attribute.

Parameters:

Name Type Description Default
mode str

Mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_mode(self, mode: str) -> bool:
    if mode.lower() not in self.modes:
        _LOGGER.debug("Invalid purifier mode used - %s", mode)
        return False

    # Call change_fan_speed if mode is set to manual
    if mode == PurifierModes.MANUAL:
        if self.state.fan_set_level is None or self.state.fan_level == 0:
            return await self.set_fan_speed(1)
        return await self.set_fan_speed(self.state.fan_set_level)

    payload_data = {
        "workMode": mode
    }
    r_dict = await self.call_bypassv2_api('setPurifierMode', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "mode_toggle", self, r_dict)
    if r is None:
        return False

    self.state.mode = mode
    self.state.connection_status = ConnectionStatus.ONLINE
    self.state.device_status = DeviceStatus.ON
    return True

set_nightlight_dim async

set_nightlight_dim() -> bool

Inherited From VeSyncPurifier

Set Nightlight Dim.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_nightlight_dim(self) -> bool:
    """Set Nightlight Dim."""
    return await self.set_nightlight_mode(NightlightModes.DIM)

set_nightlight_mode async

set_nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Set Nightlight Mode.

Modes are defined in the device.nightlight_modes attribute.

Parameters:

Name Type Description Default
mode str

Nightlight mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_nightlight_mode(self, mode: str) -> bool:
    if not self.supports_nightlight:
        _LOGGER.debug("Device does not support night light")
        return False
    if mode.lower() not in self.nightlight_modes:
        _LOGGER.warning("Invalid nightlight mode used (on, off or dim)- %s", mode)
        return False

    r_dict = await self.call_bypassv2_api(
        'setNightLight', {'night_light': mode.lower()}
        )
    r = Helpers.process_dev_response(_LOGGER, "set_night_light", self, r_dict)
    if r is None:
        return False

    self.state.nightlight_status = mode
    return True

set_pet_mode async

set_pet_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    if PurifierModes.PET in self.modes:
        return await self.set_mode(PurifierModes.PET)
    logger.error("Pet mode not supported for this device.")
    return False

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    if PurifierModes.SLEEP in self.modes:
        return await self.set_mode(PurifierModes.SLEEP)
    logger.error("Sleep mode not supported for this device.")
    return False

set_state

set_state(state_attr: str, stat_value: Any) -> None

Inherited From VeSyncBaseDevice

Set device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def set_state(self, state_attr: str, stat_value: Any) -> None:  # noqa: ANN401
    """Set device state attribute."""
    setattr(self, state_attr, stat_value)

set_timer async

set_timer(duration: int, action: str | None = None) -> bool

Inherited From VeSyncAirBypass

Set timer for device.

This may not be implemented for all devices. Please open an issue if there is an error.

Parameters:

Name Type Description Default
duration int

Duration in seconds.

required
action str | None

Action to take when timer expires.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_timer(
    self, duration: int, action: str | None = None
) -> bool:
    action = DeviceStatus.OFF  # No other actions available for this device
    if action not in [DeviceStatus.ON, DeviceStatus.OFF]:
        _LOGGER.debug('Invalid action for timer')
        return False

    method = 'powerSwitch'
    action_int = 1 if action == DeviceStatus.ON else 0
    action_item = PurifierV2TimerActionItems(type=method, act=action_int)
    timing = PurifierV2EventTiming(clkSec=duration)
    payload_data = PurifierV2TimerPayloadData(
        enabled=True, startAct=[action_item], tmgEvt=timing,
    )

    r_dict = await self.call_bypassv2_api('addTimerV2', payload_data.to_dict())
    r = Helpers.process_dev_response(_LOGGER, "set_timer", self, r_dict)
    if r is None:
        return False

    r_model = ResultV2SetTimer.from_dict(r)

    self.state.timer = Timer(duration, action=action, id=r_model.id)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_turbo_mode async

set_turbo_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    if PurifierModes.TURBO in self.modes:
        return await self.set_mode(PurifierModes.TURBO)
    logger.error("Turbo mode not supported for this device.")
    return False

sleep_mode async deprecated

sleep_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_sleep_mode instead.

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_sleep_mode instead.")
async def sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    return await self.set_sleep_mode()

to_dict

to_dict(state: bool = True) -> dict[str, Any]

Inherited From VeSyncBaseDevice

Return device information as a dictionary.

Parameters:

Name Type Description Default
state bool

If True, include state in dictionary, defaults to True.

True

Returns:

Type Description
dict[str, Any]

dict[str, Any]: Dictionary containing device information.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_dict(self, state: bool = True) -> dict[str, Any]:
    """Return device information as a dictionary.

    Args:
        state (bool): If True, include state in dictionary, defaults to True.

    Returns:
        dict[str, Any]: Dictionary containing device information.
    """
    device_dict = {
        "device_name": self.device_name,
        "product_type": self.product_type,
        "model": self.device_type,
        "subdevice_no": str(self.sub_device_no),
        "type": self.type,
        "cid": self.cid,
        "features:": self.features,
        "config_module": self.config_module,
        "connection_type": self.connection_type,
        "last_response": self.last_response,
    }
    state_dict = self.state.to_dict() if state else {}
    return device_dict | state_dict

to_json

to_json(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Print JSON API string for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
str str

JSON formatted string of device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_json(self, state: bool = True, indent: bool = True) -> str:
    """Print JSON API string for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        str: JSON formatted string of device details.
    """
    return self.to_jsonb(state, indent).decode()

to_jsonb

to_jsonb(state: bool = True, indent: bool = True) -> bytes

Inherited From VeSyncBaseDevice

JSON API bytes for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
bytes bytes

JSON formatted bytes of device details.

Example

This is an example without state.

{
    "Device Name": "Living Room Lamp",
    "Model": "ESL100",
    "Subdevice No": "0",
    "Type": "wifi",
    "CID": "1234567890abcdef"
}

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_jsonb(self, state: bool = True, indent: bool = True) -> bytes:
    """JSON API bytes for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        bytes: JSON formatted bytes of device details.

    Example:
        This is an example without state.
        ```
        {
            "Device Name": "Living Room Lamp",
            "Model": "ESL100",
            "Subdevice No": "0",
            "Type": "wifi",
            "CID": "1234567890abcdef"
        }
        ```
    """
    return_dict = self.to_dict(state=state)
    if indent:
        return orjson.dumps(
            return_dict,
            option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS,
        )

    return orjson.dumps(return_dict, option=orjson.OPT_NON_STR_KEYS)

toggle_child_lock async

toggle_child_lock(toggle: bool | None = None) -> bool

Inherited From VeSyncAirBypass

Toggle Child Lock (Display Lock).

Parameters:

Name Type Description Default
toggle bool | None

Toggle child lock. If None, toggle state.

None

Toggle child lock.

Set child lock to on or off. Internal method used by turn_on_child_lock and turn_off_child_lock.

Parameters:

Name Type Description Default
toggle bool

True to turn child lock on, False to turn off

None

Returns:

Name Type Description
bool bool

True if child lock is set, False if not

Levoit 100S/200S set Child Lock.

Parameters:

Name Type Description Default
toggle bool

True to turn child lock on, False to turn off

None

Returns:

Name Type Description
bool bool

True if successful, False if not

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_child_lock(self, toggle: bool | None = None) -> bool:
    """Levoit 100S/200S set Child Lock.

    Parameters:
        toggle (bool): True to turn child lock on, False to turn off

    Returns:
        bool : True if successful, False if not
    """
    if toggle is None:
        toggle = not bool(self.state.child_lock)
    payload_data = {'childLockSwitch': int(toggle)}
    r_dict = await self.call_bypassv2_api('setChildLock', payload_data)

    r = Helpers.process_dev_response(_LOGGER, "toggle_child_lock", self, r_dict)
    if r is None:
        return False

    self.state.child_lock = toggle
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_display async

toggle_display(mode: bool) -> bool

Inherited From VeSyncAirBypass

Set Display Mode.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_display(self, mode: bool) -> bool:
    if bool(self.state.display_set_state) == mode:
        _LOGGER.debug('Display is already %s', mode)
        return True

    payload_data = {
        'screenSwitch': int(mode)
    }
    r_dict = await self.call_bypassv2_api('setDisplay', payload_data)

    r = Helpers.process_dev_response(_LOGGER, "set_display", self, r_dict)
    if r is None:
        return False

    self.state.display_set_state = DeviceStatus.from_bool(mode)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_light_detection async

toggle_light_detection(toggle: bool | None = None) -> bool

Inherited From VeSyncPurifier

Set Light Detection Mode.

Parameters:

Name Type Description Default
toggle bool | None

Toggle light detection. If None, toggle state.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Enable/Disable Light Detection Feature.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_light_detection(self, toggle: bool | None = None) -> bool:
    """Enable/Disable Light Detection Feature."""
    if toggle is None:
        toggle = not bool(self.state.light_detection_status)
    payload_data = {"lightDetectionSwitch": int(toggle)}
    r_dict = await self.call_bypassv2_api('setLightDetection', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "set_light_detection", self, r_dict)
    if r is None:
        return False

    self.state.light_detection_switch = DeviceStatus.ON if toggle \
        else DeviceStatus.OFF
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_switch async

toggle_switch(toggle: bool | None = None) -> bool

Inherited From VeSyncAirBypass

Toggle device power on or off.

Parameters:

Name Type Description Default
toggle bool | None

True to turn on, False to turn off, None to toggle.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = not bool(self.state.device_status)
    if not isinstance(toggle, bool):
        _LOGGER.debug('Invalid toggle value for purifier switch')
        return False
    if toggle == bool(self.state.device_status):
        _LOGGER.debug('Purifier is already %s', self.state.device_status)
        return True

    payload_data = {
            'powerSwitch': int(toggle),
            'switchIdx': 0
        }
    r_dict = await self.call_bypassv2_api('setSwitch', payload_data)
    r = Helpers.process_dev_response(_LOGGER, "toggle_switch", self, r_dict)
    if r is None:
        return False

    self.state.device_status = DeviceStatus.from_bool(toggle)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

turbo_mode async deprecated

turbo_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_turbo_mode instead.

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_turbo_mode instead.")
async def turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    return await self.set_turbo_mode()

turn_off async

turn_off() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device off.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_off(self) -> bool:
    """Turn device off."""
    return await self.toggle_switch(False)

turn_off_child_lock async

turn_off_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to OFF.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_child_lock(self) -> bool:
    """Set child lock (display lock) to OFF."""
    return await self.toggle_child_lock(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncPurifier

Turn off Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off Display."""
    return await self.toggle_display(False)

turn_off_light_detection async

turn_off_light_detection() -> bool

Inherited From VeSyncPurifier

Turn off Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_light_detection(self) -> bool:
    """Turn off Light Detection."""
    return await self.toggle_light_detection(False)

turn_off_nightlight async

turn_off_nightlight() -> bool

Inherited From VeSyncPurifier

Turn off Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_nightlight(self) -> bool:
    """Turn off Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.OFF)

turn_on async

turn_on() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device on.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_on(self) -> bool:
    """Turn device on."""
    return await self.toggle_switch(True)

turn_on_child_lock async

turn_on_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to ON.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_child_lock(self) -> bool:
    """Set child lock (display lock) to ON."""
    return await self.toggle_child_lock(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncPurifier

Turn on Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on Display."""
    return await self.toggle_display(True)

turn_on_light_detection async

turn_on_light_detection() -> bool

Inherited From VeSyncPurifier

Turn on Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_light_detection(self) -> bool:
    """Turn on Light Detection."""
    return await self.toggle_light_detection(True)

turn_on_nightlight async

turn_on_nightlight() -> bool

Inherited From VeSyncPurifier

Turn on Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_nightlight(self) -> bool:
    """Turn on Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.ON)

update async

update() -> None

Inherited From VeSyncBaseDevice

Update device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def update(self) -> None:
    """Update device details."""
    await self.get_details()

pyvesync.devices.vesyncpurifier.VeSyncAir131

Bases: BypassV1Mixin, VeSyncPurifier

Levoit Air Purifier Class.

Class for LV-PUR131S, using BypassV1 API.

Attributes:

Name Type Description
state PurifierState

State of the device.

last_response ResponseInfo

Last response from API call.

manager VeSync

Manager object for API calls.

device_name str

Name of device.

device_image str

URL for device image.

cid str

Device ID.

connection_type str

Connection type of device.

device_type str

Type of device.

type str

Type of device.

uuid str

UUID of device, not always present.

config_module str

Configuration module of device.

mac_id str

MAC ID of device.

current_firm_version str

Current firmware version of device.

device_region str

Region of device. (US, EU, etc.)

pid str

Product ID of device, pulled by some devices on update.

sub_device_no int

Sub-device number of device.

product_type str

Product type of device.

features dict

Features of device.

modes list[str]

List of modes supported by the device.

fan_levels list[int]

List of fan levels supported by the device.

nightlight_modes list[str]

List of nightlight modes supported by the device.

auto_preferences list[str]

List of auto preferences supported by the device.

Source code in src\pyvesync\devices\vesyncpurifier.py
class VeSyncAir131(BypassV1Mixin, VeSyncPurifier):
    """Levoit Air Purifier Class.

    Class for LV-PUR131S, using BypassV1 API.

    Attributes:
        state (PurifierState): State of the device.
        last_response (ResponseInfo): Last response from API call.
        manager (VeSync): Manager object for API calls.
        device_name (str): Name of device.
        device_image (str): URL for device image.
        cid (str): Device ID.
        connection_type (str): Connection type of device.
        device_type (str): Type of device.
        type (str): Type of device.
        uuid (str): UUID of device, not always present.
        config_module (str): Configuration module of device.
        mac_id (str): MAC ID of device.
        current_firm_version (str): Current firmware version of device.
        device_region (str): Region of device. (US, EU, etc.)
        pid (str): Product ID of device, pulled by some devices on update.
        sub_device_no (int): Sub-device number of device.
        product_type (str): Product type of device.
        features (dict): Features of device.
        modes (list[str]): List of modes supported by the device.
        fan_levels (list[int]): List of fan levels supported by the device.
        nightlight_modes (list[str]): List of nightlight modes supported by the device.
        auto_preferences (list[str]): List of auto preferences supported by the device.
    """

    __slots__ = ()

    def __init__(self, details: ResponseDeviceDetailsModel,
                 manager: VeSync, feature_map: PurifierMap) -> None:
        """Initialize air purifier class."""
        super().__init__(details, manager, feature_map)
        # self.request_keys = [
        #     "acceptLanguage",
        #     "appVersion",
        #     "phoneBrand",
        #     "phoneOS",
        #     "accountID",
        #     "debugMode"
        #     "traceId",
        #     "timeZone",
        #     "token",
        #     "userCountryCode",
        #     "uuid"
        # ]

    # def _build_request(
    #     self, method: str, update_dict: dict | None = None
    # ) -> RequestPurifier131:
    #     """Build API request body for air purifier timer."""
    #     body = Helpers.get_class_attributes(DefaultValues, self.request_keys)
    #     body.update(Helpers.get_class_attributes(self.manager, self.request_keys))
    #     body.update(Helpers.get_class_attributes(self, self.request_keys))
    #     body["method"] = method
    #     if update_dict is not None:
    #         body.update(update_dict)
    #     return RequestPurifier131.from_dict(body)

    def _set_state(self, details: Purifier131Result) -> None:
        """Set state from purifier API get_details() response."""
        self.state.device_status = details.deviceStatus
        self.state.connection_status = details.connectionStatus
        self.state.active_time = details.activeTime
        self.state.filter_life = details.filterLife.percent
        self.state.display_status = details.screenStatus
        self.state.display_set_state = details.screenStatus
        self.state.child_lock = bool(DeviceStatus(details.childLock))
        self.state.mode = details.mode
        self.state.fan_level = details.level or 0
        self.state.fan_set_level = details.level or 0
        self.state.set_air_quality_level(details.airQuality)

    async def get_details(self) -> None:
        # body = self._build_request('deviceDetail')
        # headers = Helpers.req_header_bypass()

        # r_dict, _ = await self.manager.async_call_api(
        #     '/cloud/v1/deviceManaged/deviceDetail',
        #     method='post',
        #     headers=headers,
        #     json_object=body.to_dict(),
        # )
        r_dict = await self.call_bypassv1_api(
            RequestPurifier131, method="deviceDetail", endpoint="deviceDetail"
        )
        r = Helpers.process_dev_response(_LOGGER, "get_details", self, r_dict)
        if r is None:
            return

        r_model = Purifier131Result.from_dict(r.get('result', {}))
        self._set_state(r_model)

    async def toggle_display(self, mode: bool) -> bool:
        update_dict = {
            "status": "on" if mode else "off"
        }
        # body = self._build_request('airPurifierScreenCtl', update_dict=update_dict)
        # headers = Helpers.req_header_bypass()

        # r_dict, _ = await self.manager.async_call_api(
        #     '/cloud/v1/deviceManaged/airPurifierScreenCtl', 'post',
        #     json_object=body.to_dict(), headers=headers
        # )
        r_dict = await self.call_bypassv1_api(
            RequestPurifier131, method="airPurifierScreenCtl",
            endpoint="airPurifierScreenCtl", update_dict=update_dict
        )
        r = Helpers.process_dev_response(_LOGGER, "toggle_display", self, r_dict)
        if r is None:
            return False

        self.state.display_set_state = DeviceStatus.from_bool(mode)
        self.state.display_status = DeviceStatus.from_bool(mode)
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def toggle_switch(self, toggle: bool | None = None) -> bool:
        if toggle is None:
            toggle = self.state.device_status != DeviceStatus.ON

        update_dict = {
            "status": DeviceStatus.from_bool(toggle).value
        }
        # body = self._build_request('airPurifierPowerSwitchCtl', update_dict=update_dict)
        # headers = Helpers.req_header_bypass()
        # r_dict, _ = await self.manager.async_call_api(
        #     '/cloud/v1/deviceManaged/airPurifierPowerSwitchCtl', 'post',
        #     json_object=body.to_dict(), headers=headers
        # )
        r_dict = await self.call_bypassv1_api(
            RequestPurifier131, method="airPurifierPowerSwitchCtl",
            endpoint="airPurifierPowerSwitchCtl", update_dict=update_dict
        )
        r = Helpers.process_dev_response(_LOGGER, "toggle_switch", self, r_dict)
        if r is None:
            return False

        self.state.device_status = DeviceStatus.from_bool(toggle)
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

    async def set_fan_speed(self, speed: int | None = None) -> bool:
        current_speed = self.state.fan_set_level or 0

        if speed is not None:
            if speed not in self.fan_levels:
                _LOGGER.debug(
                    "%s is invalid speed - valid speeds are %s",
                    speed,
                    str(self.fan_levels),
                )
                return False
            new_speed = speed
        else:
            new_speed = Helpers.bump_level(current_speed, self.fan_levels)

        update_dict = {
            "level": new_speed
        }
        # body = self._build_request('airPurifierSpeedCtl', update_dict=update_dict)
        # headers = Helpers.req_header_bypass()

        # r_dict, _ = await self.manager.async_call_api(
        #     '/cloud/v1/deviceManaged/airPurifierSpeedCtl', 'post',
        #     json_object=body, headers=headers
        # )
        r_dict = await self.call_bypassv1_api(
            RequestPurifier131Level, method="airPurifierSpeedCtl",
            endpoint="airPurifierSpeedCtl", update_dict=update_dict
        )
        r = Helpers.process_dev_response(_LOGGER, "set_fan_speed", self, r_dict)
        if r is None:
            return False

        self.state.fan_level = new_speed
        self.state.fan_set_level = new_speed
        self.state.connection_status = 'online'
        self.state.mode = PurifierModes.MANUAL
        return True

    async def set_mode(self, mode: str) -> bool:
        if mode not in self.modes:
            _LOGGER.debug('Invalid purifier mode used - %s', mode)
            return False

        if mode == PurifierModes.MANUAL:
            set_level = (
                1 if self.state.fan_set_level in [0, None] else self.state.fan_set_level
            )
            return await self.set_fan_speed(set_level)

        update_dict = {
            "mode": mode
        }
        # body = self._build_request('airPurifierModeCtl', update_dict=update_dict)
        # headers = Helpers.req_header_bypass()

        # r_dict, _ = await self.manager.async_call_api(
        #     '/cloud/v1/deviceManaged/airPurifierRunModeCtl', 'post',
        #     json_object=body.to_dict(), headers=headers
        # )
        r_dict = await self.call_bypassv1_api(
            RequestPurifier131Mode, method="airPurifierRunModeCtl",
            endpoint="airPurifierRunModeCtl", update_dict=update_dict
        )
        r = Helpers.process_dev_response(_LOGGER, "mode_toggle", self, r_dict)
        if r is None:
            return False

        self.state.mode = mode
        self.state.connection_status = ConnectionStatus.ONLINE
        return True

Attributes

auto_preferences instance-attribute

auto_preferences: list[str] = auto_preferences

Inherited From VeSyncPurifier

child_lock property

child_lock: bool

Inherited From VeSyncPurifier

Get child lock state.

Returns:

Name Type Description
bool bool

True if child lock is enabled, False if not.

cid instance-attribute

cid: str = cid

Inherited From VeSyncBaseDevice

config_module instance-attribute

config_module: str = configModule

Inherited From VeSyncBaseDevice

connection_type instance-attribute

connection_type: str | None = connectionType

Inherited From VeSyncBaseDevice

current_firm_version instance-attribute

current_firm_version = currentFirmVersion

Inherited From VeSyncBaseDevice

device_image instance-attribute

device_image: str | None = deviceImg

Inherited From VeSyncBaseDevice

device_name instance-attribute

device_name: str = deviceName

Inherited From VeSyncBaseDevice

device_region instance-attribute

device_region: str | None = deviceRegion

Inherited From VeSyncBaseDevice

device_type instance-attribute

device_type: str = deviceType

Inherited From VeSyncBaseDevice

enabled instance-attribute

enabled: bool = True

Inherited From VeSyncBaseDevice

fan_levels instance-attribute

fan_levels: list[int] = fan_levels

Inherited From VeSyncPurifier

features instance-attribute

features: list[str] = features

Inherited From VeSyncBaseDevice

firmware_update property

firmware_update: bool

Inherited From VeSyncBaseDevice

Return True if firmware update available.

This is going to be updated.

is_on property

is_on: bool

Inherited From VeSyncBaseDevice

Return true if device is on.

last_response instance-attribute

last_response: ResponseInfo | None = None

Inherited From VeSyncBaseDevice

mac_id instance-attribute

mac_id: str | None = macID

Inherited From VeSyncBaseDevice

manager instance-attribute

manager: VeSync

Inherited From BypassV1Mixin

modes instance-attribute

modes: list[str] = modes

Inherited From VeSyncPurifier

night_light property

night_light: str

Inherited From VeSyncPurifier

Get night light state.

Returns:

Name Type Description
str str

Night light state (on, dim, off)

nightlight_modes instance-attribute

nightlight_modes: list[str] = nightlight_modes

Inherited From VeSyncPurifier

pid instance-attribute

pid: str | None = None

Inherited From VeSyncBaseDevice

product_type instance-attribute

product_type: str = product_type

Inherited From VeSyncBaseDevice

request_keys class-attribute

request_keys: list[str] = [
    'acceptLanguage',
    'appVersion',
    'phoneBrand',
    'phoneOS',
    'accountID',
    'cid',
    'configModule',
    'debugMode',
    'traceId',
    'timeZone',
    'token',
    'userCountryCode',
    'uuid',
    'configModel',
    'deviceId',
]

Inherited From BypassV1Mixin

state instance-attribute

state: PurifierState = PurifierState(
    self, details, feature_map
)

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_air_quality property

supports_air_quality: bool

Inherited From VeSyncPurifier

Return True if device supports air quality.

supports_fan_rotate property

supports_fan_rotate: bool

Inherited From VeSyncPurifier

Return True if device supports fan rotation.

supports_light_detection property

supports_light_detection: bool

Inherited From VeSyncPurifier

Returns True if device supports light detection.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncPurifier

Return True if device supports nightlight.

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

Functions

auto_mode async deprecated

auto_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_auto_mode instead.

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_auto_mode instead.")
async def auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    return await self.set_auto_mode()

call_bypassv1_api async

call_bypassv1_api(
    request_model: type[RequestBypassV1],
    update_dict: dict | None = None,
    method: str = 'bypass',
    endpoint: str = 'bypass',
) -> dict | None

Inherited From BypassV1Mixin

Send ByPass V1 API request.

This uses the _build_request method to send API requests to the Bypass V1 API. The endpoint can be overridden with the endpoint argument.

Parameters:

Name Type Description Default
request_model type[RequestBypassV1]

The request model to use.

required
update_dict dict

Additional keys to add on.

None
method str

The method to use in the outer body.

'bypass'
endpoint str | None

The last part of the url path, defaults to bypass, e.g. /cloud/v1/deviceManaged/bypass.

'bypass'

Returns:

Name Type Description
bytes dict | None

The response from the API request.

Source code in src\pyvesync\utils\device_mixins.py
async def call_bypassv1_api(
    self,
    request_model: type[RequestBypassV1],
    update_dict: dict | None = None,
    method: str = "bypass",
    endpoint: str = "bypass",
) -> dict | None:
    """Send ByPass V1 API request.

    This uses the `_build_request` method to send API requests to the Bypass V1 API.
    The endpoint can be overridden with the `endpoint` argument.

    Args:
        request_model (type[RequestBypassV1]): The request model to use.
        update_dict (dict): Additional keys to add on.
        method (str): The method to use in the outer body.
        endpoint (str | None): The last part of the url path, defaults to
            `bypass`, e.g. `/cloud/v1/deviceManaged/bypass`.

    Returns:
        bytes: The response from the API request.
    """
    request = self._build_request(request_model, update_dict, method)
    url_path = BYPASS_V1_PATH + endpoint
    resp_dict, _ = await self.manager.async_call_api(
        url_path, "post", request, Helpers.req_header_bypass()
    )

    return resp_dict

change_fan_speed async deprecated

change_fan_speed(speed: int | None = None) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_fan_speed() instead.

Deprecated method for changing fan speed.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_fan_speed()` instead.")
async def change_fan_speed(self, speed: int | None = None) -> bool:
    """Deprecated method for changing fan speed."""
    return await self.set_fan_speed(speed)

change_mode async deprecated

change_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_mode(mode: str) instead.

Deprecated method for changing purifier mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_mode(mode: str)` instead.")
async def change_mode(self, mode: str) -> bool:
    """Deprecated method for changing purifier mode."""
    return await self.set_mode(mode)

child_lock_off async deprecated

child_lock_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_child_lock() instead.

Turn off child lock (display lock).

This has been deprecated, use turn_off_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_off_child_lock()` instead.")
async def child_lock_off(self) -> bool:
    """Turn off child lock (display lock).

    This has been deprecated, use `turn_off_child_lock()` instead.
    """
    return await self.toggle_child_lock(False)

child_lock_on async deprecated

child_lock_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_child_lock() instead.

Turn on child lock (display lock).

This has been deprecated, use turn_on_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_on_child_lock()` instead.")
async def child_lock_on(self) -> bool:
    """Turn on child lock (display lock).

    This has been deprecated, use `turn_on_child_lock()` instead.
    """
    return await self.toggle_child_lock(True)

clear_timer async

clear_timer() -> bool

Inherited From VeSyncBaseDevice

Clear timer for device from API.

This may not be implemented for all devices. Please open an issue if there is an error.

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def clear_timer(self) -> bool:
    """Clear timer for device from API.

    This may not be implemented for all devices. Please open an issue
    if there is an error.

    Returns:
        bool: True if successful, False otherwise.
    """
    logger.debug('Not implemented - clear_timer')
    return False

display

display(state: bool = True) -> None

Inherited From VeSyncBaseDevice

Print formatted static device info to stdout.

Parameters:

Name Type Description Default
state bool

If True, include state in display, defaults to True.

True

Example:

Device Name:..................Living Room Lamp
Model:........................ESL100
Subdevice No:.................0
Type:.........................wifi
CID:..........................1234567890abcdef

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def display(self, state: bool = True) -> None:
    """Print formatted static device info to stdout.

    Args:
        state (bool): If True, include state in display, defaults to True.

    Example:
    ```
    Device Name:..................Living Room Lamp
    Model:........................ESL100
    Subdevice No:.................0
    Type:.........................wifi
    CID:..........................1234567890abcdef
    ```
    """
    # noinspection SpellCheckingInspection
    display_list = [
        ('Device Name:', self.device_name),
        ('Product Type: ', self.product_type),
        ('Model: ', self.device_type),
        ('Subdevice No: ', str(self.sub_device_no)),
        ('Type: ', self.type),
        ('CID: ', self.cid),
        ('Config Module: ', self.config_module),
        ('Connection Type: ', self.connection_type),
        ('Features', self.features),
        ('Last Response: ', self.last_response),
    ]
    if self.uuid is not None:
        display_list.append(('UUID: ', self.uuid))

    for line in display_list:
        print(f'{line[0]:.<30} {line[1]}')
    if state:
        self.state.display()

displayJSON deprecated

displayJSON(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Deprecated

Use to_json() instead

Return JSON details for device. - Deprecated use to_json().

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
@deprecated("Use to_json() instead")
def displayJSON(self, state: bool = True, indent: bool = True) -> str:  # pylint: disable=invalid-name
    """Return JSON details for device. - Deprecated use to_json()."""
    return self.to_json(state, indent)

get_details async

get_details() -> None

Inherited From VeSyncBaseDevice

Get device details.

This method is defined in each device class to contain the logic to pull the device state from the API and update the device's state attribute. The update() method should be called to update the device state.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def get_details(self) -> None:
    # body = self._build_request('deviceDetail')
    # headers = Helpers.req_header_bypass()

    # r_dict, _ = await self.manager.async_call_api(
    #     '/cloud/v1/deviceManaged/deviceDetail',
    #     method='post',
    #     headers=headers,
    #     json_object=body.to_dict(),
    # )
    r_dict = await self.call_bypassv1_api(
        RequestPurifier131, method="deviceDetail", endpoint="deviceDetail"
    )
    r = Helpers.process_dev_response(_LOGGER, "get_details", self, r_dict)
    if r is None:
        return

    r_model = Purifier131Result.from_dict(r.get('result', {}))
    self._set_state(r_model)

get_state

get_state(state_attr: str) -> Any

Inherited From VeSyncBaseDevice

Get device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def get_state(self, state_attr: str) -> Any:  # noqa: ANN401
    """Get device state attribute."""
    return getattr(self.state, state_attr)

get_timer async

get_timer() -> Timer | None

Inherited From VeSyncBaseDevice

Get timer for device from API and set the state.Timer attribute.

This may not be implemented for all devices. Please open an issue if there is an error.

Note

This method may not be implemented for all devices. Please open an issue if there is an error.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def get_timer(self) -> Timer | None:
    """Get timer for device from API and set the `state.Timer` attribute.

    This may not be implemented for all devices. Please open an issue
    if there is an error.

    Note:
        This method may not be implemented for all devices. Please
        open an issue if there is an error.
    """
    logger.debug('Not implemented - get_timer')
    return None

manual_mode async deprecated

manual_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_manual_mode instead.

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_manual_mode instead.")
async def manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    return await self.set_manual_mode()

nightlight_mode async deprecated

nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_nightlight_mode instead.

Set Nightlight Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_nightlight_mode instead.")
async def nightlight_mode(self, mode: str) -> bool:
    """Set Nightlight Mode."""
    return await self.set_nightlight_mode(mode)

pet_mode async deprecated

pet_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_pet_mode instead.

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_pet_mode instead.")
async def pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    return await self.set_pet_mode()

reset_filter async

reset_filter() -> bool

Inherited From VeSyncPurifier

Reset filter life.

Source code in src\pyvesync\base_devices\purifier_base.py
async def reset_filter(self) -> bool:
    """Reset filter life."""
    logger.debug("Filter life reset not configured for this device.")
    return False

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    if PurifierModes.AUTO in self.modes:
        return await self.set_mode(PurifierModes.AUTO)
    logger.error("Auto mode not supported for this device.")
    return False

set_auto_preference async

set_auto_preference(
    preference: str, room_size: int = 800
) -> bool

Inherited From VeSyncPurifier

Set auto preference.

Parameters:

Name Type Description Default
preference str

Auto preference to set, available preference is found in self.auto_preferences.

required
room_size int

Room size to set, defaults to 800ft2.

800

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_auto_preference(self, preference: str, room_size: int = 800) -> bool:
    """Set auto preference.

    Args:
        preference (str): Auto preference to set, available preference is
            found in `self.auto_preferences`.
        room_size (int): Room size to set, defaults to 800ft2.

    Returns:
        bool: True if successful, False otherwise.
    """
    del preference, room_size
    logger.debug("Auto preference not configured for this device.")
    return False

set_child_lock async deprecated

set_child_lock(toggle: bool) -> bool

Inherited From VeSyncPurifier

Deprecated

Use toggle_child_lock() instead.

Set child lock (display lock).

This has been deprecated in favor of toggle_child_lock().

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `toggle_child_lock()` instead.")
async def set_child_lock(self, toggle: bool) -> bool:
    """Set child lock (display lock).

    This has been deprecated in favor of `toggle_child_lock()`.
    """
    return await self.toggle_child_lock(toggle)

set_fan_speed async

set_fan_speed(speed: int | None = None) -> bool

Inherited From VeSyncPurifier

Set Purifier Fan Speed.

Parameters:

Name Type Description Default
speed int | None

Fan speed to set. If None, use default speed.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_fan_speed(self, speed: int | None = None) -> bool:
    current_speed = self.state.fan_set_level or 0

    if speed is not None:
        if speed not in self.fan_levels:
            _LOGGER.debug(
                "%s is invalid speed - valid speeds are %s",
                speed,
                str(self.fan_levels),
            )
            return False
        new_speed = speed
    else:
        new_speed = Helpers.bump_level(current_speed, self.fan_levels)

    update_dict = {
        "level": new_speed
    }
    # body = self._build_request('airPurifierSpeedCtl', update_dict=update_dict)
    # headers = Helpers.req_header_bypass()

    # r_dict, _ = await self.manager.async_call_api(
    #     '/cloud/v1/deviceManaged/airPurifierSpeedCtl', 'post',
    #     json_object=body, headers=headers
    # )
    r_dict = await self.call_bypassv1_api(
        RequestPurifier131Level, method="airPurifierSpeedCtl",
        endpoint="airPurifierSpeedCtl", update_dict=update_dict
    )
    r = Helpers.process_dev_response(_LOGGER, "set_fan_speed", self, r_dict)
    if r is None:
        return False

    self.state.fan_level = new_speed
    self.state.fan_set_level = new_speed
    self.state.connection_status = 'online'
    self.state.mode = PurifierModes.MANUAL
    return True

set_light_detection_off async deprecated

set_light_detection_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_light_detection() instead.

Turn off light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_off_light_detection() instead.")
async def set_light_detection_off(self) -> bool:
    """Turn off light detection feature."""
    return await self.toggle_light_detection(False)

set_light_detection_on async deprecated

set_light_detection_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_light_detection() instead.

Turn on light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_on_light_detection() instead.")
async def set_light_detection_on(self) -> bool:
    """Turn on light detection feature."""
    return await self.toggle_light_detection(True)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    if PurifierModes.MANUAL in self.modes:
        return await self.set_mode(PurifierModes.MANUAL)
    logger.error("Manual mode not supported for this device.")
    return False

set_mode async

set_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Set Purifier Mode.

Allowed modes are found in the device.modes attribute.

Parameters:

Name Type Description Default
mode str

Mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def set_mode(self, mode: str) -> bool:
    if mode not in self.modes:
        _LOGGER.debug('Invalid purifier mode used - %s', mode)
        return False

    if mode == PurifierModes.MANUAL:
        set_level = (
            1 if self.state.fan_set_level in [0, None] else self.state.fan_set_level
        )
        return await self.set_fan_speed(set_level)

    update_dict = {
        "mode": mode
    }
    # body = self._build_request('airPurifierModeCtl', update_dict=update_dict)
    # headers = Helpers.req_header_bypass()

    # r_dict, _ = await self.manager.async_call_api(
    #     '/cloud/v1/deviceManaged/airPurifierRunModeCtl', 'post',
    #     json_object=body.to_dict(), headers=headers
    # )
    r_dict = await self.call_bypassv1_api(
        RequestPurifier131Mode, method="airPurifierRunModeCtl",
        endpoint="airPurifierRunModeCtl", update_dict=update_dict
    )
    r = Helpers.process_dev_response(_LOGGER, "mode_toggle", self, r_dict)
    if r is None:
        return False

    self.state.mode = mode
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_nightlight_dim async

set_nightlight_dim() -> bool

Inherited From VeSyncPurifier

Set Nightlight Dim.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_nightlight_dim(self) -> bool:
    """Set Nightlight Dim."""
    return await self.set_nightlight_mode(NightlightModes.DIM)

set_nightlight_mode async

set_nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Set Nightlight Mode.

Modes are defined in the device.nightlight_modes attribute.

Parameters:

Name Type Description Default
mode str

Nightlight mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_nightlight_mode(self, mode: str) -> bool:
    """Set Nightlight Mode.

    Modes are defined in the `device.nightlight_modes` attribute.

    Args:
        mode (str): Nightlight mode to set.

    Returns:
        bool: True if successful, False otherwise.
    """
    del mode
    return False

set_pet_mode async

set_pet_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    if PurifierModes.PET in self.modes:
        return await self.set_mode(PurifierModes.PET)
    logger.error("Pet mode not supported for this device.")
    return False

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    if PurifierModes.SLEEP in self.modes:
        return await self.set_mode(PurifierModes.SLEEP)
    logger.error("Sleep mode not supported for this device.")
    return False

set_state

set_state(state_attr: str, stat_value: Any) -> None

Inherited From VeSyncBaseDevice

Set device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def set_state(self, state_attr: str, stat_value: Any) -> None:  # noqa: ANN401
    """Set device state attribute."""
    setattr(self, state_attr, stat_value)

set_timer async

set_timer(duration: int, action: str | None = None) -> bool

Inherited From VeSyncBaseDevice

Set timer for device.

This may not be implemented for all devices. Please open an issue if there is an error.

Parameters:

Name Type Description Default
duration int

Duration in seconds.

required
action str | None

Action to take when timer expires.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    """Set timer for device.

    This may not be implemented for all devices. Please open an issue
    if there is an error.

    Args:
        duration (int): Duration in seconds.
        action (str | None): Action to take when timer expires.

    Returns:
        bool: True if successful, False otherwise.
    """
    del duration
    del action
    logger.debug('Not implemented - set_timer')
    return False

set_turbo_mode async

set_turbo_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    if PurifierModes.TURBO in self.modes:
        return await self.set_mode(PurifierModes.TURBO)
    logger.error("Turbo mode not supported for this device.")
    return False

sleep_mode async deprecated

sleep_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_sleep_mode instead.

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_sleep_mode instead.")
async def sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    return await self.set_sleep_mode()

to_dict

to_dict(state: bool = True) -> dict[str, Any]

Inherited From VeSyncBaseDevice

Return device information as a dictionary.

Parameters:

Name Type Description Default
state bool

If True, include state in dictionary, defaults to True.

True

Returns:

Type Description
dict[str, Any]

dict[str, Any]: Dictionary containing device information.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_dict(self, state: bool = True) -> dict[str, Any]:
    """Return device information as a dictionary.

    Args:
        state (bool): If True, include state in dictionary, defaults to True.

    Returns:
        dict[str, Any]: Dictionary containing device information.
    """
    device_dict = {
        "device_name": self.device_name,
        "product_type": self.product_type,
        "model": self.device_type,
        "subdevice_no": str(self.sub_device_no),
        "type": self.type,
        "cid": self.cid,
        "features:": self.features,
        "config_module": self.config_module,
        "connection_type": self.connection_type,
        "last_response": self.last_response,
    }
    state_dict = self.state.to_dict() if state else {}
    return device_dict | state_dict

to_json

to_json(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Print JSON API string for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
str str

JSON formatted string of device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_json(self, state: bool = True, indent: bool = True) -> str:
    """Print JSON API string for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        str: JSON formatted string of device details.
    """
    return self.to_jsonb(state, indent).decode()

to_jsonb

to_jsonb(state: bool = True, indent: bool = True) -> bytes

Inherited From VeSyncBaseDevice

JSON API bytes for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
bytes bytes

JSON formatted bytes of device details.

Example

This is an example without state.

{
    "Device Name": "Living Room Lamp",
    "Model": "ESL100",
    "Subdevice No": "0",
    "Type": "wifi",
    "CID": "1234567890abcdef"
}

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_jsonb(self, state: bool = True, indent: bool = True) -> bytes:
    """JSON API bytes for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        bytes: JSON formatted bytes of device details.

    Example:
        This is an example without state.
        ```
        {
            "Device Name": "Living Room Lamp",
            "Model": "ESL100",
            "Subdevice No": "0",
            "Type": "wifi",
            "CID": "1234567890abcdef"
        }
        ```
    """
    return_dict = self.to_dict(state=state)
    if indent:
        return orjson.dumps(
            return_dict,
            option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS,
        )

    return orjson.dumps(return_dict, option=orjson.OPT_NON_STR_KEYS)

toggle_child_lock async

toggle_child_lock(toggle: bool | None = None) -> bool

Inherited From VeSyncPurifier

Toggle Child Lock (Display Lock).

Parameters:

Name Type Description Default
toggle bool | None

Toggle child lock. If None, toggle state.

None
Source code in src\pyvesync\base_devices\purifier_base.py
async def toggle_child_lock(self, toggle: bool | None = None) -> bool:
    """Toggle Child Lock (Display Lock).

    Args:
        toggle (bool | None): Toggle child lock. If None, toggle state.
    """
    del toggle
    logger.debug("Child lock not configured for this device.")
    return False

toggle_display async

toggle_display(mode: bool) -> bool

Inherited From VeSyncPurifier

Set Display Mode.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_display(self, mode: bool) -> bool:
    update_dict = {
        "status": "on" if mode else "off"
    }
    # body = self._build_request('airPurifierScreenCtl', update_dict=update_dict)
    # headers = Helpers.req_header_bypass()

    # r_dict, _ = await self.manager.async_call_api(
    #     '/cloud/v1/deviceManaged/airPurifierScreenCtl', 'post',
    #     json_object=body.to_dict(), headers=headers
    # )
    r_dict = await self.call_bypassv1_api(
        RequestPurifier131, method="airPurifierScreenCtl",
        endpoint="airPurifierScreenCtl", update_dict=update_dict
    )
    r = Helpers.process_dev_response(_LOGGER, "toggle_display", self, r_dict)
    if r is None:
        return False

    self.state.display_set_state = DeviceStatus.from_bool(mode)
    self.state.display_status = DeviceStatus.from_bool(mode)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_light_detection async

toggle_light_detection(toggle: bool | None = None) -> bool

Inherited From VeSyncPurifier

Set Light Detection Mode.

Parameters:

Name Type Description Default
toggle bool | None

Toggle light detection. If None, toggle state.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
async def toggle_light_detection(self, toggle: bool | None = None) -> bool:
    """Set Light Detection Mode.

    Args:
        toggle (bool | None): Toggle light detection. If None, toggle state.

    Returns:
        bool: True if successful, False otherwise.
    """
    del toggle
    if not self.supports_light_detection:
        logger.debug("Light detection not supported for this device.")
    else:
        logger.debug("Light detection not configured for this device.")
    return False

toggle_switch async

toggle_switch(toggle: bool | None = None) -> bool

Inherited From VeSyncBaseToggleDevice

Toggle device power on or off.

Parameters:

Name Type Description Default
toggle bool | None

True to turn on, False to turn off, None to toggle.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncpurifier.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.device_status != DeviceStatus.ON

    update_dict = {
        "status": DeviceStatus.from_bool(toggle).value
    }
    # body = self._build_request('airPurifierPowerSwitchCtl', update_dict=update_dict)
    # headers = Helpers.req_header_bypass()
    # r_dict, _ = await self.manager.async_call_api(
    #     '/cloud/v1/deviceManaged/airPurifierPowerSwitchCtl', 'post',
    #     json_object=body.to_dict(), headers=headers
    # )
    r_dict = await self.call_bypassv1_api(
        RequestPurifier131, method="airPurifierPowerSwitchCtl",
        endpoint="airPurifierPowerSwitchCtl", update_dict=update_dict
    )
    r = Helpers.process_dev_response(_LOGGER, "toggle_switch", self, r_dict)
    if r is None:
        return False

    self.state.device_status = DeviceStatus.from_bool(toggle)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

turbo_mode async deprecated

turbo_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_turbo_mode instead.

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_turbo_mode instead.")
async def turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    return await self.set_turbo_mode()

turn_off async

turn_off() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device off.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_off(self) -> bool:
    """Turn device off."""
    return await self.toggle_switch(False)

turn_off_child_lock async

turn_off_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to OFF.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_child_lock(self) -> bool:
    """Set child lock (display lock) to OFF."""
    return await self.toggle_child_lock(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncPurifier

Turn off Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off Display."""
    return await self.toggle_display(False)

turn_off_light_detection async

turn_off_light_detection() -> bool

Inherited From VeSyncPurifier

Turn off Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_light_detection(self) -> bool:
    """Turn off Light Detection."""
    return await self.toggle_light_detection(False)

turn_off_nightlight async

turn_off_nightlight() -> bool

Inherited From VeSyncPurifier

Turn off Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_nightlight(self) -> bool:
    """Turn off Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.OFF)

turn_on async

turn_on() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device on.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_on(self) -> bool:
    """Turn device on."""
    return await self.toggle_switch(True)

turn_on_child_lock async

turn_on_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to ON.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_child_lock(self) -> bool:
    """Set child lock (display lock) to ON."""
    return await self.toggle_child_lock(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncPurifier

Turn on Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on Display."""
    return await self.toggle_display(True)

turn_on_light_detection async

turn_on_light_detection() -> bool

Inherited From VeSyncPurifier

Turn on Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_light_detection(self) -> bool:
    """Turn on Light Detection."""
    return await self.toggle_light_detection(True)

turn_on_nightlight async

turn_on_nightlight() -> bool

Inherited From VeSyncPurifier

Turn on Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_nightlight(self) -> bool:
    """Turn on Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.ON)

update async

update() -> None

Inherited From VeSyncBaseDevice

Update device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def update(self) -> None:
    """Update device details."""
    await self.get_details()

pyvesync.base_devices.purifier_base.VeSyncPurifier

Bases: VeSyncBaseToggleDevice

Base device for vesync air purifiers.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

Device details from API.

required
manager VeSync

VeSync manager instance.

required
feature_map PurifierMap

Feature map for the device.

required

Attributes:

Name Type Description
state PurifierState

State of the device.

last_response ResponseInfo

Last response from API call.

manager VeSync

Manager object for API calls.

device_name str

Name of device.

device_image str

URL for device image.

cid str

Device ID.

connection_type str

Connection type of device.

device_type str

Type of device.

type str

Type of device.

uuid str

UUID of device, not always present.

config_module str

Configuration module of device.

mac_id str

MAC ID of device.

current_firm_version str

Current firmware version of device.

device_region str

Region of device. (US, EU, etc.)

pid str

Product ID of device, pulled by some devices on update.

sub_device_no int

Sub-device number of device.

product_type str

Product type of device.

features dict

Features of device.

modes list[str]

List of modes supported by the device.

fan_levels list[int]

List of fan levels supported by the device.

nightlight_modes list[str]

List of nightlight modes supported by the device.

auto_preferences list[str]

List of auto preferences supported by the device.

Source code in src\pyvesync\base_devices\purifier_base.py
class VeSyncPurifier(VeSyncBaseToggleDevice):
    """Base device for vesync air purifiers.

    Args:
        details (ResponseDeviceDetailsModel): Device details from API.
        manager (VeSync): VeSync manager instance.
        feature_map (PurifierMap): Feature map for the device.

    Attributes:
        state (PurifierState): State of the device.
        last_response (ResponseInfo): Last response from API call.
        manager (VeSync): Manager object for API calls.
        device_name (str): Name of device.
        device_image (str): URL for device image.
        cid (str): Device ID.
        connection_type (str): Connection type of device.
        device_type (str): Type of device.
        type (str): Type of device.
        uuid (str): UUID of device, not always present.
        config_module (str): Configuration module of device.
        mac_id (str): MAC ID of device.
        current_firm_version (str): Current firmware version of device.
        device_region (str): Region of device. (US, EU, etc.)
        pid (str): Product ID of device, pulled by some devices on update.
        sub_device_no (int): Sub-device number of device.
        product_type (str): Product type of device.
        features (dict): Features of device.
        modes (list[str]): List of modes supported by the device.
        fan_levels (list[int]): List of fan levels supported by the device.
        nightlight_modes (list[str]): List of nightlight modes supported by the device.
        auto_preferences (list[str]): List of auto preferences supported by the device.
    """

    __slots__ = (
        "auto_preferences",
        "fan_levels",
        "modes",
        "nightlight_modes"
    )

    def __init__(
        self,
        details: ResponseDeviceDetailsModel,
        manager: VeSync,
        feature_map: PurifierMap,
    ) -> None:
        """Initialize VeSync Purifier Base Class."""
        super().__init__(details, manager, feature_map)
        self.features: list[str] = feature_map.features
        self.state: PurifierState = PurifierState(self, details, feature_map)
        self.modes: list[str] = feature_map.modes
        self.fan_levels: list[int] = feature_map.fan_levels
        self.nightlight_modes: list[str] = feature_map.nightlight_modes
        self.auto_preferences: list[str] = feature_map.auto_preferences

    @property
    def supports_air_quality(self) -> bool:
        """Return True if device supports air quality."""
        return PurifierFeatures.AIR_QUALITY in self.features

    @property
    def supports_fan_rotate(self) -> bool:
        """Return True if device supports fan rotation."""
        return PurifierFeatures.VENT_ANGLE in self.features

    @property
    def supports_nightlight(self) -> bool:
        """Return True if device supports nightlight."""
        return PurifierFeatures.NIGHTLIGHT in self.features

    @property
    def supports_light_detection(self) -> bool:
        """Returns True if device supports light detection."""
        return PurifierFeatures.LIGHT_DETECT in self.features

    async def toggle_display(self, mode: bool) -> bool:
        """Set Display Mode."""
        del mode
        raise NotImplementedError

    async def turn_on_display(self) -> bool:
        """Turn on Display."""
        return await self.toggle_display(True)

    async def turn_off_display(self) -> bool:
        """Turn off Display."""
        return await self.toggle_display(False)

    async def set_nightlight_mode(self, mode: str) -> bool:
        """Set Nightlight Mode.

        Modes are defined in the `device.nightlight_modes` attribute.

        Args:
            mode (str): Nightlight mode to set.

        Returns:
            bool: True if successful, False otherwise.
        """
        del mode
        return False

    async def set_nightlight_dim(self) -> bool:
        """Set Nightlight Dim."""
        return await self.set_nightlight_mode(NightlightModes.DIM)

    async def turn_on_nightlight(self) -> bool:
        """Turn on Nightlight."""
        return await self.set_nightlight_mode(NightlightModes.ON)

    async def turn_off_nightlight(self) -> bool:
        """Turn off Nightlight."""
        return await self.set_nightlight_mode(NightlightModes.OFF)

    async def toggle_child_lock(self, toggle: bool | None = None) -> bool:
        """Toggle Child Lock (Display Lock).

        Args:
            toggle (bool | None): Toggle child lock. If None, toggle state.
        """
        del toggle
        logger.debug("Child lock not configured for this device.")
        return False

    async def turn_on_child_lock(self) -> bool:
        """Set child lock (display lock) to ON."""
        return await self.toggle_child_lock(True)

    async def turn_off_child_lock(self) -> bool:
        """Set child lock (display lock) to OFF."""
        return await self.toggle_child_lock(False)

    @abstractmethod
    async def set_mode(self, mode: str) -> bool:
        """Set Purifier Mode.

        Allowed modes are found in the `device.modes` attribute.

        Args:
            mode (str): Mode to set.

        Returns:
            bool: True if successful, False otherwise.
        """

    @abstractmethod
    async def set_fan_speed(self, speed: int | None = None) -> bool:
        """Set Purifier Fan Speed.

        Args:
            speed (int | None): Fan speed to set. If None, use default speed.

        Returns:
            bool: True if successful, False otherwise.
        """

    async def set_auto_mode(self) -> bool:
        """Set Purifier to Auto Mode."""
        if PurifierModes.AUTO in self.modes:
            return await self.set_mode(PurifierModes.AUTO)
        logger.error("Auto mode not supported for this device.")
        return False

    async def set_sleep_mode(self) -> bool:
        """Set Purifier to Sleep Mode."""
        if PurifierModes.SLEEP in self.modes:
            return await self.set_mode(PurifierModes.SLEEP)
        logger.error("Sleep mode not supported for this device.")
        return False

    async def set_manual_mode(self) -> bool:
        """Set Purifier to Manual Mode."""
        if PurifierModes.MANUAL in self.modes:
            return await self.set_mode(PurifierModes.MANUAL)
        logger.error("Manual mode not supported for this device.")
        return False

    async def set_turbo_mode(self) -> bool:
        """Set Purifier to Turbo Mode."""
        if PurifierModes.TURBO in self.modes:
            return await self.set_mode(PurifierModes.TURBO)
        logger.error("Turbo mode not supported for this device.")
        return False

    async def set_pet_mode(self) -> bool:
        """Set Purifier to Pet Mode."""
        if PurifierModes.PET in self.modes:
            return await self.set_mode(PurifierModes.PET)
        logger.error("Pet mode not supported for this device.")
        return False

    async def set_auto_preference(self, preference: str, room_size: int = 800) -> bool:
        """Set auto preference.

        Args:
            preference (str): Auto preference to set, available preference is
                found in `self.auto_preferences`.
            room_size (int): Room size to set, defaults to 800ft2.

        Returns:
            bool: True if successful, False otherwise.
        """
        del preference, room_size
        logger.debug("Auto preference not configured for this device.")
        return False

    async def toggle_light_detection(self, toggle: bool | None = None) -> bool:
        """Set Light Detection Mode.

        Args:
            toggle (bool | None): Toggle light detection. If None, toggle state.

        Returns:
            bool: True if successful, False otherwise.
        """
        del toggle
        if not self.supports_light_detection:
            logger.debug("Light detection not supported for this device.")
        else:
            logger.debug("Light detection not configured for this device.")
        return False

    async def turn_on_light_detection(self) -> bool:
        """Turn on Light Detection."""
        return await self.toggle_light_detection(True)

    async def turn_off_light_detection(self) -> bool:
        """Turn off Light Detection."""
        return await self.toggle_light_detection(False)

    async def reset_filter(self) -> bool:
        """Reset filter life."""
        logger.debug("Filter life reset not configured for this device.")
        return False

    @deprecated("Use set_auto_mode instead.")
    async def auto_mode(self) -> bool:
        """Set Purifier to Auto Mode."""
        return await self.set_auto_mode()

    @deprecated("Use set_sleep_mode instead.")
    async def sleep_mode(self) -> bool:
        """Set Purifier to Sleep Mode."""
        return await self.set_sleep_mode()

    @deprecated("Use set_manual_mode instead.")
    async def manual_mode(self) -> bool:
        """Set Purifier to Manual Mode."""
        return await self.set_manual_mode()

    @deprecated("Use set_turbo_mode instead.")
    async def turbo_mode(self) -> bool:
        """Set Purifier to Turbo Mode."""
        return await self.set_turbo_mode()

    @deprecated("Use set_pet_mode instead.")
    async def pet_mode(self) -> bool:
        """Set Purifier to Pet Mode."""
        return await self.set_pet_mode()

    @deprecated("Use set_nightlight_mode instead.")
    async def nightlight_mode(self, mode: str) -> bool:
        """Set Nightlight Mode."""
        return await self.set_nightlight_mode(mode)

    @deprecated("Use `set_fan_speed()` instead.")
    async def change_fan_speed(self, speed: int | None = None) -> bool:
        """Deprecated method for changing fan speed."""
        return await self.set_fan_speed(speed)

    @deprecated("Use `set_mode(mode: str)` instead.")
    async def change_mode(self, mode: str) -> bool:
        """Deprecated method for changing purifier mode."""
        return await self.set_mode(mode)

    @deprecated("Use `toggle_child_lock()` instead.")
    async def set_child_lock(self, toggle: bool) -> bool:
        """Set child lock (display lock).

        This has been deprecated in favor of `toggle_child_lock()`.
        """
        return await self.toggle_child_lock(toggle)

    @deprecated("Use `turn_on_child_lock()` instead.")
    async def child_lock_on(self) -> bool:
        """Turn on child lock (display lock).

        This has been deprecated, use `turn_on_child_lock()` instead.
        """
        return await self.toggle_child_lock(True)

    @deprecated("Use `turn_off_child_lock()` instead.")
    async def child_lock_off(self) -> bool:
        """Turn off child lock (display lock).

        This has been deprecated, use `turn_off_child_lock()` instead.
        """
        return await self.toggle_child_lock(False)

    @property
    @deprecated("Use self.state.child_lock instead.")
    def child_lock(self) -> bool:
        """Get child lock state.

        Returns:
            bool : True if child lock is enabled, False if not.
        """
        return self.state.child_lock

    @property
    @deprecated("Use self.state.nightlight_status instead.")
    def night_light(self) -> str:
        """Get night light state.

        Returns:
            str : Night light state (on, dim, off)
        """
        return self.state.nightlight_status

    @deprecated("Use turn_on_light_detection() instead.")
    async def set_light_detection_on(self) -> bool:
        """Turn on light detection feature."""
        return await self.toggle_light_detection(True)

    @deprecated("Use turn_off_light_detection() instead.")
    async def set_light_detection_off(self) -> bool:
        """Turn off light detection feature."""
        return await self.toggle_light_detection(False)

Attributes

auto_preferences instance-attribute

auto_preferences: list[str] = auto_preferences

Inherited From VeSyncPurifier

child_lock property

child_lock: bool

Inherited From VeSyncPurifier

Get child lock state.

Returns:

Name Type Description
bool bool

True if child lock is enabled, False if not.

cid instance-attribute

cid: str = cid

Inherited From VeSyncBaseDevice

config_module instance-attribute

config_module: str = configModule

Inherited From VeSyncBaseDevice

connection_type instance-attribute

connection_type: str | None = connectionType

Inherited From VeSyncBaseDevice

current_firm_version instance-attribute

current_firm_version = currentFirmVersion

Inherited From VeSyncBaseDevice

device_image instance-attribute

device_image: str | None = deviceImg

Inherited From VeSyncBaseDevice

device_name instance-attribute

device_name: str = deviceName

Inherited From VeSyncBaseDevice

device_region instance-attribute

device_region: str | None = deviceRegion

Inherited From VeSyncBaseDevice

device_type instance-attribute

device_type: str = deviceType

Inherited From VeSyncBaseDevice

enabled instance-attribute

enabled: bool = True

Inherited From VeSyncBaseDevice

fan_levels instance-attribute

fan_levels: list[int] = fan_levels

Inherited From VeSyncPurifier

features instance-attribute

features: list[str] = features

Inherited From VeSyncBaseDevice

firmware_update property

firmware_update: bool

Inherited From VeSyncBaseDevice

Return True if firmware update available.

This is going to be updated.

is_on property

is_on: bool

Inherited From VeSyncBaseDevice

Return true if device is on.

last_response instance-attribute

last_response: ResponseInfo | None = None

Inherited From VeSyncBaseDevice

mac_id instance-attribute

mac_id: str | None = macID

Inherited From VeSyncBaseDevice

manager instance-attribute

manager = manager

Inherited From VeSyncBaseDevice

modes instance-attribute

modes: list[str] = modes

Inherited From VeSyncPurifier

night_light property

night_light: str

Inherited From VeSyncPurifier

Get night light state.

Returns:

Name Type Description
str str

Night light state (on, dim, off)

nightlight_modes instance-attribute

nightlight_modes: list[str] = nightlight_modes

Inherited From VeSyncPurifier

pid instance-attribute

pid: str | None = None

Inherited From VeSyncBaseDevice

product_type instance-attribute

product_type: str = product_type

Inherited From VeSyncBaseDevice

state instance-attribute

state: PurifierState = PurifierState(
    self, details, feature_map
)

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_air_quality property

supports_air_quality: bool

Inherited From VeSyncPurifier

Return True if device supports air quality.

supports_fan_rotate property

supports_fan_rotate: bool

Inherited From VeSyncPurifier

Return True if device supports fan rotation.

supports_light_detection property

supports_light_detection: bool

Inherited From VeSyncPurifier

Returns True if device supports light detection.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncPurifier

Return True if device supports nightlight.

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

Functions

auto_mode async deprecated

auto_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_auto_mode instead.

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_auto_mode instead.")
async def auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    return await self.set_auto_mode()

change_fan_speed async deprecated

change_fan_speed(speed: int | None = None) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_fan_speed() instead.

Deprecated method for changing fan speed.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_fan_speed()` instead.")
async def change_fan_speed(self, speed: int | None = None) -> bool:
    """Deprecated method for changing fan speed."""
    return await self.set_fan_speed(speed)

change_mode async deprecated

change_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_mode(mode: str) instead.

Deprecated method for changing purifier mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `set_mode(mode: str)` instead.")
async def change_mode(self, mode: str) -> bool:
    """Deprecated method for changing purifier mode."""
    return await self.set_mode(mode)

child_lock_off async deprecated

child_lock_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_child_lock() instead.

Turn off child lock (display lock).

This has been deprecated, use turn_off_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_off_child_lock()` instead.")
async def child_lock_off(self) -> bool:
    """Turn off child lock (display lock).

    This has been deprecated, use `turn_off_child_lock()` instead.
    """
    return await self.toggle_child_lock(False)

child_lock_on async deprecated

child_lock_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_child_lock() instead.

Turn on child lock (display lock).

This has been deprecated, use turn_on_child_lock() instead.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `turn_on_child_lock()` instead.")
async def child_lock_on(self) -> bool:
    """Turn on child lock (display lock).

    This has been deprecated, use `turn_on_child_lock()` instead.
    """
    return await self.toggle_child_lock(True)

clear_timer async

clear_timer() -> bool

Inherited From VeSyncBaseDevice

Clear timer for device from API.

This may not be implemented for all devices. Please open an issue if there is an error.

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def clear_timer(self) -> bool:
    """Clear timer for device from API.

    This may not be implemented for all devices. Please open an issue
    if there is an error.

    Returns:
        bool: True if successful, False otherwise.
    """
    logger.debug('Not implemented - clear_timer')
    return False

display

display(state: bool = True) -> None

Inherited From VeSyncBaseDevice

Print formatted static device info to stdout.

Parameters:

Name Type Description Default
state bool

If True, include state in display, defaults to True.

True

Example:

Device Name:..................Living Room Lamp
Model:........................ESL100
Subdevice No:.................0
Type:.........................wifi
CID:..........................1234567890abcdef

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def display(self, state: bool = True) -> None:
    """Print formatted static device info to stdout.

    Args:
        state (bool): If True, include state in display, defaults to True.

    Example:
    ```
    Device Name:..................Living Room Lamp
    Model:........................ESL100
    Subdevice No:.................0
    Type:.........................wifi
    CID:..........................1234567890abcdef
    ```
    """
    # noinspection SpellCheckingInspection
    display_list = [
        ('Device Name:', self.device_name),
        ('Product Type: ', self.product_type),
        ('Model: ', self.device_type),
        ('Subdevice No: ', str(self.sub_device_no)),
        ('Type: ', self.type),
        ('CID: ', self.cid),
        ('Config Module: ', self.config_module),
        ('Connection Type: ', self.connection_type),
        ('Features', self.features),
        ('Last Response: ', self.last_response),
    ]
    if self.uuid is not None:
        display_list.append(('UUID: ', self.uuid))

    for line in display_list:
        print(f'{line[0]:.<30} {line[1]}')
    if state:
        self.state.display()

displayJSON deprecated

displayJSON(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Deprecated

Use to_json() instead

Return JSON details for device. - Deprecated use to_json().

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
@deprecated("Use to_json() instead")
def displayJSON(self, state: bool = True, indent: bool = True) -> str:  # pylint: disable=invalid-name
    """Return JSON details for device. - Deprecated use to_json()."""
    return self.to_json(state, indent)

get_details abstractmethod async

get_details() -> None

Inherited From VeSyncBaseDevice

Get device details.

This method is defined in each device class to contain the logic to pull the device state from the API and update the device's state attribute. The update() method should be called to update the device state.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
@abstractmethod
async def get_details(self) -> None:
    """Get device details.

    This method is defined in each device class to contain
    the logic to pull the device state from the API and update
    the device's `state` attribute. The `update()` method should
    be called to update the device state.
    """

get_state

get_state(state_attr: str) -> Any

Inherited From VeSyncBaseDevice

Get device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def get_state(self, state_attr: str) -> Any:  # noqa: ANN401
    """Get device state attribute."""
    return getattr(self.state, state_attr)

get_timer async

get_timer() -> Timer | None

Inherited From VeSyncBaseDevice

Get timer for device from API and set the state.Timer attribute.

This may not be implemented for all devices. Please open an issue if there is an error.

Note

This method may not be implemented for all devices. Please open an issue if there is an error.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def get_timer(self) -> Timer | None:
    """Get timer for device from API and set the `state.Timer` attribute.

    This may not be implemented for all devices. Please open an issue
    if there is an error.

    Note:
        This method may not be implemented for all devices. Please
        open an issue if there is an error.
    """
    logger.debug('Not implemented - get_timer')
    return None

manual_mode async deprecated

manual_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_manual_mode instead.

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_manual_mode instead.")
async def manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    return await self.set_manual_mode()

nightlight_mode async deprecated

nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_nightlight_mode instead.

Set Nightlight Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_nightlight_mode instead.")
async def nightlight_mode(self, mode: str) -> bool:
    """Set Nightlight Mode."""
    return await self.set_nightlight_mode(mode)

pet_mode async deprecated

pet_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_pet_mode instead.

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_pet_mode instead.")
async def pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    return await self.set_pet_mode()

reset_filter async

reset_filter() -> bool

Inherited From VeSyncPurifier

Reset filter life.

Source code in src\pyvesync\base_devices\purifier_base.py
async def reset_filter(self) -> bool:
    """Reset filter life."""
    logger.debug("Filter life reset not configured for this device.")
    return False

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Auto Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Purifier to Auto Mode."""
    if PurifierModes.AUTO in self.modes:
        return await self.set_mode(PurifierModes.AUTO)
    logger.error("Auto mode not supported for this device.")
    return False

set_auto_preference async

set_auto_preference(
    preference: str, room_size: int = 800
) -> bool

Inherited From VeSyncPurifier

Set auto preference.

Parameters:

Name Type Description Default
preference str

Auto preference to set, available preference is found in self.auto_preferences.

required
room_size int

Room size to set, defaults to 800ft2.

800

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_auto_preference(self, preference: str, room_size: int = 800) -> bool:
    """Set auto preference.

    Args:
        preference (str): Auto preference to set, available preference is
            found in `self.auto_preferences`.
        room_size (int): Room size to set, defaults to 800ft2.

    Returns:
        bool: True if successful, False otherwise.
    """
    del preference, room_size
    logger.debug("Auto preference not configured for this device.")
    return False

set_child_lock async deprecated

set_child_lock(toggle: bool) -> bool

Inherited From VeSyncPurifier

Deprecated

Use toggle_child_lock() instead.

Set child lock (display lock).

This has been deprecated in favor of toggle_child_lock().

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use `toggle_child_lock()` instead.")
async def set_child_lock(self, toggle: bool) -> bool:
    """Set child lock (display lock).

    This has been deprecated in favor of `toggle_child_lock()`.
    """
    return await self.toggle_child_lock(toggle)

set_fan_speed abstractmethod async

set_fan_speed(speed: int | None = None) -> bool

Set Purifier Fan Speed.

Parameters:

Name Type Description Default
speed int | None

Fan speed to set. If None, use default speed.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
@abstractmethod
async def set_fan_speed(self, speed: int | None = None) -> bool:
    """Set Purifier Fan Speed.

    Args:
        speed (int | None): Fan speed to set. If None, use default speed.

    Returns:
        bool: True if successful, False otherwise.
    """

set_light_detection_off async deprecated

set_light_detection_off() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_off_light_detection() instead.

Turn off light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_off_light_detection() instead.")
async def set_light_detection_off(self) -> bool:
    """Turn off light detection feature."""
    return await self.toggle_light_detection(False)

set_light_detection_on async deprecated

set_light_detection_on() -> bool

Inherited From VeSyncPurifier

Deprecated

Use turn_on_light_detection() instead.

Turn on light detection feature.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use turn_on_light_detection() instead.")
async def set_light_detection_on(self) -> bool:
    """Turn on light detection feature."""
    return await self.toggle_light_detection(True)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Manual Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Purifier to Manual Mode."""
    if PurifierModes.MANUAL in self.modes:
        return await self.set_mode(PurifierModes.MANUAL)
    logger.error("Manual mode not supported for this device.")
    return False

set_mode abstractmethod async

set_mode(mode: str) -> bool

Set Purifier Mode.

Allowed modes are found in the device.modes attribute.

Parameters:

Name Type Description Default
mode str

Mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
@abstractmethod
async def set_mode(self, mode: str) -> bool:
    """Set Purifier Mode.

    Allowed modes are found in the `device.modes` attribute.

    Args:
        mode (str): Mode to set.

    Returns:
        bool: True if successful, False otherwise.
    """

set_nightlight_dim async

set_nightlight_dim() -> bool

Inherited From VeSyncPurifier

Set Nightlight Dim.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_nightlight_dim(self) -> bool:
    """Set Nightlight Dim."""
    return await self.set_nightlight_mode(NightlightModes.DIM)

set_nightlight_mode async

set_nightlight_mode(mode: str) -> bool

Inherited From VeSyncPurifier

Set Nightlight Mode.

Modes are defined in the device.nightlight_modes attribute.

Parameters:

Name Type Description Default
mode str

Nightlight mode to set.

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_nightlight_mode(self, mode: str) -> bool:
    """Set Nightlight Mode.

    Modes are defined in the `device.nightlight_modes` attribute.

    Args:
        mode (str): Nightlight mode to set.

    Returns:
        bool: True if successful, False otherwise.
    """
    del mode
    return False

set_pet_mode async

set_pet_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Pet Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_pet_mode(self) -> bool:
    """Set Purifier to Pet Mode."""
    if PurifierModes.PET in self.modes:
        return await self.set_mode(PurifierModes.PET)
    logger.error("Pet mode not supported for this device.")
    return False

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    if PurifierModes.SLEEP in self.modes:
        return await self.set_mode(PurifierModes.SLEEP)
    logger.error("Sleep mode not supported for this device.")
    return False

set_state

set_state(state_attr: str, stat_value: Any) -> None

Inherited From VeSyncBaseDevice

Set device state attribute.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def set_state(self, state_attr: str, stat_value: Any) -> None:  # noqa: ANN401
    """Set device state attribute."""
    setattr(self, state_attr, stat_value)

set_timer async

set_timer(duration: int, action: str | None = None) -> bool

Inherited From VeSyncBaseDevice

Set timer for device.

This may not be implemented for all devices. Please open an issue if there is an error.

Parameters:

Name Type Description Default
duration int

Duration in seconds.

required
action str | None

Action to take when timer expires.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    """Set timer for device.

    This may not be implemented for all devices. Please open an issue
    if there is an error.

    Args:
        duration (int): Duration in seconds.
        action (str | None): Action to take when timer expires.

    Returns:
        bool: True if successful, False otherwise.
    """
    del duration
    del action
    logger.debug('Not implemented - set_timer')
    return False

set_turbo_mode async

set_turbo_mode() -> bool

Inherited From VeSyncPurifier

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def set_turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    if PurifierModes.TURBO in self.modes:
        return await self.set_mode(PurifierModes.TURBO)
    logger.error("Turbo mode not supported for this device.")
    return False

sleep_mode async deprecated

sleep_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_sleep_mode instead.

Set Purifier to Sleep Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_sleep_mode instead.")
async def sleep_mode(self) -> bool:
    """Set Purifier to Sleep Mode."""
    return await self.set_sleep_mode()

to_dict

to_dict(state: bool = True) -> dict[str, Any]

Inherited From VeSyncBaseDevice

Return device information as a dictionary.

Parameters:

Name Type Description Default
state bool

If True, include state in dictionary, defaults to True.

True

Returns:

Type Description
dict[str, Any]

dict[str, Any]: Dictionary containing device information.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_dict(self, state: bool = True) -> dict[str, Any]:
    """Return device information as a dictionary.

    Args:
        state (bool): If True, include state in dictionary, defaults to True.

    Returns:
        dict[str, Any]: Dictionary containing device information.
    """
    device_dict = {
        "device_name": self.device_name,
        "product_type": self.product_type,
        "model": self.device_type,
        "subdevice_no": str(self.sub_device_no),
        "type": self.type,
        "cid": self.cid,
        "features:": self.features,
        "config_module": self.config_module,
        "connection_type": self.connection_type,
        "last_response": self.last_response,
    }
    state_dict = self.state.to_dict() if state else {}
    return device_dict | state_dict

to_json

to_json(state: bool = True, indent: bool = True) -> str

Inherited From VeSyncBaseDevice

Print JSON API string for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
str str

JSON formatted string of device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_json(self, state: bool = True, indent: bool = True) -> str:
    """Print JSON API string for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        str: JSON formatted string of device details.
    """
    return self.to_jsonb(state, indent).decode()

to_jsonb

to_jsonb(state: bool = True, indent: bool = True) -> bytes

Inherited From VeSyncBaseDevice

JSON API bytes for device details.

Parameters:

Name Type Description Default
state bool

If True, include state in JSON output, defaults to True.

True
indent bool

If True, indent JSON output, defaults to True.

True

Returns:

Name Type Description
bytes bytes

JSON formatted bytes of device details.

Example

This is an example without state.

{
    "Device Name": "Living Room Lamp",
    "Model": "ESL100",
    "Subdevice No": "0",
    "Type": "wifi",
    "CID": "1234567890abcdef"
}

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
def to_jsonb(self, state: bool = True, indent: bool = True) -> bytes:
    """JSON API bytes for device details.

    Args:
        state (bool): If True, include state in JSON output, defaults to True.
        indent (bool): If True, indent JSON output, defaults to True.

    Returns:
        bytes: JSON formatted bytes of device details.

    Example:
        This is an example without state.
        ```
        {
            "Device Name": "Living Room Lamp",
            "Model": "ESL100",
            "Subdevice No": "0",
            "Type": "wifi",
            "CID": "1234567890abcdef"
        }
        ```
    """
    return_dict = self.to_dict(state=state)
    if indent:
        return orjson.dumps(
            return_dict,
            option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS,
        )

    return orjson.dumps(return_dict, option=orjson.OPT_NON_STR_KEYS)

toggle_child_lock async

toggle_child_lock(toggle: bool | None = None) -> bool

Inherited From VeSyncPurifier

Toggle Child Lock (Display Lock).

Parameters:

Name Type Description Default
toggle bool | None

Toggle child lock. If None, toggle state.

None
Source code in src\pyvesync\base_devices\purifier_base.py
async def toggle_child_lock(self, toggle: bool | None = None) -> bool:
    """Toggle Child Lock (Display Lock).

    Args:
        toggle (bool | None): Toggle child lock. If None, toggle state.
    """
    del toggle
    logger.debug("Child lock not configured for this device.")
    return False

toggle_display async

toggle_display(mode: bool) -> bool

Set Display Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
async def toggle_display(self, mode: bool) -> bool:
    """Set Display Mode."""
    del mode
    raise NotImplementedError

toggle_light_detection async

toggle_light_detection(toggle: bool | None = None) -> bool

Inherited From VeSyncPurifier

Set Light Detection Mode.

Parameters:

Name Type Description Default
toggle bool | None

Toggle light detection. If None, toggle state.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\purifier_base.py
async def toggle_light_detection(self, toggle: bool | None = None) -> bool:
    """Set Light Detection Mode.

    Args:
        toggle (bool | None): Toggle light detection. If None, toggle state.

    Returns:
        bool: True if successful, False otherwise.
    """
    del toggle
    if not self.supports_light_detection:
        logger.debug("Light detection not supported for this device.")
    else:
        logger.debug("Light detection not configured for this device.")
    return False

toggle_switch abstractmethod async

toggle_switch(toggle: bool | None = None) -> bool

Inherited From VeSyncBaseToggleDevice

Toggle device power on or off.

Parameters:

Name Type Description Default
toggle bool | None

True to turn on, False to turn off, None to toggle.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
@abstractmethod
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    """Toggle device power on or off.

    Args:
        toggle (bool | None): True to turn on, False to turn off, None to toggle.

    Returns:
        bool: True if successful, False otherwise.
    """

turbo_mode async deprecated

turbo_mode() -> bool

Inherited From VeSyncPurifier

Deprecated

Use set_turbo_mode instead.

Set Purifier to Turbo Mode.

Source code in src\pyvesync\base_devices\purifier_base.py
@deprecated("Use set_turbo_mode instead.")
async def turbo_mode(self) -> bool:
    """Set Purifier to Turbo Mode."""
    return await self.set_turbo_mode()

turn_off async

turn_off() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device off.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_off(self) -> bool:
    """Turn device off."""
    return await self.toggle_switch(False)

turn_off_child_lock async

turn_off_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to OFF.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_child_lock(self) -> bool:
    """Set child lock (display lock) to OFF."""
    return await self.toggle_child_lock(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncPurifier

Turn off Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off Display."""
    return await self.toggle_display(False)

turn_off_light_detection async

turn_off_light_detection() -> bool

Inherited From VeSyncPurifier

Turn off Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_light_detection(self) -> bool:
    """Turn off Light Detection."""
    return await self.toggle_light_detection(False)

turn_off_nightlight async

turn_off_nightlight() -> bool

Inherited From VeSyncPurifier

Turn off Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_off_nightlight(self) -> bool:
    """Turn off Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.OFF)

turn_on async

turn_on() -> bool

Inherited From VeSyncBaseToggleDevice

Turn device on.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def turn_on(self) -> bool:
    """Turn device on."""
    return await self.toggle_switch(True)

turn_on_child_lock async

turn_on_child_lock() -> bool

Inherited From VeSyncPurifier

Set child lock (display lock) to ON.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_child_lock(self) -> bool:
    """Set child lock (display lock) to ON."""
    return await self.toggle_child_lock(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncPurifier

Turn on Display.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on Display."""
    return await self.toggle_display(True)

turn_on_light_detection async

turn_on_light_detection() -> bool

Inherited From VeSyncPurifier

Turn on Light Detection.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_light_detection(self) -> bool:
    """Turn on Light Detection."""
    return await self.toggle_light_detection(True)

turn_on_nightlight async

turn_on_nightlight() -> bool

Inherited From VeSyncPurifier

Turn on Nightlight.

Source code in src\pyvesync\base_devices\purifier_base.py
async def turn_on_nightlight(self) -> bool:
    """Turn on Nightlight."""
    return await self.set_nightlight_mode(NightlightModes.ON)

update async

update() -> None

Inherited From VeSyncBaseDevice

Update device details.

Source code in src\pyvesync\base_devices\vesyncbasedevice.py
async def update(self) -> None:
    """Update device details."""
    await self.get_details()