Documentation for Etekcity Smart Switches ↲
Contents↲
See each device class for available attributes and methods:
- SwitchState Class
- Etekcity Dimmer Switch EWD16
- Etekcity Wall Switch ESWL01 & ESWL03
- VeSyncSwitch Abstract Base Class
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
Attributes↲
connection_status
instance-attribute
↲
Inherited From DeviceState
device_status
instance-attribute
↲
Inherited From DeviceState
Functions↲
as_tuple ↲
Inherited From DeviceState
Convert state to tuple of (name, value) tuples.
display ↲
Inherited From DeviceState
Print formatted state to stdout.
to_dict ↲
Inherited From DeviceState
Convert state to dictionary.
to_json ↲
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
to_jsonb ↲
Inherited From DeviceState
Convert state to JSON bytes.
Source code in src\pyvesync\base_devices\vesyncbasedevice.py
update_ts ↲
Inherited From DeviceState
Update last update 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
Attributes↲
config_module
instance-attribute
↲
Inherited From VeSyncBaseDevice
connection_type
instance-attribute
↲
Inherited From VeSyncBaseDevice
current_firm_version
instance-attribute
↲
Inherited From VeSyncBaseDevice
device_image
instance-attribute
↲
Inherited From VeSyncBaseDevice
device_region
instance-attribute
↲
Inherited From VeSyncBaseDevice
firmware_update
property
↲
Inherited From VeSyncBaseDevice
Return True if firmware update available.
This is going to be updated.
is_dimmable
property
↲
Inherited From VeSyncSwitch
Return True if switch is dimmable.
last_response
instance-attribute
↲
last_response: ResponseInfo | None = None
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
↲
Inherited From VeSyncBaseDevice
supports_backlight
property
↲
Inherited From VeSyncSwitch
Return True if switch supports backlight.
supports_backlight_color
property
↲
Inherited From VeSyncSwitch
Return True if switch supports backlight.
supports_dimmable
property
↲
Inherited From VeSyncSwitch
Return True if switch is dimmable.
supports_indicator_light
property
↲
Inherited From VeSyncSwitch
Return True if switch supports indicator.
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'
|
Returns:
Name | Type | Description |
---|---|---|
bytes |
dict | None
|
The response from the API request. |
Source code in src\pyvesync\utils\device_mixins.py
clear_timer
async
↲
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
display ↲
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
displayJSON
deprecated
↲
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
get_details
async
↲
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
get_state ↲
Inherited From VeSyncBaseDevice
Get device state attribute.
get_timer
async
↲
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
set_backlight_color
async
↲
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
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
set_brightness
async
↲
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
set_state ↲
Inherited From VeSyncBaseDevice
Set device state attribute.
set_timer
async
↲
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
to_dict ↲
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
to_json ↲
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
to_jsonb ↲
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.
Source code in src\pyvesync\base_devices\vesyncbasedevice.py
toggle_indicator_light
async
↲
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
toggle_switch
async
↲
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
turn_indicator_light_off
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_off_indicator_light
instead.
Deprecated, use turn_off_indicator_light.
turn_indicator_light_on
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_on_indicator_light
instead.
Deprecated, use turn_on_indicator_light.
turn_off
async
↲
Inherited From VeSyncBaseToggleDevice
Turn device off.
turn_off_indicator_light
async
↲
Inherited From VeSyncSwitch
Turn off indicator light if supported.
turn_off_rgb_backlight
async
↲
Inherited From VeSyncSwitch
Turn off backlight if supported.
turn_on
async
↲
Inherited From VeSyncBaseToggleDevice
Turn device on.
turn_on_indicator_light
async
↲
Inherited From VeSyncSwitch
Turn on indicator light if supported.
turn_on_rgb_backlight
async
↲
Inherited From VeSyncSwitch
Turn on backlight if supported.
turn_rgb_backlight_off
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_off_rgb_backlight()
instead.
Turn off RGB backlight if supported.
turn_rgb_backlight_on
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_on_rgb_backlight()
instead.
Turn on RGB backlight if supported.
update
async
↲
Inherited From VeSyncBaseDevice
Update device 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
Attributes↲
config_module
instance-attribute
↲
Inherited From VeSyncBaseDevice
connection_type
instance-attribute
↲
Inherited From VeSyncBaseDevice
current_firm_version
instance-attribute
↲
Inherited From VeSyncBaseDevice
device_image
instance-attribute
↲
Inherited From VeSyncBaseDevice
device_region
instance-attribute
↲
Inherited From VeSyncBaseDevice
firmware_update
property
↲
Inherited From VeSyncBaseDevice
Return True if firmware update available.
This is going to be updated.
is_dimmable
property
↲
Inherited From VeSyncSwitch
Return True if switch is dimmable.
last_response
instance-attribute
↲
last_response: ResponseInfo | None = None
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
↲
Inherited From VeSyncBaseDevice
supports_backlight
property
↲
Inherited From VeSyncSwitch
Return True if switch supports backlight.
supports_backlight_color
property
↲
Inherited From VeSyncSwitch
Return True if switch supports backlight.
supports_dimmable
property
↲
Inherited From VeSyncSwitch
Return True if switch is dimmable.
supports_indicator_light
property
↲
Inherited From VeSyncSwitch
Return True if switch supports indicator.
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'
|
Returns:
Name | Type | Description |
---|---|---|
bytes |
dict | None
|
The response from the API request. |
Source code in src\pyvesync\utils\device_mixins.py
clear_timer
async
↲
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
display ↲
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
displayJSON
deprecated
↲
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
get_details
async
↲
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
get_state ↲
Inherited From VeSyncBaseDevice
Get device state attribute.
get_timer
async
↲
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
set_backlight_color
async
↲
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
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
set_brightness
async
↲
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
set_state ↲
Inherited From VeSyncBaseDevice
Set device state attribute.
set_timer
async
↲
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
switch_toggle
async
↲
Toggle switch status.
Source code in src\pyvesync\devices\vesyncswitch.py
to_dict ↲
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
to_json ↲
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
to_jsonb ↲
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.
Source code in src\pyvesync\base_devices\vesyncbasedevice.py
toggle_indicator_light
async
↲
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
toggle_switch
async
↲
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
turn_indicator_light_off
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_off_indicator_light
instead.
Deprecated, use turn_off_indicator_light.
turn_indicator_light_on
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_on_indicator_light
instead.
Deprecated, use turn_on_indicator_light.
turn_off
async
↲
Inherited From VeSyncBaseToggleDevice
Turn device off.
turn_off_indicator_light
async
↲
Inherited From VeSyncSwitch
Turn off indicator light if supported.
turn_off_rgb_backlight
async
↲
Inherited From VeSyncSwitch
Turn off backlight if supported.
turn_on
async
↲
Inherited From VeSyncBaseToggleDevice
Turn device on.
turn_on_indicator_light
async
↲
Inherited From VeSyncSwitch
Turn on indicator light if supported.
turn_on_rgb_backlight
async
↲
Inherited From VeSyncSwitch
Turn on backlight if supported.
turn_rgb_backlight_off
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_off_rgb_backlight()
instead.
Turn off RGB backlight if supported.
turn_rgb_backlight_on
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_on_rgb_backlight()
instead.
Turn on RGB backlight if supported.
update
async
↲
Inherited From VeSyncBaseDevice
Update device 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
Attributes↲
config_module
instance-attribute
↲
Inherited From VeSyncBaseDevice
connection_type
instance-attribute
↲
Inherited From VeSyncBaseDevice
current_firm_version
instance-attribute
↲
Inherited From VeSyncBaseDevice
device_image
instance-attribute
↲
Inherited From VeSyncBaseDevice
device_region
instance-attribute
↲
Inherited From VeSyncBaseDevice
firmware_update
property
↲
Inherited From VeSyncBaseDevice
Return True if firmware update available.
This is going to be updated.
is_dimmable
property
↲
Inherited From VeSyncSwitch
Return True if switch is dimmable.
last_response
instance-attribute
↲
last_response: ResponseInfo | None = None
Inherited From VeSyncBaseDevice
state
instance-attribute
↲
state: SwitchState = SwitchState(self, details, feature_map)
Inherited From VeSyncBaseDevice
sub_device_no
instance-attribute
↲
Inherited From VeSyncBaseDevice
supports_backlight
property
↲
Inherited From VeSyncSwitch
Return True if switch supports backlight.
supports_backlight_color
property
↲
Inherited From VeSyncSwitch
Return True if switch supports backlight.
supports_dimmable
property
↲
Inherited From VeSyncSwitch
Return True if switch is dimmable.
supports_indicator_light
property
↲
Inherited From VeSyncSwitch
Return True if switch supports indicator.
Functions↲
clear_timer
async
↲
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
display ↲
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
displayJSON
deprecated
↲
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
get_details
abstractmethod
async
↲
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
get_state ↲
Inherited From VeSyncBaseDevice
Get device state attribute.
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
set_backlight_color
async
↲
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
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
set_brightness
async
↲
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
set_state ↲
Inherited From VeSyncBaseDevice
Set device state attribute.
set_timer
async
↲
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
to_dict ↲
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
to_json ↲
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
to_jsonb ↲
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.
Source code in src\pyvesync\base_devices\vesyncbasedevice.py
toggle_indicator_light
async
↲
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
toggle_switch
abstractmethod
async
↲
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
turn_indicator_light_off
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_off_indicator_light
instead.
Deprecated, use turn_off_indicator_light.
turn_indicator_light_on
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_on_indicator_light
instead.
Deprecated, use turn_on_indicator_light.
turn_off
async
↲
Inherited From VeSyncBaseToggleDevice
Turn device off.
turn_off_indicator_light
async
↲
Inherited From VeSyncSwitch
Turn off indicator light if supported.
turn_off_rgb_backlight
async
↲
Inherited From VeSyncSwitch
Turn off backlight if supported.
turn_on
async
↲
Inherited From VeSyncBaseToggleDevice
Turn device on.
turn_on_indicator_light
async
↲
Inherited From VeSyncSwitch
Turn on indicator light if supported.
turn_on_rgb_backlight
async
↲
Inherited From VeSyncSwitch
Turn on backlight if supported.
turn_rgb_backlight_off
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_off_rgb_backlight()
instead.
Turn off RGB backlight if supported.
turn_rgb_backlight_on
async
deprecated
↲
Inherited From VeSyncSwitch
Deprecated
Use turn_on_rgb_backlight()
instead.
Turn on RGB backlight if supported.
update
async
↲
Inherited From VeSyncBaseDevice
Update device details.