Skip to content

Documentation for Etekcity Smart Switches

Contents

See each device class for available attributes and methods:

pyvesync.base_devices.switch_base.SwitchState

SwitchState(
    device: VeSyncSwitch,
    details: ResponseDeviceDetailsModel,
    feature_map: SwitchMap,
)

Bases: DeviceState

VeSync Switch State Base.

Parameters:

Name Type Description Default
device VeSyncSwitch

The switch device.

required
details ResponseDeviceDetailsModel

The switch device details.

required
feature_map SwitchMap

The switch feature map.

required

Attributes:

Name Type Description
_exclude_serialization list[str]

List of attributes to exclude from serialization.

active_time int

Active time of device, defaults to None.

connection_status str

Connection status of device.

device VeSyncBaseDevice

Device object.

device_status str

Device status.

features dict

Features of device.

last_update_ts int

Last update timestamp of device, defaults to None.

backlight_color Color

The backlight color of the switch.

brightness int

The brightness level of the switch.

backlight_status str

The status of the backlight.

indicator_status str

The status of the indicator light.

Inherited From DeviceState

Initialize device state.

Initialize VeSync Switch State.

Source code in src\pyvesync\base_devices\switch_base.py
def __init__(
    self,
    device: VeSyncSwitch,
    details: ResponseDeviceDetailsModel,
    feature_map: SwitchMap
        ) -> None:
    """Initialize VeSync Switch State."""
    super().__init__(device, details, feature_map)
    self.device: VeSyncSwitch = device
    self._backlight_color: Color | str | None = StrFlag.NOT_SUPPORTED
    self.brightness: int = IntFlag.NOT_SUPPORTED
    self.active_time: int | None = 0
    self.backlight_status: str = StrFlag.NOT_SUPPORTED
    self.indicator_status: str = StrFlag.NOT_SUPPORTED

Attributes

active_time instance-attribute

active_time: int | None = 0

Inherited From DeviceState

backlight_color property writable

backlight_color: Color | None

Get backlight color.

backlight_hsv property

backlight_hsv: HSV | None

Get backlight HSV color.

backlight_rgb property

backlight_rgb: RGB | None

Get backlight RGB color.

backlight_status instance-attribute

backlight_status: str = NOT_SUPPORTED

brightness instance-attribute

brightness: int = NOT_SUPPORTED

connection_status instance-attribute

connection_status: str = connectionStatus or UNKNOWN

Inherited From DeviceState

device instance-attribute

device: VeSyncSwitch = device

Inherited From DeviceState

device_status instance-attribute

device_status: str = deviceStatus or UNKNOWN

Inherited From DeviceState

features instance-attribute

features = features

Inherited From DeviceState

indicator_status instance-attribute

indicator_status: str = NOT_SUPPORTED

last_update_ts instance-attribute

last_update_ts: int | None = None

Inherited From DeviceState

timer instance-attribute

timer: Timer | None = None

Inherited From DeviceState

Functions

as_tuple

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

Inherited From DeviceState

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

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

display

display() -> None

Inherited From DeviceState

Print formatted state to stdout.

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

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.vesyncswitch.VeSyncWallSwitch

VeSyncWallSwitch(
    details: ResponseDeviceDetailsModel,
    manager: VeSync,
    feature_map: SwitchMap,
)

Bases: BypassV1Mixin, VeSyncSwitch

Etekcity standard wall switch.

Inherits from the BypassV1Mixin and VeSyncSwitch classes.

Inherited From VeSyncSwitch

Initialize VeSync device base class.

Initialize Switch Base Class.

Initialize Etekcity Wall Switch class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The VeSync manager.

required
feature_map SwitchMap

The feature map for the device.

required
Source code in src\pyvesync\devices\vesyncswitch.py
def __init__(self, details: ResponseDeviceDetailsModel,
             manager: VeSync, feature_map: SwitchMap) -> None:
    """Initialize Etekcity Wall Switch class.

    Args:
        details (ResponseDeviceDetailsModel): The device details.
        manager (VeSync): The VeSync manager.
        feature_map (SwitchMap): The feature map for the device.
    """
    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_dimmable property

is_dimmable: bool

Inherited From VeSyncSwitch

Return True if switch is dimmable.

is_on property

is_on: bool

Inherited From VeSyncBaseDevice

Return true if device is on.

last_response instance-attribute

last_response: ResponseInfo | None = None

Inherited From VeSyncBaseDevice

mac_id instance-attribute

mac_id: str | None = macID

Inherited From VeSyncBaseDevice

manager instance-attribute

manager: VeSync

Inherited From BypassV1Mixin

pid instance-attribute

pid: str | None = None

Inherited From VeSyncBaseDevice

product_type instance-attribute

product_type: str = product_type

Inherited From VeSyncBaseDevice

request_keys class-attribute

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

Inherited From BypassV1Mixin

state instance-attribute

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

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_backlight property

supports_backlight: bool

Inherited From VeSyncSwitch

Return True if switch supports backlight.

supports_backlight_color property

supports_backlight_color: bool

Inherited From VeSyncSwitch

Return True if switch supports backlight.

supports_dimmable property

supports_dimmable: bool

Inherited From VeSyncSwitch

Return True if switch is dimmable.

supports_indicator_light property

supports_indicator_light: bool

Inherited From VeSyncSwitch

Return True if switch supports indicator.

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

Functions

call_bypassv1_api async

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

Inherited From BypassV1Mixin

Send ByPass V1 API request.

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

Parameters:

Name Type Description Default
request_model type[RequestBypassV1]

The request model to use.

required
update_dict dict

Additional keys to add on.

None
method str

The method to use in the outer body.

'bypass'
endpoint str | None

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

'bypass'

Returns:

Name Type Description
bytes dict | None

The response from the API request.

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

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

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

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

    return resp_dict

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\vesyncswitch.py
async def clear_timer(self) -> bool:
    if self.state.timer is None:
        _LOGGER.warning("No timer set, run get_timer() first.")
        return False
    update_dict = {
        'timerId': str(self.state.timer.id),
    }
    r_dict = await self.call_bypassv1_api(
        TimerModels.RequestV1ClearTimer,
        update_dict,
        method='deleteTimer',
        endpoint='timer/deleteTimer'
    )
    if r_dict is None:
        return False
    result = Helpers.process_dev_response(_LOGGER, "clear_timer", self, r_dict)
    if result 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\vesyncswitch.py
async def get_details(self) -> None:
    r_dict = await self.call_bypassv1_api(
        RequestBypassV1, method='deviceDetail', endpoint='deviceDetail'
        )

    r = Helpers.process_dev_response(_LOGGER, "get_details", self, r_dict)
    if r is None:
        return
    resp_model = Helpers.model_maker(
        _LOGGER, switch_models.ResponseSwitchDetails, "get_details", r, self
    )
    if resp_model is None:
        return
    result = resp_model.result
    if not isinstance(result, switch_models.InternalSwitchResult):
        _LOGGER.warning("Invalid response model for switch details")
        return
    self.state.device_status = result.deviceStatus
    self.state.active_time = result.activeTime
    self.state.connection_status = result.connectionStatus

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() -> 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\vesyncswitch.py
async def get_timer(self) -> None:
    r_dict = await self.call_bypassv1_api(
        TimerModels.RequestV1GetTimer,
        method='getTimers',
        endpoint='timer/getTimers'
    )
    if r_dict is None:
        return
    result_model = process_bypassv1_result(
        self, _LOGGER, "get_timer", r_dict, TimerModels.ResultV1GetTimer
    )
    if result_model is None:
        return

    timers = result_model.timers
    if not isinstance(timers, list) or len(timers) == 0:
        _LOGGER.debug("No timers found")
        return
    if len(timers) > 1:
        _LOGGER.debug("More than one timer found, using first timer")
    timer = timers[0]
    if not isinstance(timer, TimerModels.TimerItemV1):
        _LOGGER.warning("Invalid timer model")
        return
    self.state.timer = Timer(
        int(timer.counterTimer),
        action=timer.action,
        id=int(timer.timerID),
    )

set_backlight_color async

set_backlight_color(
    red: int, green: int, blue: int
) -> bool

Inherited From VeSyncSwitch

Set the color of the backlight using RGB.

Parameters:

Name Type Description Default
red int

Red value (0-255).

required
green int

Green value (0-255).

required
blue int

Blue value (0-255).

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def set_backlight_color(self, red: int, green: int, blue: int) -> bool:
    """Set the color of the backlight using RGB.

    Args:
        red (int): Red value (0-255).
        green (int): Green value (0-255).
        blue (int): Blue value (0-255).

    Returns:
        bool: True if successful, False otherwise.
    """
    return await self.set_backlight_status(
        True, red=red, green=green, blue=blue
    )

set_backlight_status async

set_backlight_status(
    status: bool,
    red: int | None = None,
    green: int | None = None,
    blue: int | None = None,
) -> bool

Inherited From VeSyncSwitch

Sets the backlight status and optionally its color if supported by the device.

Parameters:

Name Type Description Default
status bool

Backlight status (True for ON, False for OFF).

required
red int | None

RGB green value (0-255), defaults to None.

None
green int | None

RGB green value (0-255), defaults to None.

None
blue int | None

RGB blue value (0-255), defaults to None.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def set_backlight_status(
        self,
        status: bool,
        red: int | None = None,
        green: int | None = None,
        blue: int | None = None
) -> bool:
    """Sets the backlight status and optionally its color if supported by the device.

    Args:
        status (bool): Backlight status (True for ON, False for OFF).
        red (int | None): RGB green value (0-255), defaults to None.
        green (int | None): RGB green value (0-255), defaults to None.
        blue (int | None): RGB blue value (0-255), defaults to None.

    Returns:
        bool: True if successful, False otherwise.

    """
    del status, red, green, blue
    if self.supports_backlight:
        logger.debug("set_backlight_status not configured for %s", self.device_name)
    else:
        logger.debug("set_backlight_status not supported for %s", self.device_name)
    return False

set_brightness async

set_brightness(brightness: int) -> bool

Inherited From VeSyncSwitch

Set the brightness of the switch if supported.

Parameters:

Name Type Description Default
brightness int

Brightness value (0-100).

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def set_brightness(self, brightness: int) -> bool:
    """Set the brightness of the switch if supported.

    Args:
        brightness (int): Brightness value (0-100).

    Returns:
        bool: True if successful, False otherwise.
    """
    del brightness
    if self.supports_dimmable:
        logger.debug("set_brightness not configured for %s", self.device_name)
    else:
        logger.debug("set_brightness not supported for %s", self.device_name)
    return False

set_state

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

Inherited From VeSyncBaseDevice

Set device state attribute.

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

set_timer async

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

Inherited From VeSyncBaseDevice

Set timer for device.

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

Parameters:

Name Type Description Default
duration int

Duration in seconds.

required
action str | None

Action to take when timer expires.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncswitch.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    if action is None:
        action = (
            DeviceStatus.ON
            if self.state.device_status == DeviceStatus.OFF
            else DeviceStatus.OFF
        )
    if action not in [DeviceStatus.ON, DeviceStatus.OFF]:
        _LOGGER.warning("Invalid action for timer - on/off")
        return False
    update_dict = {
        'action': action,
        'counterTime': str(duration),
    }
    r_dict = await self.call_bypassv1_api(
        TimerModels.RequestV1SetTime,
        update_dict,
        method='addTimer',
        endpoint='timer/addTimer'
    )
    if r_dict is None:
        return False
    result_model = process_bypassv1_result(
        self, _LOGGER, "set_timer", r_dict, TimerModels.ResultV1SetTimer
    )
    if result_model is None:
        return False
    self.state.timer = Timer(
        int(duration),
        action=action,
        id=int(result_model.timerID),
    )
    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_indicator_light async

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

Inherited From VeSyncSwitch

Toggle indicator light on or off.

Parameters:

Name Type Description Default
toggle bool

True to turn on, False to turn off. If None, toggles the state

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def toggle_indicator_light(self, toggle: bool | None = None) -> bool:
    """Toggle indicator light on or off.

    Args:
        toggle (bool): True to turn on, False to turn off. If None, toggles the state

    Returns:
        bool: True if successful, False otherwise.
    """
    del toggle
    if self.supports_indicator_light:
        logger.debug("toggle_indicator_light not configured for %s", self.device_name)
    else:
        logger.debug("toggle_indicator_light not supported for %s", self.device_name)
    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.

Toggle switch device.

Source code in src\pyvesync\devices\vesyncswitch.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    """Toggle switch device."""
    if toggle is None:
        toggle = self.state.device_status != DeviceStatus.ON
    toggle_str = DeviceStatus.from_bool(toggle)

    r_dict = await self.call_bypassv1_api(
        switch_models.RequestSwitchStatus,
        {"status": toggle_str, "switchNo": 0},
        'deviceStatus',
        'deviceStatus'
        )

    r = Helpers.process_dev_response(_LOGGER, "get_details", 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_indicator_light_off async deprecated

turn_indicator_light_off() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_off_indicator_light instead.

Deprecated, use turn_off_indicator_light.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_off_indicator_light` instead.")
async def turn_indicator_light_off(self) -> bool:
    """Deprecated, use turn_off_indicator_light."""
    return await self.toggle_indicator_light(False)

turn_indicator_light_on async deprecated

turn_indicator_light_on() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_on_indicator_light instead.

Deprecated, use turn_on_indicator_light.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_on_indicator_light` instead.")
async def turn_indicator_light_on(self) -> bool:
    """Deprecated, use turn_on_indicator_light."""
    return await self.toggle_indicator_light(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_indicator_light async

turn_off_indicator_light() -> bool

Inherited From VeSyncSwitch

Turn off indicator light if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_off_indicator_light(self) -> bool:
    """Turn off indicator light if supported."""
    return await self.toggle_indicator_light(False)

turn_off_rgb_backlight async

turn_off_rgb_backlight() -> bool

Inherited From VeSyncSwitch

Turn off backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_off_rgb_backlight(self) -> bool:
    """Turn off backlight if supported."""
    return await self.set_backlight_status(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_indicator_light async

turn_on_indicator_light() -> bool

Inherited From VeSyncSwitch

Turn on indicator light if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_on_indicator_light(self) -> bool:
    """Turn on indicator light if supported."""
    return await self.toggle_indicator_light(True)

turn_on_rgb_backlight async

turn_on_rgb_backlight() -> bool

Inherited From VeSyncSwitch

Turn on backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_on_rgb_backlight(self) -> bool:
    """Turn on backlight if supported."""
    return await self.set_backlight_status(True)

turn_rgb_backlight_off async deprecated

turn_rgb_backlight_off() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_off_rgb_backlight() instead.

Turn off RGB backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_off_rgb_backlight()` instead.")
async def turn_rgb_backlight_off(self) -> bool:
    """Turn off RGB backlight if supported."""
    return await self.set_backlight_status(False)

turn_rgb_backlight_on async deprecated

turn_rgb_backlight_on() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_on_rgb_backlight() instead.

Turn on RGB backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_on_rgb_backlight()` instead.")
async def turn_rgb_backlight_on(self) -> bool:
    """Turn on RGB backlight if supported."""
    return await self.set_backlight_status(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.vesyncswitch.VeSyncDimmerSwitch

VeSyncDimmerSwitch(
    details: ResponseDeviceDetailsModel,
    manager: VeSync,
    feature_map: SwitchMap,
)

Bases: BypassV1Mixin, VeSyncSwitch

Vesync Dimmer Switch Class with RGB Faceplate.

Inherits from the BypassV1Mixin and VeSyncSwitch classes.

Inherited From VeSyncSwitch

Initialize VeSync device base class.

Initialize Switch Base Class.

Initialize dimmer switch class.

Parameters:

Name Type Description Default
details ResponseDeviceDetailsModel

The device details.

required
manager VeSync

The VeSync manager.

required
feature_map SwitchMap

The feature map for the device.

required
Source code in src\pyvesync\devices\vesyncswitch.py
def __init__(self, details: ResponseDeviceDetailsModel,
             manager: VeSync, feature_map: SwitchMap) -> None:
    """Initialize dimmer switch class.

    Args:
        details (ResponseDeviceDetailsModel): The device details.
        manager (VeSync): The VeSync manager.
        feature_map (SwitchMap): The feature map for the device.
    """
    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_dimmable property

is_dimmable: bool

Inherited From VeSyncSwitch

Return True if switch is dimmable.

is_on property

is_on: bool

Inherited From VeSyncBaseDevice

Return true if device is on.

last_response instance-attribute

last_response: ResponseInfo | None = None

Inherited From VeSyncBaseDevice

mac_id instance-attribute

mac_id: str | None = macID

Inherited From VeSyncBaseDevice

manager instance-attribute

manager: VeSync

Inherited From BypassV1Mixin

pid instance-attribute

pid: str | None = None

Inherited From VeSyncBaseDevice

product_type instance-attribute

product_type: str = product_type

Inherited From VeSyncBaseDevice

request_keys class-attribute

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

Inherited From BypassV1Mixin

state instance-attribute

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

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_backlight property

supports_backlight: bool

Inherited From VeSyncSwitch

Return True if switch supports backlight.

supports_backlight_color property

supports_backlight_color: bool

Inherited From VeSyncSwitch

Return True if switch supports backlight.

supports_dimmable property

supports_dimmable: bool

Inherited From VeSyncSwitch

Return True if switch is dimmable.

supports_indicator_light property

supports_indicator_light: bool

Inherited From VeSyncSwitch

Return True if switch supports indicator.

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

Functions

call_bypassv1_api async

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

Inherited From BypassV1Mixin

Send ByPass V1 API request.

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

Parameters:

Name Type Description Default
request_model type[RequestBypassV1]

The request model to use.

required
update_dict dict

Additional keys to add on.

None
method str

The method to use in the outer body.

'bypass'
endpoint str | None

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

'bypass'

Returns:

Name Type Description
bytes dict | None

The response from the API request.

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

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

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

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

    return resp_dict

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\vesyncswitch.py
async def clear_timer(self) -> bool:
    if self.state.timer is None:
        _LOGGER.debug("No timer set, run get_timer() first.")
        return False
    update_dict = {
        'timerId': str(self.state.timer.id),
        'status': "1"
    }
    r_dict = await self.call_bypassv1_api(
        TimerModels.RequestV1ClearTimer,
        update_dict,
        method='deleteTimer',
        endpoint='timer/deleteTimer'
    )
    result = Helpers.process_dev_response(_LOGGER, "clear_timer", self, r_dict)
    if result 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\vesyncswitch.py
async def get_details(self) -> None:
    r_bytes = await self.call_bypassv1_api(
        switch_models.RequestDimmerDetails,
        method="deviceDetail",
        endpoint="deviceDetail",
    )

    r = Helpers.process_dev_response(_LOGGER, "get_details", self, r_bytes)
    if r is None:
        return

    resp_model = Helpers.model_maker(
        _LOGGER, switch_models.ResponseSwitchDetails, "set_timer", r, self
    )
    if resp_model is None:
        return
    result = resp_model.result
    if not isinstance(result, switch_models.InternalDimmerDetailsResult):
        _LOGGER.warning("Invalid response model for dimmer details")
        return
    self.state.active_time = result.activeTime
    self.state.connection_status = result.connectionStatus
    self.state.brightness = result.brightness
    self.state.backlight_status = result.rgbStatus
    new_color = result.rgbValue
    if isinstance(new_color, switch_models.DimmerRGB):
        self.state.backlight_color = Color.from_rgb(
            new_color.red, new_color.green, new_color.blue
            )
    self.state.indicator_status = result.indicatorlightStatus
    self.state.device_status = result.deviceStatus

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() -> 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\vesyncswitch.py
async def get_timer(self) -> None:
    r_dict = await self.call_bypassv1_api(
        TimerModels.RequestV1GetTimer,
        method='getTimers',
        endpoint='timer/getTimers'
    )
    result_model = process_bypassv1_result(
        self, _LOGGER, "get_timer", r_dict, TimerModels.ResultV1GetTimer
    )
    if result_model is None:
        return
    timers = result_model.timers
    if not isinstance(timers, list) or len(timers) == 0:
        _LOGGER.info("No timers found")
        return
    if len(timers) > 1:
        _LOGGER.debug("More than one timer found, using first timer")
    timer = timers[0]
    if not isinstance(timer, TimerModels.TimeItemV1):
        _LOGGER.warning("Invalid timer model")
        return
    self.state.timer = Timer(
        int(timer.counterTime),
        action=timer.action,
        id=int(timer.timerID),
    )

set_backlight_color async

set_backlight_color(
    red: int, green: int, blue: int
) -> bool

Inherited From VeSyncSwitch

Set the color of the backlight using RGB.

Parameters:

Name Type Description Default
red int

Red value (0-255).

required
green int

Green value (0-255).

required
blue int

Blue value (0-255).

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def set_backlight_color(self, red: int, green: int, blue: int) -> bool:
    """Set the color of the backlight using RGB.

    Args:
        red (int): Red value (0-255).
        green (int): Green value (0-255).
        blue (int): Blue value (0-255).

    Returns:
        bool: True if successful, False otherwise.
    """
    return await self.set_backlight_status(
        True, red=red, green=green, blue=blue
    )

set_backlight_status async

set_backlight_status(
    status: bool,
    red: int | None = None,
    green: int | None = None,
    blue: int | None = None,
) -> bool

Inherited From VeSyncSwitch

Sets the backlight status and optionally its color if supported by the device.

Parameters:

Name Type Description Default
status bool

Backlight status (True for ON, False for OFF).

required
red int | None

RGB green value (0-255), defaults to None.

None
green int | None

RGB green value (0-255), defaults to None.

None
blue int | None

RGB blue value (0-255), defaults to None.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\devices\vesyncswitch.py
async def set_backlight_status(
    self,
    status: bool,
    red: int | None = None,
    green: int | None = None,
    blue: int | None = None,
) -> bool:
    if red is not None and blue is not None and green is not None:
        new_color = Color.from_rgb(red, green, blue)
    else:
        new_color = None
    status_str = DeviceStatus.from_bool(status)

    update_dict: dict[str, str | dict] = {"status": status_str.value}
    if new_color is not None:
        update_dict['rgbValue'] = asdict(new_color.rgb)
    r_bytes = await self.call_bypassv1_api(
        switch_models.RequestDimmerStatus,
        update_dict,
        'dimmerRgbValueCtl',
        'dimmerRgbValueCtl'
        )

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

    self.state.backlight_status = status_str
    if new_color is not None:
        self.state.backlight_color = new_color
    self.state.backlight_status = status_str
    self.state.device_status = DeviceStatus.ON
    self.state.connection_status = ConnectionStatus.ONLINE
    return True

set_brightness async

set_brightness(brightness: int) -> bool

Inherited From VeSyncSwitch

Set the brightness of the switch if supported.

Parameters:

Name Type Description Default
brightness int

Brightness value (0-100).

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Set brightness of dimmer - 1 - 100.

Source code in src\pyvesync\devices\vesyncswitch.py
async def set_brightness(self, brightness: int) -> bool:
    """Set brightness of dimmer - 1 - 100."""
    if not Validators.validate_zero_to_hundred(brightness):
        _LOGGER.warning("Invalid brightness - must be between 0 and 100")
        return False

    r_bytes = await self.call_bypassv1_api(
        switch_models.RequestDimmerBrightness,
        {"brightness": brightness},
        'dimmerBrightnessCtl',
        'dimmerBrightnessCtl'
        )

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

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

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\vesyncswitch.py
async def set_timer(self, duration: int, action: str | None = None) -> bool:
    if action is None:
        action = (
            DeviceStatus.ON
            if self.state.device_status == DeviceStatus.OFF
            else DeviceStatus.OFF
        )
    if action not in [DeviceStatus.ON, DeviceStatus.OFF]:
        _LOGGER.warning("Invalid action for timer - on/off")
        return False
    update_dict = {
        'action': action,
        'counterTime': str(duration),
        'status': "1"
    }
    r_dict = await self.call_bypassv1_api(
        TimerModels.RequestV1SetTime,
        update_dict,
        method='addTimer',
        endpoint='timer/addTimer'
    )
    result_model = process_bypassv1_result(
        self, _LOGGER, "set_timer", r_dict, TimerModels.ResultV1SetTimer
    )
    if result_model is None:
        return False
    self.state.timer = Timer(
        int(duration),
        action=action,
        id=int(result_model.timerID),
    )
    return True

switch_toggle async

switch_toggle(status: str) -> bool

Toggle switch status.

Source code in src\pyvesync\devices\vesyncswitch.py
@deprecated(
    reason="switch_toggle() deprecated, use toggle_switch(toggle: bool | None = None)"
)
async def switch_toggle(self, status: str) -> bool:
    """Toggle switch status."""
    return await self.toggle_switch(status == DeviceStatus.ON)

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

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

Inherited From VeSyncSwitch

Toggle indicator light on or off.

Parameters:

Name Type Description Default
toggle bool

True to turn on, False to turn off. If None, toggles the state

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Toggle indicator light.

Source code in src\pyvesync\devices\vesyncswitch.py
async def toggle_indicator_light(self, toggle: bool | None = None) -> bool:
    """Toggle indicator light."""
    if toggle is None:
        toggle = self.state.indicator_status == 'off'
    toggle_status = DeviceStatus.from_bool(toggle)

    r_bytes = await self.call_bypassv1_api(
        switch_models.RequestDimmerStatus,
        {"status": toggle_status},
        'dimmerIndicatorLightCtl',
        'dimmerIndicatorLightCtl'
        )

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

    self.state.indicator_status = toggle_status
    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\vesyncswitch.py
async def toggle_switch(self, toggle: bool | None = None) -> bool:
    if toggle is None:
        toggle = self.state.device_status == 'off'
    toggle_status = DeviceStatus.from_bool(toggle)

    r_bytes = await self.call_bypassv1_api(
        switch_models.RequestDimmerStatus,
        {"status": toggle_status},
        'dimmerPowerSwitchCtl',
        'dimmerPowerSwitchCtl'
        )

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

    self.state.device_status = toggle_status
    return True

turn_indicator_light_off async deprecated

turn_indicator_light_off() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_off_indicator_light instead.

Deprecated, use turn_off_indicator_light.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_off_indicator_light` instead.")
async def turn_indicator_light_off(self) -> bool:
    """Deprecated, use turn_off_indicator_light."""
    return await self.toggle_indicator_light(False)

turn_indicator_light_on async deprecated

turn_indicator_light_on() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_on_indicator_light instead.

Deprecated, use turn_on_indicator_light.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_on_indicator_light` instead.")
async def turn_indicator_light_on(self) -> bool:
    """Deprecated, use turn_on_indicator_light."""
    return await self.toggle_indicator_light(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_indicator_light async

turn_off_indicator_light() -> bool

Inherited From VeSyncSwitch

Turn off indicator light if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_off_indicator_light(self) -> bool:
    """Turn off indicator light if supported."""
    return await self.toggle_indicator_light(False)

turn_off_rgb_backlight async

turn_off_rgb_backlight() -> bool

Inherited From VeSyncSwitch

Turn off backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_off_rgb_backlight(self) -> bool:
    """Turn off backlight if supported."""
    return await self.set_backlight_status(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_indicator_light async

turn_on_indicator_light() -> bool

Inherited From VeSyncSwitch

Turn on indicator light if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_on_indicator_light(self) -> bool:
    """Turn on indicator light if supported."""
    return await self.toggle_indicator_light(True)

turn_on_rgb_backlight async

turn_on_rgb_backlight() -> bool

Inherited From VeSyncSwitch

Turn on backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_on_rgb_backlight(self) -> bool:
    """Turn on backlight if supported."""
    return await self.set_backlight_status(True)

turn_rgb_backlight_off async deprecated

turn_rgb_backlight_off() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_off_rgb_backlight() instead.

Turn off RGB backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_off_rgb_backlight()` instead.")
async def turn_rgb_backlight_off(self) -> bool:
    """Turn off RGB backlight if supported."""
    return await self.set_backlight_status(False)

turn_rgb_backlight_on async deprecated

turn_rgb_backlight_on() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_on_rgb_backlight() instead.

Turn on RGB backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_on_rgb_backlight()` instead.")
async def turn_rgb_backlight_on(self) -> bool:
    """Turn on RGB backlight if supported."""
    return await self.set_backlight_status(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.switch_base.VeSyncSwitch

VeSyncSwitch(
    details: ResponseDeviceDetailsModel,
    manager: VeSync,
    feature_map: SwitchMap,
)

Bases: VeSyncBaseToggleDevice

Etekcity Switch Base Class.

Abstract Base Class for Etekcity Switch Devices, inheriting from pyvesync.vesyncbasedevice.VeSyncBaseDevice. Should not be instantiated directly, subclassed by VeSyncWallSwitch and VeSyncDimmerSwitch.

Attributes:

Name Type Description
state SwitchState

Switch state object.

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.

Inherited From VeSyncBaseDevice

Initialize VeSync device base class.

Initialize Switch Base Class.

Source code in src\pyvesync\base_devices\switch_base.py
def __init__(self, details: ResponseDeviceDetailsModel,
             manager: VeSync, feature_map: SwitchMap) -> None:
    """Initialize Switch Base Class."""
    super().__init__(details, manager, feature_map)
    self.state: SwitchState = SwitchState(self, details, 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_dimmable property

is_dimmable: bool

Inherited From VeSyncSwitch

Return True if switch is dimmable.

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

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

Inherited From VeSyncBaseDevice

sub_device_no instance-attribute

sub_device_no: int | None = subDeviceNo

Inherited From VeSyncBaseDevice

supports_backlight property

supports_backlight: bool

Inherited From VeSyncSwitch

Return True if switch supports backlight.

supports_backlight_color property

supports_backlight_color: bool

Inherited From VeSyncSwitch

Return True if switch supports backlight.

supports_dimmable property

supports_dimmable: bool

Inherited From VeSyncSwitch

Return True if switch is dimmable.

supports_indicator_light property

supports_indicator_light: bool

Inherited From VeSyncSwitch

Return True if switch supports indicator.

type instance-attribute

type: str | None = type

Inherited From VeSyncBaseDevice

uuid instance-attribute

uuid: str | None = uuid

Inherited From VeSyncBaseDevice

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

set_backlight_color(
    red: int, green: int, blue: int
) -> bool

Inherited From VeSyncSwitch

Set the color of the backlight using RGB.

Parameters:

Name Type Description Default
red int

Red value (0-255).

required
green int

Green value (0-255).

required
blue int

Blue value (0-255).

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def set_backlight_color(self, red: int, green: int, blue: int) -> bool:
    """Set the color of the backlight using RGB.

    Args:
        red (int): Red value (0-255).
        green (int): Green value (0-255).
        blue (int): Blue value (0-255).

    Returns:
        bool: True if successful, False otherwise.
    """
    return await self.set_backlight_status(
        True, red=red, green=green, blue=blue
    )

set_backlight_status async

set_backlight_status(
    status: bool,
    red: int | None = None,
    green: int | None = None,
    blue: int | None = None,
) -> bool

Inherited From VeSyncSwitch

Sets the backlight status and optionally its color if supported by the device.

Parameters:

Name Type Description Default
status bool

Backlight status (True for ON, False for OFF).

required
red int | None

RGB green value (0-255), defaults to None.

None
green int | None

RGB green value (0-255), defaults to None.

None
blue int | None

RGB blue value (0-255), defaults to None.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def set_backlight_status(
        self,
        status: bool,
        red: int | None = None,
        green: int | None = None,
        blue: int | None = None
) -> bool:
    """Sets the backlight status and optionally its color if supported by the device.

    Args:
        status (bool): Backlight status (True for ON, False for OFF).
        red (int | None): RGB green value (0-255), defaults to None.
        green (int | None): RGB green value (0-255), defaults to None.
        blue (int | None): RGB blue value (0-255), defaults to None.

    Returns:
        bool: True if successful, False otherwise.

    """
    del status, red, green, blue
    if self.supports_backlight:
        logger.debug("set_backlight_status not configured for %s", self.device_name)
    else:
        logger.debug("set_backlight_status not supported for %s", self.device_name)
    return False

set_brightness async

set_brightness(brightness: int) -> bool

Inherited From VeSyncSwitch

Set the brightness of the switch if supported.

Parameters:

Name Type Description Default
brightness int

Brightness value (0-100).

required

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def set_brightness(self, brightness: int) -> bool:
    """Set the brightness of the switch if supported.

    Args:
        brightness (int): Brightness value (0-100).

    Returns:
        bool: True if successful, False otherwise.
    """
    del brightness
    if self.supports_dimmable:
        logger.debug("set_brightness not configured for %s", self.device_name)
    else:
        logger.debug("set_brightness not supported for %s", self.device_name)
    return False

set_state

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

Inherited From VeSyncBaseDevice

Set device state attribute.

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

set_timer async

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

Inherited From VeSyncBaseDevice

Set timer for device.

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

Parameters:

Name Type Description Default
duration int

Duration in seconds.

required
action str | None

Action to take when timer expires.

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

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

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

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

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

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

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

Inherited From VeSyncSwitch

Toggle indicator light on or off.

Parameters:

Name Type Description Default
toggle bool

True to turn on, False to turn off. If None, toggles the state

None

Returns:

Name Type Description
bool bool

True if successful, False otherwise.

Source code in src\pyvesync\base_devices\switch_base.py
async def toggle_indicator_light(self, toggle: bool | None = None) -> bool:
    """Toggle indicator light on or off.

    Args:
        toggle (bool): True to turn on, False to turn off. If None, toggles the state

    Returns:
        bool: True if successful, False otherwise.
    """
    del toggle
    if self.supports_indicator_light:
        logger.debug("toggle_indicator_light not configured for %s", self.device_name)
    else:
        logger.debug("toggle_indicator_light not supported for %s", self.device_name)
    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_indicator_light_off async deprecated

turn_indicator_light_off() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_off_indicator_light instead.

Deprecated, use turn_off_indicator_light.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_off_indicator_light` instead.")
async def turn_indicator_light_off(self) -> bool:
    """Deprecated, use turn_off_indicator_light."""
    return await self.toggle_indicator_light(False)

turn_indicator_light_on async deprecated

turn_indicator_light_on() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_on_indicator_light instead.

Deprecated, use turn_on_indicator_light.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_on_indicator_light` instead.")
async def turn_indicator_light_on(self) -> bool:
    """Deprecated, use turn_on_indicator_light."""
    return await self.toggle_indicator_light(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_indicator_light async

turn_off_indicator_light() -> bool

Inherited From VeSyncSwitch

Turn off indicator light if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_off_indicator_light(self) -> bool:
    """Turn off indicator light if supported."""
    return await self.toggle_indicator_light(False)

turn_off_rgb_backlight async

turn_off_rgb_backlight() -> bool

Inherited From VeSyncSwitch

Turn off backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_off_rgb_backlight(self) -> bool:
    """Turn off backlight if supported."""
    return await self.set_backlight_status(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_indicator_light async

turn_on_indicator_light() -> bool

Inherited From VeSyncSwitch

Turn on indicator light if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_on_indicator_light(self) -> bool:
    """Turn on indicator light if supported."""
    return await self.toggle_indicator_light(True)

turn_on_rgb_backlight async

turn_on_rgb_backlight() -> bool

Inherited From VeSyncSwitch

Turn on backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
async def turn_on_rgb_backlight(self) -> bool:
    """Turn on backlight if supported."""
    return await self.set_backlight_status(True)

turn_rgb_backlight_off async deprecated

turn_rgb_backlight_off() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_off_rgb_backlight() instead.

Turn off RGB backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_off_rgb_backlight()` instead.")
async def turn_rgb_backlight_off(self) -> bool:
    """Turn off RGB backlight if supported."""
    return await self.set_backlight_status(False)

turn_rgb_backlight_on async deprecated

turn_rgb_backlight_on() -> bool

Inherited From VeSyncSwitch

Deprecated

Use turn_on_rgb_backlight() instead.

Turn on RGB backlight if supported.

Source code in src\pyvesync\base_devices\switch_base.py
@deprecated("Use `turn_on_rgb_backlight()` instead.")
async def turn_rgb_backlight_on(self) -> bool:
    """Turn on RGB backlight if supported."""
    return await self.set_backlight_status(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()