Skip to content

VeSync Humidifiers

Contents

pyvesync.base_devices.humidifier_base.HumidifierState

Bases: DeviceState

State Class for VeSync Humidifiers.

This is the state class for all vesync humidifiers. If there are new features or state attributes, they should be added directly to this class and be set to the default NOT_SUPPORTED flag.

Attributes:

Name Type Description
auto_preference int

Auto preference level.

auto_stop_target_reached bool

Automatic stop target reached.

auto_target_humidity int

Target humidity level.

automatic_stop_config bool

Automatic stop configuration.

child_lock_status bool

Child lock status.

display_set_status str

Display set status.

display_status str

Display status.

drying_mode_auto_switch str

Drying mode auto switch status.

drying_mode_level int

Drying mode level.

drying_mode_status str

Drying mode status.

drying_mode_time_remain int

Drying mode time remaining.

filter_life_percent int

Filter life percentage.

humidity int

Current humidity level.

humidity_high bool

High humidity status.

mist_level int

Mist level.

mist_virtual_level int

Mist virtual level.

mode str

Current mode.

nightlight_brightness int

Nightlight brightness level.

nightlight_status str

Nightlight status.

temperature int

Current temperature.

warm_mist_enabled bool

Warm mist enabled status.

warm_mist_level int

Warm mist level.

water_lacks bool

Water lacks status.

water_tank_lifted bool

Water tank lifted status.

Source code in src\pyvesync\base_devices\humidifier_base.py
class HumidifierState(DeviceState):
    """State Class for VeSync Humidifiers.

    This is the state class for all vesync humidifiers. If there are
    new features or state attributes, they should be added directly to
    this class and be set to the default `NOT_SUPPORTED` flag.

    Attributes:
        auto_preference (int): Auto preference level.
        auto_stop_target_reached (bool): Automatic stop target reached.
        auto_target_humidity (int): Target humidity level.
        automatic_stop_config (bool): Automatic stop configuration.
        child_lock_status (bool): Child lock status.
        display_set_status (str): Display set status.
        display_status (str): Display status.
        drying_mode_auto_switch (str): Drying mode auto switch status.
        drying_mode_level (int): Drying mode level.
        drying_mode_status (str): Drying mode status.
        drying_mode_time_remain (int): Drying mode time remaining.
        filter_life_percent (int): Filter life percentage.
        humidity (int): Current humidity level.
        humidity_high (bool): High humidity status.
        mist_level (int): Mist level.
        mist_virtual_level (int): Mist virtual level.
        mode (str): Current mode.
        nightlight_brightness (int): Nightlight brightness level.
        nightlight_status (str): Nightlight status.
        temperature (int): Current temperature.
        warm_mist_enabled (bool): Warm mist enabled status.
        warm_mist_level (int): Warm mist level.
        water_lacks (bool): Water lacks status.
        water_tank_lifted (bool): Water tank lifted status.
    """

    __slots__ = (
        "auto_preference",
        "auto_stop_target_reached",
        "auto_target_humidity",
        "automatic_stop_config",
        "child_lock_status",
        "display_set_status",
        "display_status",
        "drying_mode_auto_switch",
        "drying_mode_level",
        "drying_mode_status",
        "drying_mode_time_remain",
        "filter_life_percent",
        "humidity",
        "humidity_high",
        "mist_level",
        "mist_virtual_level",
        "mode",
        "nightlight_brightness",
        "nightlight_status",
        "temperature",
        "warm_mist_enabled",
        "warm_mist_level",
        "water_lacks",
        "water_tank_lifted",
    )

    def __init__(self, device: VeSyncHumidifier, details: ResponseDeviceDetailsModel,
                 feature_map: HumidifierMap) -> None:
        """Initialize VeSync Humidifier State.

        This state class is used to store the current state of the humidifier.

        Args:
            device (VeSyncHumidifier): The device object.
            details (ResponseDeviceDetailsModel): The device details.
            feature_map (HumidifierMap): The feature map for the device.
        """
        super().__init__(device, details, feature_map)
        self.auto_stop_target_reached: bool = False
        self.auto_target_humidity: int = IntFlag.NOT_SUPPORTED
        self.automatic_stop_config: bool = False
        self.display_set_status: str = DeviceStatus.UNKNOWN
        self.display_status: str = DeviceStatus.UNKNOWN
        self.humidity: int = IntFlag.NOT_SUPPORTED
        self.humidity_high: bool = False
        self.mist_level: int | None = None
        self.mist_virtual_level: int | None = None
        self.mode: str = HumidifierModes.UNKNOWN
        self.nightlight_brightness: int = IntFlag.NOT_SUPPORTED
        self.nightlight_status: str = StrFlag.NOT_SUPPORTED
        self.warm_mist_enabled: bool | None = None
        self.warm_mist_level: int = IntFlag.NOT_SUPPORTED
        self.water_lacks: bool = False
        self.water_tank_lifted: bool = False
        self.temperature: int = IntFlag.NOT_SUPPORTED
        # Superior 6000S States
        self.auto_preference: int = IntFlag.NOT_SUPPORTED
        self.filter_life_percent: int = IntFlag.NOT_SUPPORTED
        self.drying_mode_level: int = IntFlag.NOT_SUPPORTED
        self.drying_mode_auto_switch: str = StrFlag.NOT_SUPPORTED
        self.drying_mode_status: str = StrFlag.NOT_SUPPORTED
        self.drying_mode_time_remain: int = IntFlag.NOT_SUPPORTED

    @property
    def automatic_stop(self) -> bool:
        """Return the automatic stop status.

        Returns:
            bool: True if automatic stop is enabled, False otherwise.
        """
        return self.automatic_stop_config

    @property
    @deprecated("Use auto_stop_target_reached instead.")
    def automatic_stop_target_reached(self) -> bool:
        """Deprecated function.

        Returns:
            bool: True if automatic stop target is reached, False otherwise.
        """
        return self.auto_stop_target_reached

    @property
    def target_humidity(self) -> int:
        """Return the target humidity level.

        Returns:
            int: Target humidity level.
        """
        return self.auto_target_humidity

    @property
    def auto_humidity(self) -> int:
        """Return the auto humidity level.

        Returns:
            int: Auto humidity level.
        """
        return self.auto_target_humidity

    @property
    def auto_enabled(self) -> bool:
        """Return True if auto mode is enabled."""
        return self.mode in [HumidifierModes.AUTO, self.mode, HumidifierModes.HUMIDITY]

    @property
    @deprecated("Use humidity property instead.")
    def humidity_level(self) -> int | None:
        """Deprecated function.

        Returns:
            int | None: Humidity level.
        """
        return self.humidity

    @property
    def drying_mode_state(self) -> str:
        """Return the drying mode state.

        Returns:
            str | None: Drying mode state.
        """
        return self.drying_mode_status

    @property
    def drying_mode_seconds_remaining(self) -> int:
        """Return the drying mode seconds remaining.

        Return:
            int | None: Drying mode seconds remaining.
        """
        return self.drying_mode_time_remain

    @property
    def drying_mode_enabled(self) -> bool:
        """Return True if drying mode is enabled.

        Returns:
            bool | None: True if drying mode is enabled, False otherwise.
        """
        return self.drying_mode_status == DeviceStatus.ON

Attributes

active_time instance-attribute

active_time: int | None = None

Inherited From DeviceState

auto_enabled property

auto_enabled: bool

Return True if auto mode is enabled.

auto_humidity property

auto_humidity: int

Return the auto humidity level.

Returns:

Name Type Description
int int

Auto humidity level.

auto_preference instance-attribute

auto_preference: int = NOT_SUPPORTED

auto_stop_target_reached instance-attribute

auto_stop_target_reached: bool = False

auto_target_humidity instance-attribute

auto_target_humidity: int = NOT_SUPPORTED

automatic_stop property

automatic_stop: bool

Return the automatic stop status.

Returns:

Name Type Description
bool bool

True if automatic stop is enabled, False otherwise.

automatic_stop_config instance-attribute

automatic_stop_config: bool = False

automatic_stop_target_reached property

automatic_stop_target_reached: bool

Deprecated function.

Returns:

Name Type Description
bool bool

True if automatic stop target is reached, False otherwise.

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_set_status instance-attribute

display_set_status: str = UNKNOWN

display_status instance-attribute

display_status: str = UNKNOWN

drying_mode_auto_switch instance-attribute

drying_mode_auto_switch: str = NOT_SUPPORTED

drying_mode_enabled property

drying_mode_enabled: bool

Return True if drying mode is enabled.

Returns:

Type Description
bool

bool | None: True if drying mode is enabled, False otherwise.

drying_mode_level instance-attribute

drying_mode_level: int = NOT_SUPPORTED

drying_mode_seconds_remaining property

drying_mode_seconds_remaining: int

Return the drying mode seconds remaining.

Return

int | None: Drying mode seconds remaining.

drying_mode_state property

drying_mode_state: str

Return the drying mode state.

Returns:

Type Description
str

str | None: Drying mode state.

drying_mode_status instance-attribute

drying_mode_status: str = NOT_SUPPORTED

drying_mode_time_remain instance-attribute

drying_mode_time_remain: int = NOT_SUPPORTED

features instance-attribute

features = features

Inherited From DeviceState

filter_life_percent instance-attribute

filter_life_percent: int = NOT_SUPPORTED

humidity instance-attribute

humidity: int = NOT_SUPPORTED

humidity_high instance-attribute

humidity_high: bool = False

humidity_level property

humidity_level: int | None

Deprecated function.

Returns:

Type Description
int | None

int | None: Humidity level.

last_update_ts instance-attribute

last_update_ts: int | None = None

Inherited From DeviceState

mist_level instance-attribute

mist_level: int | None = None

mist_virtual_level instance-attribute

mist_virtual_level: int | None = None

mode instance-attribute

mode: str = UNKNOWN

nightlight_brightness instance-attribute

nightlight_brightness: int = NOT_SUPPORTED

nightlight_status instance-attribute

nightlight_status: str = NOT_SUPPORTED

target_humidity property

target_humidity: int

Return the target humidity level.

Returns:

Name Type Description
int int

Target humidity level.

temperature instance-attribute

temperature: int = NOT_SUPPORTED

timer instance-attribute

timer: Timer | None = None

Inherited From DeviceState

warm_mist_enabled instance-attribute

warm_mist_enabled: bool | None = None

warm_mist_level instance-attribute

warm_mist_level: int = NOT_SUPPORTED

water_lacks instance-attribute

water_lacks: bool = False

water_tank_lifted instance-attribute

water_tank_lifted: bool = False

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}')

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.vesynchumidifier.VeSyncHumid200300S

VeSyncHumid200300S(
    details: ResponseDeviceDetailsModel,
    manager: VeSync,
    feature_map: HumidifierMap,
)

Bases: BypassV2Mixin, VeSyncHumidifier

300S Humidifier Class.

Primary class for VeSync humidifier devices.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The manager object for API calls.

required
feature_map HumidifierMap

The feature map for the device.

required

Attributes:

Name Type Description
state HumidifierState

The state of the humidifier.

last_response ResponseInfo

Last response info 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.

mist_levels list

List of mist levels.

mist_modes list

List of mist modes.

target_minmax tuple

Tuple of target min and max values.

warm_mist_levels list

List of warm mist levels.

Inherited From VeSyncHumidifier

Initialize VeSync device base class.

Initialize VeSync Humidifier Class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The VeSync manager.

required
feature_map HumidifierMap

The feature map for the device.

required

Initialize 200S/300S Humidifier class.

Source code in src\pyvesync\devices\vesynchumidifier.py
def __init__(self, details: ResponseDeviceDetailsModel,
             manager: VeSync, feature_map: HumidifierMap) -> None:
    """Initialize 200S/300S Humidifier class."""
    super().__init__(details, manager, feature_map)

Attributes

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

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 BypassV2Mixin

mist_levels instance-attribute

mist_levels: list[str | int] = mist_levels

Inherited From VeSyncHumidifier

mist_modes instance-attribute

mist_modes: dict[str, str] = mist_modes

Inherited From VeSyncHumidifier

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

state instance-attribute

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

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_drying_mode property

supports_drying_mode: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports drying mode.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight.

Returns:

Name Type Description
bool bool

True if nightlight is supported, False otherwise.

supports_nightlight_brightness property

supports_nightlight_brightness: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight brightness.

supports_warm_mist property

supports_warm_mist: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports warm mist.

Returns:

Name Type Description
bool bool

True if warm mist is supported, False otherwise.

target_minmax instance-attribute

target_minmax: tuple[int, int] = target_minmax

Inherited From VeSyncHumidifier

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

warm_mist_levels instance-attribute

warm_mist_levels: list[int | str] = warm_mist_levels

Inherited From VeSyncHumidifier

Functions

automatic_stop_off async deprecated

automatic_stop_off() -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use turn_off_automatic_stop() instead.

Turn 200S/300S Humidifier automatic stop on.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use turn_off_automatic_stop() instead.")
async def automatic_stop_off(self) -> bool:
    """Turn 200S/300S Humidifier automatic stop on."""
    return await self.toggle_automatic_stop(False)

automatic_stop_on async deprecated

automatic_stop_on() -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use turn_on_automatic_stop() instead.

Turn 200S/300S Humidifier automatic stop on.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use turn_on_automatic_stop() instead.")
async def automatic_stop_on(self) -> bool:
    """Turn 200S/300S Humidifier automatic stop on."""
    return await self.toggle_automatic_stop(True)

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

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\vesynchumidifier.py
async def clear_timer(self) -> bool:
    if self.state.timer is None:
        logger.debug("No timer to clear, run get_timer() first.")
        return False
    payload = {
        "id": self.state.timer.id,
    }
    r_dict = await self.call_bypassv2_api("delTimer", payload)
    r = Helpers.process_dev_response(logger, "clear_timer", self, r_dict)
    if r is None:
        return False
    self.state.timer = None
    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\vesynchumidifier.py
async def get_details(self) -> None:
    r_dict = await self.call_bypassv2_api("getHumidifierStatus")
    r_model = process_bypassv2_result(
        self, logger, 'get_details', r_dict, ClassicLVHumidResult
        )
    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\vesynchumidifier.py
async def get_timer(self) -> Timer | None:
    r_dict = await self.call_bypassv2_api("getTimer")
    result_model = process_bypassv2_result(
        self, logger, "get_timer", r_dict, ResultV2GetTimer
    )
    if result_model is None:
        return None
    if not result_model.timers:
        logger.debug("No timers found")
        return None
    timer = result_model.timers[0]
    self.state.timer = Timer(
        timer_duration=timer.total,
        action=timer.action,
        id=timer.id,
    )
    return self.state.timer

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Auto Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Humidifier to Auto Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.AUTO in self.mist_modes:
        return await self.set_mode(HumidifierModes.AUTO)
    logger.debug("Auto mode not supported for this device.")
    return await self.set_mode(HumidifierModes.AUTO)

set_automatic_stop async deprecated

set_automatic_stop(mode: bool) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use toggle_automatic_stop(toggle: bool) instead.

Set 200S/300S Humidifier to automatic stop.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_automatic_stop(toggle: bool) instead.")
async def set_automatic_stop(self, mode: bool) -> bool:
    """Set 200S/300S Humidifier to automatic stop."""
    return await self.toggle_automatic_stop(mode)

set_display async deprecated

set_display(toggle: bool) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use toggle_display(toggle: bool) instead.

Deprecated method to toggle display on/off.

Use toggle_display(toggle: bool) instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_display(toggle: bool) instead.")
async def set_display(self, toggle: bool) -> bool:
    """Deprecated method to toggle display on/off.

    Use toggle_display(toggle: bool) instead.
    """
    return await self.toggle_display(toggle)

set_humidity async

set_humidity(humidity: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Target Humidity.

Parameters:

Name Type Description Default
humidity int

Target humidity level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_humidity(self, humidity: int) -> bool:
    if not Validators.validate_range(humidity, *self.target_minmax):
        logger.debug(
            "Invalid humidity, must be between %s and %s", *self.target_minmax
        )
        return False

    payload_data = {"target_humidity": humidity}
    r_dict = await self.call_bypassv2_api("setTargetHumidity", payload_data)
    r = Helpers.process_dev_response(logger, "set_humidity", self, r_dict)
    if r is None:
        return False
    self.state.auto_target_humidity = humidity
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_humidity_mode async deprecated

set_humidity_mode(mode: str) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use set_mode(mode: str) instead.

Deprecated method to set humidifier mode.

Use set_mode(mode: str) instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use set_mode(mode: str) instead.")
async def set_humidity_mode(self, mode: str) -> bool:
    """Deprecated method to set humidifier mode.

    Use `set_mode(mode: str)` instead.
    """
    return await self.set_mode(mode)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Manual Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Humidifier to Manual Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.MANUAL in self.mist_modes:
        return await self.set_mode(HumidifierModes.MANUAL)
    logger.debug("Manual mode not supported for this device.")
    return await self.set_mode(HumidifierModes.MANUAL)

set_mist_level async

set_mist_level(level: int) -> bool

Inherited From VeSyncHumidifier

Set Mist Level for Humidifier.

Parameters:

Name Type Description Default
level int

Mist level.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Mist levels are defined in self.mist_levels.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mist_level(self, level: int) -> bool:
    if level not in self.mist_levels:
        logger.debug(
            "Humidifier mist level must be between %s and %s",
            self.mist_levels[0],
            self.mist_levels[-1],
        )
        return False

    payload_data = {"id": 0, "level": level, "type": "mist"}
    r_dict = await self.call_bypassv2_api("setVirtualLevel", payload_data)
    r = Helpers.process_dev_response(logger, "set_mist_level", self, r_dict)
    if r is None:
        return False

    self.state.mist_virtual_level = level
    self.state.mist_level = level
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_mode async

set_mode(mode: str) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Mode.

Parameters:

Name Type Description Default
mode str

Humidifier mode.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Modes for device are defined in self.mist_modes.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mode(self, mode: str) -> bool:
    if mode.lower() not in self.mist_modes:
        logger.debug("Invalid humidity mode used - %s", mode)
        logger.debug(
            "Proper modes for this device are - %s",
            orjson.dumps(
                self.mist_modes, option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS
            ),
        )
        return False

    payload_data = {"mode": self.mist_modes[mode.lower()]}
    r_dict = await self.call_bypassv2_api("setHumidityMode", payload_data)
    r = Helpers.process_dev_response(logger, "set_humidity_mode", self, r_dict)
    if r is None:
        return False

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

set_nightlight_brightness async

set_nightlight_brightness(brightness: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier night light brightness.

Parameters:

Name Type Description Default
brightness int

Target night light brightness.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_nightlight_brightness(self, brightness: int) -> bool:
    if not self.supports_nightlight:
        logger.debug('%s is a %s does not have a nightlight',
                     self.device_name, self.device_type)
        return False

    if Validators.validate_zero_to_hundred(brightness):
        logger.debug("Brightness value must be set between 0 and 100")
        return False

    payload_data = {"night_light_brightness": brightness}
    r_dict = await self.call_bypassv2_api("setNightLightBrightness", payload_data)
    r = Helpers.process_dev_response(
        logger, "set_night_light_brightness", self, r_dict
        )
    if r is None:
        return False
    self.state.nightlight_brightness = brightness
    self.state.nightlight_status = (
        DeviceStatus.ON if brightness > 0 else DeviceStatus.OFF
    )
    return True

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Sleep Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Humidifier to Sleep Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.SLEEP in self.mist_modes:
        return await self.set_mode(HumidifierModes.SLEEP)
    logger.debug("Sleep mode not supported for this device.")
    return await self.set_mode(HumidifierModes.SLEEP)

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\vesynchumidifier.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    if action is None:
        action = (
            DeviceStatus.OFF
            if self.state.device_status == DeviceStatus.ON
            else DeviceStatus.ON
        )
    payload_data = {
        "action": str(action),
        "total": duration,
    }
    r_dict = await self.call_bypassv2_api("addTimer", payload_data)
    r = process_bypassv2_result(self, logger, "set_timer", r_dict, ResultV2SetTimer)
    if r is None:
        return False

    self.state.timer = Timer(
        timer_duration=duration, action=action, id=r.id, remaining=0
    )
    return True

set_warm_level async

set_warm_level(warm_level: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Warm Level.

Parameters:

Name Type Description Default
warm_level int

Target warm level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_warm_level(self, warm_level: int) -> bool:
    if not self.supports_warm_mist:
        logger.debug('%s is a %s does not have a mist warmer',
                     self.device_name, self.device_type)
        return False

    if warm_level not in self.warm_mist_levels:
        logger.debug("warm_level value must be - %s",
                     str(self.warm_mist_levels))
        return False

    payload_data = {"type": "warm", "level": warm_level, "id": 0}
    r_dict = await self.call_bypassv2_api("setVirtualLevel", payload_data)
    r = Helpers.process_dev_response(logger, "set_warm_level", self, r_dict)
    if r is None:
        return False

    self.state.warm_mist_level = warm_level
    self.state.warm_mist_enabled = True
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

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_automatic_stop async

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

Inherited From VeSyncHumidifier

Toggle automatic stop.

Parameters:

Name Type Description Default
toggle bool | None

True to enable automatic stop, False to disable.

None

Returns:

Name Type Description
bool bool

Success of request.

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

    payload_data = {'enabled': toggle}
    r_dict = await self.call_bypassv2_api("setAutomaticStop", payload_data)
    r = Helpers.process_dev_response(logger, "set_automatic_stop", self, r_dict)
    if r is None:
        return False
    self.state.automatic_stop_config = toggle
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_display async

toggle_display(toggle: bool) -> bool

Inherited From VeSyncHumidifier

Toggle the display on/off.

Parameters:

Name Type Description Default
toggle bool

True to turn on the display, False to turn off.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def toggle_display(self, toggle: bool) -> bool:
    payload_data = {'state': toggle}
    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_status = DeviceStatus.from_bool(toggle)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_drying_mode async

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

Inherited From VeSyncHumidifier

enable/disable drying filters after turning off.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def toggle_drying_mode(self, toggle: bool | None = None) -> bool:
    """enable/disable drying filters after turning off."""
    del toggle
    if self.supports_drying_mode:
        logger.debug("Drying mode is not configured for this device.")
        return False
    logger.debug("Drying mode is not supported 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\vesynchumidifier.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.device_status == DeviceStatus.ON

    payload_data = {'enabled': toggle, 'id': 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

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_automatic_stop async

turn_off_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn off automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_automatic_stop(self) -> bool:
    """Turn off automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncHumidifier

Turn off the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(False)

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_automatic_stop async

turn_on_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn on automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_automatic_stop(self) -> bool:
    """Turn on automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncHumidifier

Turn on the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(True)

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.vesynchumidifier.VeSyncHumid200S

VeSyncHumid200S(
    details: ResponseDeviceDetailsModel,
    manager: VeSync,
    feature_map: HumidifierMap,
)

Bases: VeSyncHumid200300S

Levoit Classic 200S Specific class.

Overrides the toggle_display(toggle: bool) method of the VeSyncHumid200300S class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The manager object for API calls.

required
feature_map HumidifierMap

The feature map for the device.

required

Attributes:

Name Type Description
state HumidifierState

The state of the humidifier.

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.

mist_levels list

List of mist levels.

mist_modes list

List of mist modes.

target_minmax tuple

Tuple of target min and max values.

warm_mist_levels list

List of warm mist levels.

Inherited From VeSyncHumid200300S

Initialize VeSync device base class.

Initialize VeSync Humidifier Class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The VeSync manager.

required
feature_map HumidifierMap

The feature map for the device.

required

Initialize 200S/300S Humidifier class.

Initialize levoit 200S device class.

This overrides the toggle_display(toggle: bool) method of the VeSyncHumid200300S class.

Source code in src\pyvesync\devices\vesynchumidifier.py
def __init__(self, details: ResponseDeviceDetailsModel,
             manager: VeSync, feature_map: HumidifierMap) -> None:
    """Initialize levoit 200S device class.

    This overrides the `toggle_display(toggle: bool)` method of the
    VeSyncHumid200300S class.
    """
    super().__init__(details, manager, feature_map)

Attributes

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

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 BypassV2Mixin

mist_levels instance-attribute

mist_levels: list[str | int] = mist_levels

Inherited From VeSyncHumidifier

mist_modes instance-attribute

mist_modes: dict[str, str] = mist_modes

Inherited From VeSyncHumidifier

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

state instance-attribute

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

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_drying_mode property

supports_drying_mode: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports drying mode.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight.

Returns:

Name Type Description
bool bool

True if nightlight is supported, False otherwise.

supports_nightlight_brightness property

supports_nightlight_brightness: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight brightness.

supports_warm_mist property

supports_warm_mist: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports warm mist.

Returns:

Name Type Description
bool bool

True if warm mist is supported, False otherwise.

target_minmax instance-attribute

target_minmax: tuple[int, int] = target_minmax

Inherited From VeSyncHumidifier

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

warm_mist_levels instance-attribute

warm_mist_levels: list[int | str] = warm_mist_levels

Inherited From VeSyncHumidifier

Functions

automatic_stop_off async deprecated

automatic_stop_off() -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use turn_off_automatic_stop() instead.

Turn 200S/300S Humidifier automatic stop on.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use turn_off_automatic_stop() instead.")
async def automatic_stop_off(self) -> bool:
    """Turn 200S/300S Humidifier automatic stop on."""
    return await self.toggle_automatic_stop(False)

automatic_stop_on async deprecated

automatic_stop_on() -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use turn_on_automatic_stop() instead.

Turn 200S/300S Humidifier automatic stop on.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use turn_on_automatic_stop() instead.")
async def automatic_stop_on(self) -> bool:
    """Turn 200S/300S Humidifier automatic stop on."""
    return await self.toggle_automatic_stop(True)

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

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\vesynchumidifier.py
async def clear_timer(self) -> bool:
    if self.state.timer is None:
        logger.debug("No timer to clear, run get_timer() first.")
        return False
    payload = {
        "id": self.state.timer.id,
    }
    r_dict = await self.call_bypassv2_api("delTimer", payload)
    r = Helpers.process_dev_response(logger, "clear_timer", self, r_dict)
    if r is None:
        return False
    self.state.timer = None
    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\vesynchumidifier.py
async def get_details(self) -> None:
    r_dict = await self.call_bypassv2_api("getHumidifierStatus")
    r_model = process_bypassv2_result(
        self, logger, 'get_details', r_dict, ClassicLVHumidResult
        )
    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\vesynchumidifier.py
async def get_timer(self) -> Timer | None:
    r_dict = await self.call_bypassv2_api("getTimer")
    result_model = process_bypassv2_result(
        self, logger, "get_timer", r_dict, ResultV2GetTimer
    )
    if result_model is None:
        return None
    if not result_model.timers:
        logger.debug("No timers found")
        return None
    timer = result_model.timers[0]
    self.state.timer = Timer(
        timer_duration=timer.total,
        action=timer.action,
        id=timer.id,
    )
    return self.state.timer

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Auto Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Humidifier to Auto Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.AUTO in self.mist_modes:
        return await self.set_mode(HumidifierModes.AUTO)
    logger.debug("Auto mode not supported for this device.")
    return await self.set_mode(HumidifierModes.AUTO)

set_automatic_stop async deprecated

set_automatic_stop(mode: bool) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use toggle_automatic_stop(toggle: bool) instead.

Set 200S/300S Humidifier to automatic stop.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_automatic_stop(toggle: bool) instead.")
async def set_automatic_stop(self, mode: bool) -> bool:
    """Set 200S/300S Humidifier to automatic stop."""
    return await self.toggle_automatic_stop(mode)

set_display async deprecated

set_display(toggle: bool) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use toggle_display(toggle: bool) instead.

Deprecated method to toggle display on/off.

Use toggle_display(toggle: bool) instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_display(toggle: bool) instead.")
async def set_display(self, toggle: bool) -> bool:
    """Deprecated method to toggle display on/off.

    Use toggle_display(toggle: bool) instead.
    """
    return await self.toggle_display(toggle)

set_humidity async

set_humidity(humidity: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Target Humidity.

Parameters:

Name Type Description Default
humidity int

Target humidity level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_humidity(self, humidity: int) -> bool:
    if not Validators.validate_range(humidity, *self.target_minmax):
        logger.debug(
            "Invalid humidity, must be between %s and %s", *self.target_minmax
        )
        return False

    payload_data = {"target_humidity": humidity}
    r_dict = await self.call_bypassv2_api("setTargetHumidity", payload_data)
    r = Helpers.process_dev_response(logger, "set_humidity", self, r_dict)
    if r is None:
        return False
    self.state.auto_target_humidity = humidity
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_humidity_mode async deprecated

set_humidity_mode(mode: str) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use set_mode(mode: str) instead.

Deprecated method to set humidifier mode.

Use set_mode(mode: str) instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use set_mode(mode: str) instead.")
async def set_humidity_mode(self, mode: str) -> bool:
    """Deprecated method to set humidifier mode.

    Use `set_mode(mode: str)` instead.
    """
    return await self.set_mode(mode)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Manual Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Humidifier to Manual Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.MANUAL in self.mist_modes:
        return await self.set_mode(HumidifierModes.MANUAL)
    logger.debug("Manual mode not supported for this device.")
    return await self.set_mode(HumidifierModes.MANUAL)

set_mist_level async

set_mist_level(level: int) -> bool

Inherited From VeSyncHumidifier

Set Mist Level for Humidifier.

Parameters:

Name Type Description Default
level int

Mist level.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Mist levels are defined in self.mist_levels.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mist_level(self, level: int) -> bool:
    if level not in self.mist_levels:
        logger.debug(
            "Humidifier mist level must be between %s and %s",
            self.mist_levels[0],
            self.mist_levels[-1],
        )
        return False

    payload_data = {"id": 0, "level": level, "type": "mist"}
    r_dict = await self.call_bypassv2_api("setVirtualLevel", payload_data)
    r = Helpers.process_dev_response(logger, "set_mist_level", self, r_dict)
    if r is None:
        return False

    self.state.mist_virtual_level = level
    self.state.mist_level = level
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_mode async

set_mode(mode: str) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Mode.

Parameters:

Name Type Description Default
mode str

Humidifier mode.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Modes for device are defined in self.mist_modes.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mode(self, mode: str) -> bool:
    if mode.lower() not in self.mist_modes:
        logger.debug("Invalid humidity mode used - %s", mode)
        logger.debug(
            "Proper modes for this device are - %s",
            orjson.dumps(
                self.mist_modes, option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS
            ),
        )
        return False

    payload_data = {"mode": self.mist_modes[mode.lower()]}
    r_dict = await self.call_bypassv2_api("setHumidityMode", payload_data)
    r = Helpers.process_dev_response(logger, "set_humidity_mode", self, r_dict)
    if r is None:
        return False

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

set_nightlight_brightness async

set_nightlight_brightness(brightness: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier night light brightness.

Parameters:

Name Type Description Default
brightness int

Target night light brightness.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_nightlight_brightness(self, brightness: int) -> bool:
    if not self.supports_nightlight:
        logger.debug('%s is a %s does not have a nightlight',
                     self.device_name, self.device_type)
        return False

    if Validators.validate_zero_to_hundred(brightness):
        logger.debug("Brightness value must be set between 0 and 100")
        return False

    payload_data = {"night_light_brightness": brightness}
    r_dict = await self.call_bypassv2_api("setNightLightBrightness", payload_data)
    r = Helpers.process_dev_response(
        logger, "set_night_light_brightness", self, r_dict
        )
    if r is None:
        return False
    self.state.nightlight_brightness = brightness
    self.state.nightlight_status = (
        DeviceStatus.ON if brightness > 0 else DeviceStatus.OFF
    )
    return True

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Sleep Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Humidifier to Sleep Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.SLEEP in self.mist_modes:
        return await self.set_mode(HumidifierModes.SLEEP)
    logger.debug("Sleep mode not supported for this device.")
    return await self.set_mode(HumidifierModes.SLEEP)

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\vesynchumidifier.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    if action is None:
        action = (
            DeviceStatus.OFF
            if self.state.device_status == DeviceStatus.ON
            else DeviceStatus.ON
        )
    payload_data = {
        "action": str(action),
        "total": duration,
    }
    r_dict = await self.call_bypassv2_api("addTimer", payload_data)
    r = process_bypassv2_result(self, logger, "set_timer", r_dict, ResultV2SetTimer)
    if r is None:
        return False

    self.state.timer = Timer(
        timer_duration=duration, action=action, id=r.id, remaining=0
    )
    return True

set_warm_level async

set_warm_level(warm_level: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Warm Level.

Parameters:

Name Type Description Default
warm_level int

Target warm level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_warm_level(self, warm_level: int) -> bool:
    if not self.supports_warm_mist:
        logger.debug('%s is a %s does not have a mist warmer',
                     self.device_name, self.device_type)
        return False

    if warm_level not in self.warm_mist_levels:
        logger.debug("warm_level value must be - %s",
                     str(self.warm_mist_levels))
        return False

    payload_data = {"type": "warm", "level": warm_level, "id": 0}
    r_dict = await self.call_bypassv2_api("setVirtualLevel", payload_data)
    r = Helpers.process_dev_response(logger, "set_warm_level", self, r_dict)
    if r is None:
        return False

    self.state.warm_mist_level = warm_level
    self.state.warm_mist_enabled = True
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

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_automatic_stop async

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

Inherited From VeSyncHumidifier

Toggle automatic stop.

Parameters:

Name Type Description Default
toggle bool | None

True to enable automatic stop, False to disable.

None

Returns:

Name Type Description
bool bool

Success of request.

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

    payload_data = {'enabled': toggle}
    r_dict = await self.call_bypassv2_api("setAutomaticStop", payload_data)
    r = Helpers.process_dev_response(logger, "set_automatic_stop", self, r_dict)
    if r is None:
        return False
    self.state.automatic_stop_config = toggle
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_display async

toggle_display(toggle: bool) -> bool

Inherited From VeSyncHumid200300S

Toggle the display on/off.

Parameters:

Name Type Description Default
toggle bool

True to turn on the display, False to turn off.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def toggle_display(self, toggle: bool) -> bool:
    payload_data = {"enabled": toggle, "id": 0}
    r_dict = await self.call_bypassv2_api("setIndicatorLightSwitch", payload_data)
    r = Helpers.process_dev_response(logger, "toggle_display", self, r_dict)
    if r is None:
        return False

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

toggle_drying_mode async

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

Inherited From VeSyncHumidifier

enable/disable drying filters after turning off.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def toggle_drying_mode(self, toggle: bool | None = None) -> bool:
    """enable/disable drying filters after turning off."""
    del toggle
    if self.supports_drying_mode:
        logger.debug("Drying mode is not configured for this device.")
        return False
    logger.debug("Drying mode is not supported 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\vesynchumidifier.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.device_status == DeviceStatus.ON

    payload_data = {'enabled': toggle, 'id': 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

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_automatic_stop async

turn_off_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn off automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_automatic_stop(self) -> bool:
    """Turn off automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncHumidifier

Turn off the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(False)

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_automatic_stop async

turn_on_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn on automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_automatic_stop(self) -> bool:
    """Turn on automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncHumidifier

Turn on the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(True)

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.vesynchumidifier.VeSyncSuperior6000S

VeSyncSuperior6000S(
    details: ResponseDeviceDetailsModel,
    manager: VeSync,
    feature_map: HumidifierMap,
)

Bases: BypassV2Mixin, VeSyncHumidifier

Superior 6000S Humidifier.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The manager object for API calls.

required
feature_map HumidifierMap

The feature map for the device.

required

Attributes:

Name Type Description
state HumidifierState

The state of the humidifier.

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.

mist_levels list

List of mist levels.

mist_modes list

List of mist modes.

target_minmax tuple

Tuple of target min and max values.

warm_mist_levels list

List of warm mist levels.

Inherited From VeSyncHumidifier

Initialize VeSync device base class.

Initialize VeSync Humidifier Class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The VeSync manager.

required
feature_map HumidifierMap

The feature map for the device.

required

Initialize Superior 6000S Humidifier class.

Source code in src\pyvesync\devices\vesynchumidifier.py
def __init__(self, details: ResponseDeviceDetailsModel,
             manager: VeSync, feature_map: HumidifierMap) -> None:
    """Initialize Superior 6000S Humidifier class."""
    super().__init__(details, manager, feature_map)

Attributes

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

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 BypassV2Mixin

mist_levels instance-attribute

mist_levels: list[str | int] = mist_levels

Inherited From VeSyncHumidifier

mist_modes instance-attribute

mist_modes: dict[str, str] = mist_modes

Inherited From VeSyncHumidifier

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

state instance-attribute

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

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_drying_mode property

supports_drying_mode: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports drying mode.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight.

Returns:

Name Type Description
bool bool

True if nightlight is supported, False otherwise.

supports_nightlight_brightness property

supports_nightlight_brightness: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight brightness.

supports_warm_mist property

supports_warm_mist: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports warm mist.

Returns:

Name Type Description
bool bool

True if warm mist is supported, False otherwise.

target_minmax instance-attribute

target_minmax: tuple[int, int] = target_minmax

Inherited From VeSyncHumidifier

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

warm_mist_levels instance-attribute

warm_mist_levels: list[int | str] = warm_mist_levels

Inherited From VeSyncHumidifier

Functions

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

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\vesynchumidifier.py
async def get_details(self) -> None:
    r_dict = await self.call_bypassv2_api("getHumidifierStatus")
    r_model = process_bypassv2_result(
        self, logger, "get_details", r_dict, Superior6000SResult
    )
    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\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

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Auto Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Humidifier to Auto Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.AUTO in self.mist_modes:
        return await self.set_mode(HumidifierModes.AUTO)
    logger.debug("Auto mode not supported for this device.")
    return await self.set_mode(HumidifierModes.AUTO)

set_display_enabled async deprecated

set_display_enabled(mode: bool) -> bool
Deprecated

Use toggle_display() instead.

Set display on/off.

Deprecated method, please use toggle_display() instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_display() instead.")
async def set_display_enabled(self, mode: bool) -> bool:
    """Set display on/off.

    Deprecated method, please use toggle_display() instead.
    """
    return await self.toggle_display(mode)

set_drying_mode_enabled async deprecated

set_drying_mode_enabled(mode: bool) -> bool
Deprecated

Use toggle_drying_mode() instead.

Set drying mode on/off.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_drying_mode() instead.")
async def set_drying_mode_enabled(self, mode: bool) -> bool:
    """Set drying mode on/off."""
    return await self.toggle_drying_mode(mode)

set_humidity async

set_humidity(humidity: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Target Humidity.

Parameters:

Name Type Description Default
humidity int

Target humidity level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_humidity(self, humidity: int) -> bool:
    if Validators.validate_range(humidity, *self.target_minmax):
        logger.debug("Humidity value must be set between 30 and 80")
        return False

    payload_data = {"targetHumidity": humidity}
    r_dict = await self.call_bypassv2_api("setTargetHumidity", payload_data)
    r = Helpers.process_dev_response(logger, "set_humidity", self, r_dict)
    if r is None:
        return False

    self.state.auto_target_humidity = humidity
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_humidity_mode async deprecated

set_humidity_mode(mode: str) -> bool
Deprecated

Use set_mode(mode: str) instead.

Set humidifier mode.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use set_mode(mode: str) instead.")
async def set_humidity_mode(self, mode: str) -> bool:
    """Set humidifier mode."""
    return await self.set_mode(mode)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Manual Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Humidifier to Manual Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.MANUAL in self.mist_modes:
        return await self.set_mode(HumidifierModes.MANUAL)
    logger.debug("Manual mode not supported for this device.")
    return await self.set_mode(HumidifierModes.MANUAL)

set_mist_level async

set_mist_level(level: int) -> bool

Inherited From VeSyncHumidifier

Set Mist Level for Humidifier.

Parameters:

Name Type Description Default
level int

Mist level.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Mist levels are defined in self.mist_levels.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mist_level(self, level: int) -> bool:
    if level not in self.mist_levels:
        logger.debug("Humidifier mist level must be between 0 and 9")
        return False

    payload_data = {"levelIdx": 0, "virtualLevel": level, "levelType": "mist"}
    r_dict = await self.call_bypassv2_api("setVirtualLevel", payload_data)
    r = Helpers.process_dev_response(logger, "set_mist_level", self, r_dict)
    if r is None:
        return False

    self.state.mist_level = level
    self.state.mist_virtual_level = level
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_mode async

set_mode(mode: str) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Mode.

Parameters:

Name Type Description Default
mode str

Humidifier mode.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Modes for device are defined in self.mist_modes.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mode(self, mode: str) -> bool:
    if mode.lower() not in self.mist_modes:
        logger.debug('Invalid humidity mode used - %s',
                     mode)
        logger.debug(
            "Proper modes for this device are - %s",
            orjson.dumps(
                self.mist_modes, option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS
            ),
        )
        return False

    payload_data = {"workMode": self.mist_modes[mode.lower()]}
    r_dict = await self.call_bypassv2_api("setHumidityMode", payload_data)

    r = Helpers.process_dev_response(logger, "set_humidity_mode", self, r_dict)
    if r is None:
        return False
    self.state.mode = mode
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_nightlight_brightness async

set_nightlight_brightness(brightness: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier night light brightness.

Parameters:

Name Type Description Default
brightness int

Target night light brightness.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_nightlight_brightness(self, brightness: int) -> bool:
    """Set Humidifier night light brightness.

    Args:
        brightness (int): Target night light brightness.

    Returns:
        bool: Success of request.
    """
    del brightness
    if not self.supports_nightlight_brightness:
        logger.debug("Nightlight brightness is not supported for this device.")
        return False
    logger.debug("Nightlight brightness has not been configured.")
    return False

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Sleep Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Humidifier to Sleep Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.SLEEP in self.mist_modes:
        return await self.set_mode(HumidifierModes.SLEEP)
    logger.debug("Sleep mode not supported for this device.")
    return await self.set_mode(HumidifierModes.SLEEP)

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_warm_level async

set_warm_level(warm_level: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Warm Level.

Parameters:

Name Type Description Default
warm_level int

Target warm level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_warm_level(self, warm_level: int) -> bool:
    """Set Humidifier Warm Level.

    Args:
        warm_level (int): Target warm level.

    Returns:
        bool: Success of request.
    """
    del warm_level
    if self.supports_warm_mist:
        logger.debug("Warm level has not been configured.")
        return False
    logger.debug("Warm level is not supported for this device.")
    return False

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_automatic_stop async

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

Inherited From VeSyncHumidifier

Toggle automatic stop.

Parameters:

Name Type Description Default
toggle bool | None

True to enable automatic stop, False to disable.

None

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def toggle_automatic_stop(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.automatic_stop_config is not True

    payload_data = {"autoStopSwitch": int(toggle)}
    r_dict = await self.call_bypassv2_api("setAutoStopSwitch", payload_data)
    r = Helpers.process_dev_response(logger, "toggle_automatic_stop", 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

toggle_display async

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

Inherited From VeSyncHumidifier

Toggle the display on/off.

Parameters:

Name Type Description Default
toggle bool

True to turn on the display, False to turn off.

None

Returns:

Name Type Description
bool bool

Success of request.

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

    payload_data = {"screenSwitch": int(toggle)}
    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_status = DeviceStatus.from_bool(toggle)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_drying_mode async

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

Inherited From VeSyncHumidifier

enable/disable drying filters after turning off.

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

    payload_data = {"autoDryingSwitch": int(toggle)}
    r_dict = await self.call_bypassv2_api("setDryingMode", payload_data)
    r = Helpers.process_dev_response(logger, "set_drying_mode_enabled", self, r_dict)
    if r is None:
        return False

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

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\vesynchumidifier.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.device_status != DeviceStatus.ON

    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

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_automatic_stop async

turn_off_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn off automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_automatic_stop(self) -> bool:
    """Turn off automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncHumidifier

Turn off the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(False)

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_automatic_stop async

turn_on_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn on automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_automatic_stop(self) -> bool:
    """Turn on automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncHumidifier

Turn on the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(True)

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.vesynchumidifier.VeSyncHumid1000S

VeSyncHumid1000S(
    details: ResponseDeviceDetailsModel,
    manager: VeSync,
    feature_map: HumidifierMap,
)

Bases: VeSyncHumid200300S

Levoit OasisMist 1000S Specific class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The manager object for API calls.

required
feature_map HumidifierMap

The feature map for the device.

required

Attributes:

Name Type Description
state HumidifierState

The state of the humidifier.

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.

mist_levels list

List of mist levels.

mist_modes list

List of mist modes.

target_minmax tuple

Tuple of target min and max values.

warm_mist_levels list

List of warm mist levels.

Inherited From VeSyncHumid200300S

Initialize VeSync device base class.

Initialize VeSync Humidifier Class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The VeSync manager.

required
feature_map HumidifierMap

The feature map for the device.

required

Initialize 200S/300S Humidifier class.

Initialize levoit 1000S device class.

Source code in src\pyvesync\devices\vesynchumidifier.py
def __init__(self, details: ResponseDeviceDetailsModel,
             manager: VeSync, feature_map: HumidifierMap) -> None:
    """Initialize levoit 1000S device class."""
    super().__init__(details, manager, feature_map)

Attributes

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

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 BypassV2Mixin

mist_levels instance-attribute

mist_levels: list[str | int] = mist_levels

Inherited From VeSyncHumidifier

mist_modes instance-attribute

mist_modes: dict[str, str] = mist_modes

Inherited From VeSyncHumidifier

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

state instance-attribute

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

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_drying_mode property

supports_drying_mode: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports drying mode.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight.

Returns:

Name Type Description
bool bool

True if nightlight is supported, False otherwise.

supports_nightlight_brightness property

supports_nightlight_brightness: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight brightness.

supports_warm_mist property

supports_warm_mist: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports warm mist.

Returns:

Name Type Description
bool bool

True if warm mist is supported, False otherwise.

target_minmax instance-attribute

target_minmax: tuple[int, int] = target_minmax

Inherited From VeSyncHumidifier

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

warm_mist_levels instance-attribute

warm_mist_levels: list[int | str] = warm_mist_levels

Inherited From VeSyncHumidifier

Functions

automatic_stop_off async deprecated

automatic_stop_off() -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use turn_off_automatic_stop() instead.

Turn 200S/300S Humidifier automatic stop on.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use turn_off_automatic_stop() instead.")
async def automatic_stop_off(self) -> bool:
    """Turn 200S/300S Humidifier automatic stop on."""
    return await self.toggle_automatic_stop(False)

automatic_stop_on async deprecated

automatic_stop_on() -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use turn_on_automatic_stop() instead.

Turn 200S/300S Humidifier automatic stop on.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use turn_on_automatic_stop() instead.")
async def automatic_stop_on(self) -> bool:
    """Turn 200S/300S Humidifier automatic stop on."""
    return await self.toggle_automatic_stop(True)

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

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\vesynchumidifier.py
async def clear_timer(self) -> bool:
    if self.state.timer is None:
        logger.debug("No timer to clear, run get_timer() first.")
        return False
    payload = {
        "id": self.state.timer.id,
    }
    r_dict = await self.call_bypassv2_api("delTimer", payload)
    r = Helpers.process_dev_response(logger, "clear_timer", self, r_dict)
    if r is None:
        return False
    self.state.timer = None
    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 VeSyncHumid200300S

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\vesynchumidifier.py
async def get_details(self) -> None:
    r_dict = await self.call_bypassv2_api("getHumidifierStatus")
    r_model = process_bypassv2_result(
        self, logger, 'get_details', r_dict, Levoit1000SResult
        )
    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\vesynchumidifier.py
async def get_timer(self) -> Timer | None:
    r_dict = await self.call_bypassv2_api("getTimer")
    result_model = process_bypassv2_result(
        self, logger, "get_timer", r_dict, ResultV2GetTimer
    )
    if result_model is None:
        return None
    if not result_model.timers:
        logger.debug("No timers found")
        return None
    timer = result_model.timers[0]
    self.state.timer = Timer(
        timer_duration=timer.total,
        action=timer.action,
        id=timer.id,
    )
    return self.state.timer

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Auto Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Humidifier to Auto Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.AUTO in self.mist_modes:
        return await self.set_mode(HumidifierModes.AUTO)
    logger.debug("Auto mode not supported for this device.")
    return await self.set_mode(HumidifierModes.AUTO)

set_automatic_stop async deprecated

set_automatic_stop(mode: bool) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use toggle_automatic_stop() instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_automatic_stop() instead.")
async def set_automatic_stop(self, mode: bool) -> bool:
    return await self.toggle_automatic_stop(mode)

set_display async deprecated

set_display(toggle: bool) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use toggle_switch() instead.

Toggle display on/off.

This is a deprecated method, please use toggle_display() instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use toggle_switch() instead.")
async def set_display(self, toggle: bool) -> bool:
    """Toggle display on/off.

    This is a deprecated method, please use toggle_display() instead.
    """
    return await self.toggle_switch(toggle)

set_humidity async

set_humidity(humidity: int) -> bool

Inherited From VeSyncHumid200300S

Set Humidifier Target Humidity.

Parameters:

Name Type Description Default
humidity int

Target humidity level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_humidity(self, humidity: int) -> bool:
    if Validators.validate_range(humidity, *self.target_minmax):
        logger.debug("Humidity value must be set between %s and %s",
                     self.target_minmax[0], self.target_minmax[1])
        return False

    payload_data = {"targetHumidity": humidity}
    r_dict = await self.call_bypassv2_api("setTargetHumidity", payload_data)
    r = Helpers.process_dev_response(logger, "set_humidity", self, r_dict)
    if r is None:
        return False

    self.state.auto_target_humidity = humidity
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_humidity_mode async deprecated

set_humidity_mode(mode: str) -> bool

Inherited From VeSyncHumid200300S

Deprecated

Use set_mode() instead.

Set humidifier mode - sleep, auto or manual.

Deprecated, please use set_mode() instead.

Source code in src\pyvesync\devices\vesynchumidifier.py
@deprecated("Use set_mode() instead.")
async def set_humidity_mode(self, mode: str) -> bool:
    """Set humidifier mode - sleep, auto or manual.

    Deprecated, please use set_mode() instead.
    """
    return await self.set_mode(mode)

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Manual Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Humidifier to Manual Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.MANUAL in self.mist_modes:
        return await self.set_mode(HumidifierModes.MANUAL)
    logger.debug("Manual mode not supported for this device.")
    return await self.set_mode(HumidifierModes.MANUAL)

set_mist_level async

set_mist_level(level: int) -> bool

Inherited From VeSyncHumid200300S

Set Mist Level for Humidifier.

Parameters:

Name Type Description Default
level int

Mist level.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Mist levels are defined in self.mist_levels.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mist_level(self, level: int) -> bool:
    if level not in self.mist_levels:
        logger.debug('Humidifier mist level out of range')
        return False

    payload_data = {"levelIdx": 0, "virtualLevel": level, "levelType": "mist"}
    r_dict = await self.call_bypassv2_api('virtualLevel', payload_data)
    r = Helpers.process_dev_response(logger, "set_mist_level", self, r_dict)
    if r is None:
        return False

    self.state.mist_level = level
    self.state.mist_virtual_level = level
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_mode async

set_mode(mode: str) -> bool

Inherited From VeSyncHumid200300S

Set Humidifier Mode.

Parameters:

Name Type Description Default
mode str

Humidifier mode.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Modes for device are defined in self.mist_modes.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_mode(self, mode: str) -> bool:
    if mode.lower() not in self.mist_modes:
        logger.debug("Invalid humidity mode used - %s", mode)
        logger.debug(
            "Proper modes for this device are - %s",
            orjson.dumps(
                self.mist_modes, option=orjson.OPT_INDENT_2 | orjson.OPT_NON_STR_KEYS
            ),
        )
        return False

    payload_data = {"workMode": mode.lower()}
    r_dict = await self.call_bypassv2_api("setHumidityMode", payload_data)
    r = Helpers.process_dev_response(logger, "set_mode", self, r_dict)
    if r is None:
        return False

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

set_nightlight_brightness async

set_nightlight_brightness(brightness: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier night light brightness.

Parameters:

Name Type Description Default
brightness int

Target night light brightness.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_nightlight_brightness(self, brightness: int) -> bool:
    if not self.supports_nightlight:
        logger.debug('%s is a %s does not have a nightlight',
                     self.device_name, self.device_type)
        return False

    if Validators.validate_zero_to_hundred(brightness):
        logger.debug("Brightness value must be set between 0 and 100")
        return False

    payload_data = {"night_light_brightness": brightness}
    r_dict = await self.call_bypassv2_api("setNightLightBrightness", payload_data)
    r = Helpers.process_dev_response(
        logger, "set_night_light_brightness", self, r_dict
        )
    if r is None:
        return False
    self.state.nightlight_brightness = brightness
    self.state.nightlight_status = (
        DeviceStatus.ON if brightness > 0 else DeviceStatus.OFF
    )
    return True

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Sleep Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Humidifier to Sleep Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.SLEEP in self.mist_modes:
        return await self.set_mode(HumidifierModes.SLEEP)
    logger.debug("Sleep mode not supported for this device.")
    return await self.set_mode(HumidifierModes.SLEEP)

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\vesynchumidifier.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    if action is None:
        action = (
            DeviceStatus.OFF
            if self.state.device_status == DeviceStatus.ON
            else DeviceStatus.ON
        )
    payload_data = {
        "action": str(action),
        "total": duration,
    }
    r_dict = await self.call_bypassv2_api("addTimer", payload_data)
    r = process_bypassv2_result(self, logger, "set_timer", r_dict, ResultV2SetTimer)
    if r is None:
        return False

    self.state.timer = Timer(
        timer_duration=duration, action=action, id=r.id, remaining=0
    )
    return True

set_warm_level async

set_warm_level(warm_level: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Warm Level.

Parameters:

Name Type Description Default
warm_level int

Target warm level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def set_warm_level(self, warm_level: int) -> bool:
    if not self.supports_warm_mist:
        logger.debug('%s is a %s does not have a mist warmer',
                     self.device_name, self.device_type)
        return False

    if warm_level not in self.warm_mist_levels:
        logger.debug("warm_level value must be - %s",
                     str(self.warm_mist_levels))
        return False

    payload_data = {"type": "warm", "level": warm_level, "id": 0}
    r_dict = await self.call_bypassv2_api("setVirtualLevel", payload_data)
    r = Helpers.process_dev_response(logger, "set_warm_level", self, r_dict)
    if r is None:
        return False

    self.state.warm_mist_level = warm_level
    self.state.warm_mist_enabled = True
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

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_automatic_stop async

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

Inherited From VeSyncHumid200300S

Toggle automatic stop.

Parameters:

Name Type Description Default
toggle bool | None

True to enable automatic stop, False to disable.

None

Returns:

Name Type Description
bool bool

Success of request.

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

    payload_data = {"autoStopSwitch": int(toggle)}
    r_dict = await self.call_bypassv2_api("setAutoStopSwitch", payload_data)
    r = Helpers.process_dev_response(logger, "set_automatic_stop", self, r_dict)

    if r is None:
        return False
    self.state.automatic_stop_config = toggle
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_display async

toggle_display(toggle: bool) -> bool

Inherited From VeSyncHumid200300S

Toggle the display on/off.

Parameters:

Name Type Description Default
toggle bool

True to turn on the display, False to turn off.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\devices\vesynchumidifier.py
async def toggle_display(self, toggle: bool) -> bool:
    payload_data = {"screenSwitch": int(toggle)}
    body = self._build_request("setDisplay", payload_data)
    headers = Helpers.req_header_bypass()

    r_dict, _ = await self.manager.async_call_api(
        '/cloud/v2/deviceManaged/bypassV2',
        method='post',
        headers=headers,
        json_object=body.to_dict(),
    )
    r = Helpers.process_dev_response(logger, "set_display", self, r_dict)
    if r is None:
        return False
    self.state.display_set_status = DeviceStatus.from_bool(toggle)
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

toggle_drying_mode async

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

Inherited From VeSyncHumidifier

enable/disable drying filters after turning off.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def toggle_drying_mode(self, toggle: bool | None = None) -> bool:
    """enable/disable drying filters after turning off."""
    del toggle
    if self.supports_drying_mode:
        logger.debug("Drying mode is not configured for this device.")
        return False
    logger.debug("Drying mode is not supported for this device.")
    return False

toggle_switch async

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

Inherited From VeSyncHumid200300S

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\vesynchumidifier.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.device_status != DeviceStatus.ON

    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

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_automatic_stop async

turn_off_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn off automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_automatic_stop(self) -> bool:
    """Turn off automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncHumidifier

Turn off the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(False)

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_automatic_stop async

turn_on_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn on automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_automatic_stop(self) -> bool:
    """Turn on automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncHumidifier

Turn on the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(True)

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.humidifier_base.VeSyncHumidifier

Bases: VeSyncBaseToggleDevice

VeSyncHumdifier Base Class.

This is the base device to be inherited by all Humidifier devices. This class only holds the device configuration and static attributes. The state attribute holds the current state.

Attributes:

Name Type Description
state HumidifierState

The state of the humidifier.

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.

mist_levels list

List of mist levels.

mist_modes list

List of mist modes.

target_minmax tuple

Tuple of target min and max values.

warm_mist_levels list

List of warm mist levels.

Source code in src\pyvesync\base_devices\humidifier_base.py
class VeSyncHumidifier(VeSyncBaseToggleDevice):
    """VeSyncHumdifier Base Class.

    This is the base device to be inherited by all Humidifier devices.
    This class only holds the device configuration and static attributes.
    The state attribute holds the current state.

    Attributes:
        state (HumidifierState): The state of the humidifier.
        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.
        mist_levels (list): List of mist levels.
        mist_modes (list): List of mist modes.
        target_minmax (tuple): Tuple of target min and max values.
        warm_mist_levels (list): List of warm mist levels.

    """

    __slots__ = (
        "mist_levels",
        "mist_modes",
        "target_minmax",
        "warm_mist_levels",
    )

    def __init__(self, details: ResponseDeviceDetailsModel,
                 manager: VeSync, feature_map: HumidifierMap) -> None:
        """Initialize VeSync Humidifier Class.

        Args:
            details (ResponseDeviceDetailsModel): The device details.
            manager (VeSync): The VeSync manager.
            feature_map (HumidifierMap): The feature map for the device.
        """
        super().__init__(details, manager, feature_map)
        self.state: HumidifierState = HumidifierState(self, details, feature_map)
        self.mist_modes: dict[str, str] = feature_map.mist_modes
        self.mist_levels: list[str | int] = feature_map.mist_levels
        self.features: list[str] = feature_map.features
        self.warm_mist_levels: list[int | str] = feature_map.warm_mist_levels
        self.target_minmax: tuple[int, int] = feature_map.target_minmax

    @property
    def supports_warm_mist(self) -> bool:
        """Return True if the humidifier supports warm mist.

        Returns:
            bool: True if warm mist is supported, False otherwise.
        """
        return HumidifierFeatures.WARM_MIST in self.features

    @property
    def supports_nightlight(self) -> bool:
        """Return True if the humidifier supports nightlight.

        Returns:
            bool: True if nightlight is supported, False otherwise.
        """
        return HumidifierFeatures.NIGHTLIGHT in self.features

    @property
    def supports_nightlight_brightness(self) -> bool:
        """Return True if the humidifier supports nightlight brightness."""
        return HumidifierFeatures.NIGHTLIGHT_BRIGHTNESS in self.features

    @property
    def supports_drying_mode(self) -> bool:
        """Return True if the humidifier supports drying mode."""
        return HumidifierFeatures.DRYING_MODE in self.features

    async def toggle_automatic_stop(self, toggle: bool | None = None) -> bool:
        """Toggle automatic stop.

        Args:
            toggle (bool | None): True to enable automatic stop, False to disable.

        Returns:
            bool: Success of request.
        """
        del toggle
        logger.warning("Automatic stop is not supported or configured for this device.")
        return False

    async def toggle_display(self, toggle: bool) -> bool:
        """Toggle the display on/off.

        Args:
            toggle (bool): True to turn on the display, False to turn off.

        Returns:
            bool: Success of request.
        """
        del toggle
        logger.warning("Display is not supported or configured for this device.")
        return False

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

        Args:
            mode (str): Humidifier mode.

        Returns:
            bool: Success of request.

        Note:
            Modes for device are defined in `self.mist_modes`.
        """

    @abstractmethod
    async def set_mist_level(self, level: int) -> bool:
        """Set Mist Level for Humidifier.

        Args:
            level (int): Mist level.

        Returns:
            bool: Success of request.

        Note:
            Mist levels are defined in `self.mist_levels`.
        """

    async def turn_on_display(self) -> bool:
        """Turn on the display.

        Returns:
            bool: Success of request.
        """
        return await self.toggle_display(True)

    async def turn_off_display(self) -> bool:
        """Turn off the display.

        Returns:
            bool: Success of request.
        """
        return await self.toggle_display(False)

    async def turn_on_automatic_stop(self) -> bool:
        """Turn on automatic stop.

        Returns:
            bool: Success of request.
        """
        return await self.toggle_automatic_stop(True)

    async def turn_off_automatic_stop(self) -> bool:
        """Turn off automatic stop.

        Returns:
            bool: Success of request.
        """
        return await self.toggle_automatic_stop(False)

    async def set_auto_mode(self) -> bool:
        """Set Humidifier to Auto Mode.

        Returns:
            bool: Success of request.
        """
        if HumidifierModes.AUTO in self.mist_modes:
            return await self.set_mode(HumidifierModes.AUTO)
        logger.debug("Auto mode not supported for this device.")
        return await self.set_mode(HumidifierModes.AUTO)

    async def set_manual_mode(self) -> bool:
        """Set Humidifier to Manual Mode.

        Returns:
            bool: Success of request.
        """
        if HumidifierModes.MANUAL in self.mist_modes:
            return await self.set_mode(HumidifierModes.MANUAL)
        logger.debug("Manual mode not supported for this device.")
        return await self.set_mode(HumidifierModes.MANUAL)

    async def set_sleep_mode(self) -> bool:
        """Set Humidifier to Sleep Mode.

        Returns:
            bool: Success of request.
        """
        if HumidifierModes.SLEEP in self.mist_modes:
            return await self.set_mode(HumidifierModes.SLEEP)
        logger.debug("Sleep mode not supported for this device.")
        return await self.set_mode(HumidifierModes.SLEEP)

    async def set_humidity(self, humidity: int) -> bool:
        """Set Humidifier Target Humidity.

        Args:
            humidity (int): Target humidity level.

        Returns:
            bool: Success of request.
        """
        del humidity
        logger.debug("Target humidity is not supported or configured for this device.")
        return False

    async def set_nightlight_brightness(self, brightness: int) -> bool:
        """Set Humidifier night light brightness.

        Args:
            brightness (int): Target night light brightness.

        Returns:
            bool: Success of request.
        """
        del brightness
        if not self.supports_nightlight_brightness:
            logger.debug("Nightlight brightness is not supported for this device.")
            return False
        logger.debug("Nightlight brightness has not been configured.")
        return False

    async def set_warm_level(self, warm_level: int) -> bool:
        """Set Humidifier Warm Level.

        Args:
            warm_level (int): Target warm level.

        Returns:
            bool: Success of request.
        """
        del warm_level
        if self.supports_warm_mist:
            logger.debug("Warm level has not been configured.")
            return False
        logger.debug("Warm level is not supported for this device.")
        return False

    async def toggle_drying_mode(self, toggle: bool | None = None) -> bool:
        """enable/disable drying filters after turning off."""
        del toggle
        if self.supports_drying_mode:
            logger.debug("Drying mode is not configured for this device.")
            return False
        logger.debug("Drying mode is not supported for this device.")
        return False

Attributes

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

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

mist_levels instance-attribute

mist_levels: list[str | int] = mist_levels

Inherited From VeSyncHumidifier

mist_modes instance-attribute

mist_modes: dict[str, str] = mist_modes

Inherited From VeSyncHumidifier

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: HumidifierState = HumidifierState(
    self, details, feature_map
)

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_drying_mode property

supports_drying_mode: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports drying mode.

supports_nightlight property

supports_nightlight: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight.

Returns:

Name Type Description
bool bool

True if nightlight is supported, False otherwise.

supports_nightlight_brightness property

supports_nightlight_brightness: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports nightlight brightness.

supports_warm_mist property

supports_warm_mist: bool

Inherited From VeSyncHumidifier

Return True if the humidifier supports warm mist.

Returns:

Name Type Description
bool bool

True if warm mist is supported, False otherwise.

target_minmax instance-attribute

target_minmax: tuple[int, int] = target_minmax

Inherited From VeSyncHumidifier

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

warm_mist_levels instance-attribute

warm_mist_levels: list[int | str] = warm_mist_levels

Inherited From VeSyncHumidifier

Functions

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

set_auto_mode async

set_auto_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Auto Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_auto_mode(self) -> bool:
    """Set Humidifier to Auto Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.AUTO in self.mist_modes:
        return await self.set_mode(HumidifierModes.AUTO)
    logger.debug("Auto mode not supported for this device.")
    return await self.set_mode(HumidifierModes.AUTO)

set_humidity async

set_humidity(humidity: int) -> bool

Set Humidifier Target Humidity.

Parameters:

Name Type Description Default
humidity int

Target humidity level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_humidity(self, humidity: int) -> bool:
    """Set Humidifier Target Humidity.

    Args:
        humidity (int): Target humidity level.

    Returns:
        bool: Success of request.
    """
    del humidity
    logger.debug("Target humidity is not supported or configured for this device.")
    return False

set_manual_mode async

set_manual_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Manual Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_manual_mode(self) -> bool:
    """Set Humidifier to Manual Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.MANUAL in self.mist_modes:
        return await self.set_mode(HumidifierModes.MANUAL)
    logger.debug("Manual mode not supported for this device.")
    return await self.set_mode(HumidifierModes.MANUAL)

set_mist_level abstractmethod async

set_mist_level(level: int) -> bool

Set Mist Level for Humidifier.

Parameters:

Name Type Description Default
level int

Mist level.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Mist levels are defined in self.mist_levels.

Source code in src\pyvesync\base_devices\humidifier_base.py
@abstractmethod
async def set_mist_level(self, level: int) -> bool:
    """Set Mist Level for Humidifier.

    Args:
        level (int): Mist level.

    Returns:
        bool: Success of request.

    Note:
        Mist levels are defined in `self.mist_levels`.
    """

set_mode abstractmethod async

set_mode(mode: str) -> bool

Set Humidifier Mode.

Parameters:

Name Type Description Default
mode str

Humidifier mode.

required

Returns:

Name Type Description
bool bool

Success of request.

Note

Modes for device are defined in self.mist_modes.

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

    Args:
        mode (str): Humidifier mode.

    Returns:
        bool: Success of request.

    Note:
        Modes for device are defined in `self.mist_modes`.
    """

set_nightlight_brightness async

set_nightlight_brightness(brightness: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier night light brightness.

Parameters:

Name Type Description Default
brightness int

Target night light brightness.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_nightlight_brightness(self, brightness: int) -> bool:
    """Set Humidifier night light brightness.

    Args:
        brightness (int): Target night light brightness.

    Returns:
        bool: Success of request.
    """
    del brightness
    if not self.supports_nightlight_brightness:
        logger.debug("Nightlight brightness is not supported for this device.")
        return False
    logger.debug("Nightlight brightness has not been configured.")
    return False

set_sleep_mode async

set_sleep_mode() -> bool

Inherited From VeSyncHumidifier

Set Humidifier to Sleep Mode.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_sleep_mode(self) -> bool:
    """Set Humidifier to Sleep Mode.

    Returns:
        bool: Success of request.
    """
    if HumidifierModes.SLEEP in self.mist_modes:
        return await self.set_mode(HumidifierModes.SLEEP)
    logger.debug("Sleep mode not supported for this device.")
    return await self.set_mode(HumidifierModes.SLEEP)

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_warm_level async

set_warm_level(warm_level: int) -> bool

Inherited From VeSyncHumidifier

Set Humidifier Warm Level.

Parameters:

Name Type Description Default
warm_level int

Target warm level.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def set_warm_level(self, warm_level: int) -> bool:
    """Set Humidifier Warm Level.

    Args:
        warm_level (int): Target warm level.

    Returns:
        bool: Success of request.
    """
    del warm_level
    if self.supports_warm_mist:
        logger.debug("Warm level has not been configured.")
        return False
    logger.debug("Warm level is not supported for this device.")
    return False

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_automatic_stop async

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

Toggle automatic stop.

Parameters:

Name Type Description Default
toggle bool | None

True to enable automatic stop, False to disable.

None

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def toggle_automatic_stop(self, toggle: bool | None = None) -> bool:
    """Toggle automatic stop.

    Args:
        toggle (bool | None): True to enable automatic stop, False to disable.

    Returns:
        bool: Success of request.
    """
    del toggle
    logger.warning("Automatic stop is not supported or configured for this device.")
    return False

toggle_display async

toggle_display(toggle: bool) -> bool

Toggle the display on/off.

Parameters:

Name Type Description Default
toggle bool

True to turn on the display, False to turn off.

required

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def toggle_display(self, toggle: bool) -> bool:
    """Toggle the display on/off.

    Args:
        toggle (bool): True to turn on the display, False to turn off.

    Returns:
        bool: Success of request.
    """
    del toggle
    logger.warning("Display is not supported or configured for this device.")
    return False

toggle_drying_mode async

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

Inherited From VeSyncHumidifier

enable/disable drying filters after turning off.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def toggle_drying_mode(self, toggle: bool | None = None) -> bool:
    """enable/disable drying filters after turning off."""
    del toggle
    if self.supports_drying_mode:
        logger.debug("Drying mode is not configured for this device.")
        return False
    logger.debug("Drying mode is not supported 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.
    """

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_automatic_stop async

turn_off_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn off automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_automatic_stop(self) -> bool:
    """Turn off automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(False)

turn_off_display async

turn_off_display() -> bool

Inherited From VeSyncHumidifier

Turn off the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_off_display(self) -> bool:
    """Turn off the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(False)

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_automatic_stop async

turn_on_automatic_stop() -> bool

Inherited From VeSyncHumidifier

Turn on automatic stop.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_automatic_stop(self) -> bool:
    """Turn on automatic stop.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_automatic_stop(True)

turn_on_display async

turn_on_display() -> bool

Inherited From VeSyncHumidifier

Turn on the display.

Returns:

Name Type Description
bool bool

Success of request.

Source code in src\pyvesync\base_devices\humidifier_base.py
async def turn_on_display(self) -> bool:
    """Turn on the display.

    Returns:
        bool: Success of request.
    """
    return await self.toggle_display(True)

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()