OptionalstatusCode: numberOptionalstatusMessage: stringError thrown when API is not available or credentials are missing
+Represents the advertising data parser for SwitchBot devices.
-StaticparseParses the advertisement data coming from SwitchBot device.
-This function processes advertising packets received from SwitchBot devices -and extracts relevant information based on the device type.
-The peripheral device object from noble.
-The function to emit log messages.
-null if the device is not recognized.StaticparseParses the service data based on the device model.
-The device model.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-BLE Connection for communicating with SwitchBot devices
+Connect to a device
+Disconnect from a device
+Disconnect all devices
+Get connected device count
+Check if connected to device
+Mark the next disconnect for this MAC as expected
+Read data from device
+Write data to device
+Error thrown when BLE is not available or supported
+BLE Scanner for discovering SwitchBot devices
+Cleanup all resources
+Get discovered device by MAC or BLE ID
+OptionalbleId: stringGet all discovered devices
+Check if currently scanning
+Stop scanning
+Wait for specific device
+OptionalbleId: stringError thrown when a command fails
+OptionalconnectionType: "ble" | "api"OptionaloriginalError: ErrorError thrown when a connection timeout occurs
+OptionaltimeoutMs: numberDevice Manager for managing multiple devices
+OptionallogLevel: numberClear all devices
+Get device count
+Get all device IDs
+Check if device exists
+Get all devices
+Remove a device from the manager
+Get devices as an object keyed by ID
+Error thrown when a device is not found
+AbstractBase class for devices that should ignore advertisement state while connected. +Prevents stale BLE advertisement data from overriding active connection state.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+AbstractgetCheck if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Error thrown when device discovery fails
+OptionaloriginalError: ErrorEnhanced error handling utilities.
-StaticcreateCreates a command error with context.
-The command that failed
-The device ID
-Optionalcause: ErrorThe underlying cause
-A descriptive command error
-StaticcreateCreates a connection error with context.
-The device ID that failed to connect
-Optionalcause: ErrorThe underlying cause of the connection failure
-A descriptive connection error
-StaticcreateCreates a timeout error with context.
-The operation that timed out
-The timeout duration in milliseconds
-A descriptive timeout error
-StaticwithWraps an async operation with timeout and enhanced error handling.
-The async operation to wrap
-Timeout in milliseconds
-Name of the operation for error messages
-Promise that resolves with the operation result or rejects with timeout
-OpenAPI Client for SwitchBot API v1.1
+OptionallogLevel: numberCurtain-specific commands
+Delete webhook
+Execute a scene
+Get client configuration
+Get all devices
+Get all scenes
+Check if device has cloud service enabled
+Send command to device
+Optionalparameter: anyUpdate base URL
+Optionaloptions: EventEmitterOptionsGets the current error object.
-Checks if the specified object contains valid values based on the provided rules.
-Object including parameters you want to check.
-Object including rules for the parameters.
-Optionalrequired: boolean = falseFlag whether the obj is required or not.
Checks if the value is an array.
-The value to check.
-The rule object containing validation criteria.
-Optionalname: string = 'value'The parameter name.
-Checks if the value is a boolean.
-The value to check.
-The rule object containing validation criteria.
-Optionalname: string = 'value'The parameter name.
-Checks if the value is a float.
-The value to check.
-The rule object containing validation criteria.
-Optionalname: string = 'value'The parameter name.
-Checks if the value is an integer.
-The value to check.
-The rule object containing validation criteria.
-Optionalname: string = 'value'The parameter name.
-Checks if the value is an object.
-The value to check.
-The rule object containing validation criteria.
-Optionalname: string = 'value'The parameter name.
-Checks if the value is specified (not undefined).
-The value to check.
-Checks if the value is a string.
-The value to check.
-The rule object containing validation criteria.
-Optionalname: string = 'value'The parameter name.
-AbstractBase class for devices that expose an advertisement sequence number. +Automatically triggers a status refresh when the sequence number changes.
+Subclasses should implement their getStatus() using the centralized
+getStatusWithFallback() method from SwitchBotDevice for robust BLE-first,
+API-fallback logic. See SwitchBotDevice for details.
Example:
+async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }),
apiData => ({ ... })
)
}
+
+
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+AbstractgetCheck if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Main SwitchBot class - Hybrid BLE/API with automatic fallback
+Get device manager (for accessing devices)
+Cleanup and disconnect
+Discover devices (BLE + OpenAPI) +BLE discovery runs first, then API discovery to enable proper device matching
+Get API client (if available)
+Get BLE scanner (if available)
+Get configuration
+Check if API is available
+Check if BLE is available
+SwitchBotBLE class to interact with SwitchBot devices.
-OptionalonadvertisementOptionalondiscoverDiscovers Switchbot devices with enhanced error handling and logging.
-The discovery parameters.
-A Promise that resolves with an array of discovered Switchbot devices.
-Starts scanning for SwitchBot devices.
-Optionalparams: Params = {}Optional parameters.
-Stops scanning for SwitchBot devices.
-Validates the parameters.
-The parameters to validate.
-The schema to validate against.
-Waits for the specified time.
-The time to wait in milliseconds.
-Base error class for SwitchBot errors
+Optionalcode: stringThe SwitchBotOpenAPI class provides methods to interact with the SwitchBot OpenAPI.
-It allows you to retrieve device information, control devices, and manage webhooks.
const switchBotAPI = new SwitchBotOpenAPI('your-token', 'your-secret');
// Get devices
switchBotAPI.getDevices().then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
// Control a device
switchBotAPI.controlDevice('device-id', 'turnOn', 'default').then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
// Setup webhook
switchBotAPI.setupWebhook('http://your-webhook-url').then(() => {
console.log('Webhook setup successfully');
}).catch(error => {
console.error(error);
});
-
-
-Creates an instance of the SwitchBot OpenAPI client.
-The API token used for authentication.
-The secret key used for signing requests.
-Optionalhostname: stringOptionalwebhookControls a device by sending a command to the SwitchBot API.
-The ID of the device to control.
-The command to send to the device.
-The parameter for the command.
-The type of the command (default is 'command').
-Optionaltoken: string(Optional) The token used for authentication. If not provided, the instance token will be used.
-Optionalsecret: string(Optional) The secret used for authentication. If not provided, the instance secret will be used.
-A promise that resolves to an object containing the response body and status code.
-Deletes a webhook by sending a request to the specified URL.
-The URL of the webhook to be deleted.
-Optionaltoken: string(Optional) The token used for authentication. If not provided, the instance token will be used.
-Optionalsecret: string(Optional) The secret used for authentication. If not provided, the instance secret will be used.
-A promise that resolves when the webhook is successfully deleted.
-Retrieves the list of devices from the SwitchBot OpenAPI.
-Optionaltoken: string(Optional) The token used for authentication. If not provided, the instance token will be used.
-Optionalsecret: string(Optional) The secret used for authentication. If not provided, the instance secret will be used.
-A promise that resolves to an object containing the API response.
-Retrieves the status of a specific device.
-The unique identifier of the device.
-Optionaltoken: string(Optional) The token used for authentication. If not provided, the instance token will be used.
-Optionalsecret: string(Optional) The secret used for authentication. If not provided, the instance secret will be used.
-A promise that resolves to an object containing the device status and the status code of the request.
-Sets up a webhook listener and configures the webhook on the server.
-This method performs the following steps:
-The URL to which the webhook events will be sent.
-Optionaltoken: string(Optional) The token used for authentication. If not provided, the instance token will be used.
-Optionalsecret: string(Optional) The secret used for authentication. If not provided, the instance secret will be used.
-A promise that resolves when the webhook setup is complete.
-Represents a Switchbot Device.
-AbstractBase class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Initializes a new instance of the SwitchbotDevice class.
-The peripheral object from noble.
-The Noble object.
-Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+AbstractgetCheck if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Error thrown when invalid parameters are provided
+Optionalparameter: stringUtility class for comprehensive input validation with improved error messages.
-StaticvalidateValidates buffer and throws descriptive error.
-The buffer to validate
-OptionalexpectedLength: numberOptional expected length
-The parameter name for error reporting
-StaticvalidateStaticvalidateStaticvalidateStaticvalidateValidates numeric range with enhanced checks.
-The value to validate
-Minimum allowed value
-Maximum allowed value
-The parameter name for error reporting
-Whether the value must be an integer
-StaticvalidateStaticvalidateValidates string input with comprehensive checks.
-The value to validate
-The parameter name for error reporting
-Minimum required length
-OptionalmaxLength: numberOptional maximum length
-Base class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a SwitchBot Air Purifier device.
-Air Purifier Device
+Initializes a new instance of the SwitchbotDevice class.
-The peripheral object from noble.
-The Noble object.
-Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Operates the air purifier with the given byte array.
-The byte array to send.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Sets the mode of the air purifier.
-The mode value (1-4).
-Sets the speed of the air purifier.
-The speed value (0-100).
-Turns the air purifier off.
-Turns the air purifier on.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses service data for air purifier devices.
-The service data buffer.
-The manufacturer data buffer.
-OptionalemitLog: (level: string, message: string) => voidThe function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Set fan speed (1-4)
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Base class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Set fan speed (1-4)
+Set mode (auto/manual/sleep)
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Class representing a SwitchBot Air Purifier Table device.
-Air Purifier Table Device +Uses same logic as standard Air Purifier
+Initializes a new instance of the SwitchbotDevice class.
-The peripheral object from noble.
-The Noble object.
-Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Operates the air purifier table with the given byte array.
-The byte array to send.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Sets the mode of the air purifier table.
-The mode value (1-4).
-Sets the speed of the air purifier table.
-The speed value (0-100).
-Turns the air purifier table off.
-Turns the air purifier table on.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses service data for air purifier table devices.
-The service data buffer.
-The manufacturer data buffer.
-OptionalemitLog: (level: string, message: string) => voidThe function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Set fan speed (1-4)
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Art Frame Device +Uses same logic as Color Bulb
+StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Class representing a WoBlindTilt device.
-Blind Tilt Device
+Closes the blind tilt to the nearest endpoint.
-Closes the blind tilt down to the nearest endpoint.
-Closes the blind tilt up to the nearest endpoint.
-Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the basic information of the blind tilt.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Retrieves the current position of the blind tilt.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Opens the blind tilt to the fully open position.
-Pauses the blind tilt operation.
-Runs the blind tilt to the specified position.
-The target position percentage (0-100).
-The running mode (0 or 1).
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data and manufacturer data for the WoBlindTilt device.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-Optionalreverse: boolean = falseWhether to reverse the tilt percentage.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Close blind up (position 100%)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Check if API is available for this device
+Check if BLE is available for this device
+Open blind (position 50%)
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoBulb device.
-Color Bulb Device
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Reads the state of the bulb.
-Sets the brightness of the bulb.
-The brightness percentage (0-100).
-Sets the color temperature of the bulb.
-The color temperature percentage (0-100).
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Sets the RGB color of the bulb.
-The brightness percentage (0-100).
-The red color value (0-255).
-The green color value (0-255).
-The blue color value (0-255).
-Turns off the bulb.
-Turns on the bulb.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoBulb.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Base class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Set brightness (1-100)
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off the candle warmer lamp
+Turn on the candle warmer lamp
+Unregister a fallback handler
+Class representing a WoCeilingLight device.
-Ceiling Light Device +Uses same logic as Color Bulb
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sends a command to the ceiling light.
-The command bytes.
-Reads the state of the ceiling light.
-Sets the brightness of the ceiling light.
-The brightness percentage (0-100).
-Sets the color temperature of the ceiling light.
-The color temperature percentage (0-100).
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Sets the RGB color of the ceiling light.
-The brightness percentage (0-100).
-The red color value (0-255).
-The green color value (0-255).
-The blue color value (0-255).
-Sets the state of the ceiling light.
-The request byte array.
-Turns off the ceiling light.
-Turns on the ceiling light.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoCeilingLight.
-The manufacturer data buffer.
-The function to emit log messages.
-StaticparseParses the service data for WoCeilingLight Pro.
-The manufacturer data buffer.
-The function to emit log messages.
-StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Circulator Fan Device (Battery/USB) +Reuses air purifier fan-speed control and status behavior.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Set fan speed (1-4)
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Climate Panel Device +Reuses climate control behavior for power, mode, and fan-speed style control.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Set fan speed (1-4)
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Class representing a WoContact device.
-Contact Sensor (Door/Window Sensor)
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoContact.
-The service data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoCurtain device.
-Curtain Device - Smart curtain controller
+Closes the curtain.
-Optionalmode: number = 0xFFRunning mode (0x01 = QuietDrift, 0xFF = Default).
-Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Opens the curtain.
-Optionalmode: number = 0xFFRunning mode (0x01 = QuietDrift, 0xFF = Default).
-Sends a command to the curtain.
-The command bytes.
-Pauses the curtain.
-Runs the curtain to the target position.
-The percentage of the target position.
-Optionalmode: number = 0xFFRunning mode (0x01 = QuietDrift, 0xFF = Default).
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoCurtain.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-Optionalreverse: boolean = falseWhether to reverse the position.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Close curtain (position 100%)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get extended device information (Curtain 3) +Returns device chain information and grouped curtain status
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Check if API is available for this device
+Check if BLE is available for this device
+Open curtain (position 0%)
+Pause curtain movement
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3 complex operations
+Send multiple commands (returns true if any succeed) +Used for Curtain 3 fallback operations
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Set curtain position (0-100%)
+Enable or disable retry logic
+Unregister a fallback handler
+Floor Lamp Device +Uses same logic as Color Bulb
+StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Garage Door Opener Device (uses relay switch control) +Extends Relay Switch 1 for simple open/close control
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Toggle power
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Class representing a WoHand device.
-Bot (WoHand) Device - Press or switch button device +Supports optional BLE password protection
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Moves the bot down.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Presses the bot.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Turns off the bot.
-Turns on the bot.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-Moves the bot up.
-StaticparseParses the service data for WoHand.
-The service data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Clear Bot password
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Lower Bot arm
+Raise Bot arm
+Check if API is available for this device
+Check if BLE is available for this device
+Check if password is configured
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Press (press mode)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Set Bot long-press duration (1-255 deciseconds)
+Set or update Bot password
+4-character alphanumeric password (case-sensitive)
+Enable or disable retry logic
+Turn off (switch mode)
+Turn on (switch mode)
+Unregister a fallback handler
+Class representing a WoHub2 device.
-Hub 2 Device (Hub Mini/Hub Plus also use this)
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoHub2.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoHub3 device.
-Hub 3 Device +Uses same logic as Hub 2
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoHub3.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+HubMini Matter Device +Uses same hub logic as Hub 2
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoHumi device.
-Humidifier Device
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Decreases the humidifier setting.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Increases the humidifier setting.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the humidifier level.
-The level to set (0-100).
-Sets the humidifier to auto mode.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Sets the humidifier to manual mode.
-Turns off the humidifier.
-Turns on the humidifier.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoHumi.
-The service data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Get target humidity level (if available)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Set auto mode
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Set nebulization efficiency (0-100)
+Enable or disable fallback
+Set target humidity level (1-100)
+Set manual mode
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Class representing a WoHumi device.
-Humidifier 2 Device +Uses same logic as Humidifier
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Decreases the humidifier setting.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Increases the humidifier setting.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the humidifier level.
-The level to set (0-100).
-Sets the humidifier to auto mode.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Sets the humidifier to manual mode.
-Turns off the humidifier.
-Turns on the humidifier.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoHumi.
-The service data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Get target humidity level (if available)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Set auto mode
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Set nebulization efficiency (0-100)
+Enable or disable fallback
+Set target humidity level (1-100)
+Set manual mode
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Class representing a WoIOSensorTH device.
-Outdoor Meter (Temperature/Humidity Sensor for outdoor use) +Uses same logic as standard Meter
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoIOSensorTH.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoKeypad device.
-Keypad Device (Touch/Physical) +Note: Keypad is primarily for lock control, read-only for status
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoKeypad.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Keypad Vision Device +Uses same logic as Keypad for lock control
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+SwitchBot Keypad Vision Pro device
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get keypad status (inherited from WoKeypad)
+Promise resolving to KeypadStatus
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoLeak device.
-Water Leak Detector Device
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoLeak.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Base class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Pan the camera (degrees: -180 to 180)
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReset the camera position
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Tilt the camera (degrees: -90 to 90)
+Unregister a fallback handler
+Class representing a WoPlugMini device.
-Plug Mini (JP) Device +Uses same logic as US version
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Operates the plug with the given bytes.
-The byte array to send to the plug.
-Reads the state of the plug.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Toggles the state of the plug.
-Turns off the plug.
-Turns on the plug.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoPlugMini JP.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Toggle power
+Turn off
+Turn on
+Unregister a fallback handler
+Class representing a WoPlugMini device.
-Plug Mini (US) Device
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Operates the plug with the given bytes.
-The byte array to send to the plug.
-Reads the state of the plug.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Toggles the state of the plug.
-Turns off the plug.
-Turns on the plug.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoPlugMini US.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Toggle power
+Turn off
+Turn on
+Unregister a fallback handler
+Class representing a WoPresence device.
-Motion/Presence Sensor
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the manufacturer data for presence sensors.
-The optional service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-StaticparseParses the service data for WoPresence.
-The service data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+RGBIC Bulb Device with segmented/multi-zone color control +Supports individual LED segment control for addressable RGB+IC strips
+StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (inherited from WoBulb, centralized fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Set color for individual LED segment
+Segment identifier (0-based index)
+Red value (0-255)
+Green value (0-255)
+Blue value (0-255)
+Set effect for individual LED segment
+Segment identifier (0-based index)
+Effect name from RGBIC_EFFECTS
+Effect speed (1-100, default: 50)
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Base class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Set brightness (1-100)
+Enable or disable circuit breaker
+Set color (RGB)
+Set color temperature (Kelvin)
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off the neon wire rope light
+Turn on the neon wire rope light
+Unregister a fallback handler
+RGBICWW Floor Lamp Device +Uses same logic as RGBIC Bulb with segmented control
+StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (inherited from WoBulb, centralized fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Set color for individual LED segment
+Segment identifier (0-based index)
+Red value (0-255)
+Green value (0-255)
+Blue value (0-255)
+Set effect for individual LED segment
+Segment identifier (0-based index)
+Effect name from RGBIC_EFFECTS
+Effect speed (1-100, default: 50)
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+RGBICWW Strip Light Device +Uses same logic as RGBIC Bulb with segmented control
+StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (inherited from WoBulb, centralized fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Set color for individual LED segment
+Segment identifier (0-based index)
+Red value (0-255)
+Green value (0-255)
+Blue value (0-255)
+Set effect for individual LED segment
+Segment identifier (0-based index)
+Effect name from RGBIC_EFFECTS
+Effect speed (1-100, default: 50)
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Class representing a WoRelaySwitch1 device.
-Relay Switch 1 Device (1-channel)
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Turns off the bot.
-Turns on the bot.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoRelaySwitch1.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Toggle power
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Class representing a WoRelaySwitch1PM device.
-Relay Switch 1PM Device (1-channel with power monitoring) +Uses same logic as Relay Switch 1
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Turns off the bot.
-Turns on the bot.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoRelaySwitch1PM.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Toggle power
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Relay Switch 2PM Device (2-channel with power monitoring) +Extends Relay Switch 1 with channel-specific control
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (inherited, same as 1PM)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Set channel 1 state
+Set channel 2 state
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Toggle power
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Class representing a WoRemote device.
-Remote Device (IR remote control) +Note: Remote is read-only for battery status
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data for WoRemote.
-The service data buffer.
-The function to emit log messages.
-Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Base class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Roller Shade Device +Uses same logic as Curtain (motorized window covering)
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Close curtain (position 100%)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get extended device information (Curtain 3) +Returns device chain information and grouped curtain status
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Check if API is available for this device
+Check if BLE is available for this device
+Open curtain (position 0%)
+Pause curtain movement
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3 complex operations
+Send multiple commands (returns true if any succeed) +Used for Curtain 3 fallback operations
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Set curtain position (0-100%)
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoSensorTH device.
-Meter (Temperature/Humidity Sensor)
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseGet active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoSensorTH device.
-Meter Plus (Temperature/Humidity Sensor with screen) +Uses same logic as standard Meter
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseGet active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoSensorTH device.
-Meter Pro (Advanced Temperature/Humidity Sensor) +Uses same logic as standard Meter
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseGet active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoSensorTH device.
-Meter Pro CO2 (Temperature/Humidity/CO2 Sensor) +Use same logic as standard Meter (CO2 data available in extended status)
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseGet active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Class representing a WoSmartLock device.
-Smart Lock Device
+StaticResultSends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Decrypts a buffer using AES-128-CTR.
-The data to decrypt.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Encrypts a string using AES-128-CTR.
-The string to encrypt.
-Sends an encrypted command to the device.
-The command key.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Retrieves the IV from the device.
-Gets general state info from the Smart Lock.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Locks the Smart Lock.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Operates the lock with the given command.
-The command key.
-Optionalencrypt: boolean = trueWhether to encrypt the command.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Initializes the encryption key info for valid lock communication.
-The key ID.
-The encryption key.
-Unlocks the Smart Lock.
-Unlocks the Smart Lock without unlatching the door.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticgetStaticparseParses the service data from the SwitchBot Strip Light.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-StaticvalidateGet active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Lock the lock
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unlock the lock
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Smart Lock Lite Device
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Lock the lock
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unlock the lock
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Class representing a WoSmartLockPro device.
-Smart Lock Pro Device (with unlatch support)
+StaticResultSends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Decrypts a buffer using AES-128-CTR.
-The data to decrypt.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Encrypts a string using AES-128-CTR.
-The string to encrypt.
-Sends an encrypted command to the device.
-The command key.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Retrieves the IV from the device.
-Gets general state info from the Smart Lock.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Locks the Smart Lock.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Operates the lock with the given command.
-The command key.
-Optionalencrypt: boolean = trueWhether to encrypt the command.
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Initializes the encryption key info for valid lock communication.
-The key ID.
-The encryption key.
-Unlocks the Smart Lock.
-Unlocks the Smart Lock without unlatching the door.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticgetStaticparseParses the service data from the SwitchBot Strip Light.
-The service data buffer.
-The manufacturer data buffer.
-The function to emit log messages.
-StaticvalidateGet active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Lock the lock
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unlatch the lock (Lock Pro only)
+Unlock the lock
+Unlock without unlatching the door
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Smart Lock Pro WiFi Device (with WiFi connectivity and unlatch support)
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Lock the lock
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unlatch the lock (Lock Pro only)
+Unlock the lock
+Unlock without unlatching the door
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Smart Lock Vision Device (with camera)
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Lock the lock
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unlock the lock
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Smart Lock Vision Pro Device (with camera and unlatch support)
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Lock the lock
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unlatch the lock (Lock Pro only)
+Unlock the lock
+Unlock without unlatching the door
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Smart Thermostat Radiator Device +Reuses climate control behavior for power, mode, and speed-level style control.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Set fan speed (1-4)
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Class representing a WoStrip device.
-Strip Light Device +Uses same logic as Color Bulb
+Sends a command to the device and awaits a response.
-The command buffer.
-A Promise that resolves with the response buffer.
-Connects to the device.
-A Promise that resolves when the connection is complete.
-Disconnects from the device.
-A Promise that resolves when the disconnection is complete.
-Discovers the device services.
-A Promise that resolves with the list of services.
-Retrieves the device characteristics.
-A Promise that resolves with the device characteristics.
-Retrieves the device name.
-A Promise that resolves with the device name.
-Internal method to handle the connection process.
-A Promise that resolves when the connection is complete.
-Logs a message with the specified log level.
-The severity level of the log (e.g., 'info', 'warn', 'error').
-The log message to be emitted.
-Operates the strip light with the given byte array.
-The byte array to send.
-Reads the state of the strip light.
-Sets the brightness of the strip light.
-The brightness percentage (0-100).
-Sets the device name.
-The new device name.
-A Promise that resolves when the name is set.
-Sets the RGB values of the strip light.
-The brightness percentage (0-100).
-The red value (0-255).
-The green value (0-255).
-The blue value (0-255).
-Sets the state of the strip light.
-The request byte array.
-Turns the strip light off.
-Turns the strip light on.
-Unsubscribes from the notify characteristic.
-A Promise that resolves when the unsubscription is complete.
-StaticparseParses the service data from the SwitchBot Strip Light.
-The service data buffer.
-The function to emit log messages.
-StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Strip Light 3 Device +Uses same logic as Color Bulb
+StaticEFFECTSPreset effect name to effect ID mapping
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first/API-fallback, centralized)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Strip Light 3 and complex light patterns
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex light patterns
+Set brightness (0-100)
+Enable or disable circuit breaker
+Set RGB color
+Set color temperature with min/max bounds +For advanced bulbs that support color temperature range control
+Set color temperature (2700-6500K)
+Enable or disable connection intelligence
+Set preset light effect
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Turn off
+Turn on
+Unregister a fallback handler
+Verifies the BLE encryption key by attempting a status read with encryption. +Throws an error if the key is invalid or the device rejects the command.
+Vacuum Device
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Robot Vacuum Cleaner K10+
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Robot Vacuum Cleaner K10+ Pro
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Robot Vacuum Cleaner K10+ Pro Combo
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Robot Vacuum Cleaner K11+
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Robot Vacuum Cleaner K20
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Robot Vacuum Cleaner S10
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Robot Vacuum Cleaner S20
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Start cleaning (BLE-first, API-fallback)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Return advertised battery value
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Return advertised dustbin bound state
+Return advertised dustbin connected state
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Return advertised network connected state
+Get device status (BLE-first/API-fallback, centralized)
+Return advertised work status value
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsReturn to dock (BLE-first, API-fallback)
+Send multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Refresh status for this device. Called automatically after sequence changes.
+Update device information and react to sequence number changes.
+Base class for all SwitchBot devices
+This class provides a centralized, robust hybrid connection strategy for all SwitchBot devices:
+preferredConnection and enableFallback.getStatusWithFallback() and sendCommand() methods implement this logic. Device subclasses should call these methods and provide normalization/mapping as needed.await this.getStatusWithFallback(normalizeBLE, normalizeAPI) in your getStatus() implementation.await this.sendCommand(bleCommand, apiCommand, apiParameter) to automatically select the best connection and handle fallback.async getStatus(): Promise<DeviceStatus> {
return this.getStatusWithFallback(
bleData => ({ ... }), // normalize BLE data
apiData => ({ ... }), // normalize API data
)
}
async turnOn(): Promise<boolean> {
const result = await this.sendCommand([0x57, 0x01, 0x01], 'turnOn')
return result.success
}
+
+
+preferredConnection: 'ble' | 'api' (default: 'ble')enableFallback: boolean (default: true)enableConnectionIntelligence: boolean (default: true)enableCircuitBreaker: boolean (default: true)enableRetry: boolean (default: true)getStatusWithFallback()sendCommand()hasBLE(), hasAPI()setPreferredConnection(), setFallbackEnabled()This pattern ensures all device classes benefit from robust, testable, and consistent connection logic.
+Get active connection type (property accessor for convenience)
+Get device type (property accessor for convenience)
+Get device ID (property accessor for convenience)
+Get MAC address (property accessor for convenience)
+Get device name (property accessor for convenience)
+Get active connection type
+Get basic device info (universal settings retrieval) +Returns: battery, firmware, device-specific settings, etc. +Command: 0x57 0x02 (BLE), 'getBasicInfo' (API)
+Example usage: +const info = await device.getBasicInfo(); +console.log(info);
+Returns a CommandResult object with device info fields.
+Get circuit breaker for API
+Get circuit breaker for BLE
+Get connection tracker for this device
+Get device type
+Get fallback handler manager
+Get device ID
+Get device information
+Get MAC address (if available)
+Get device name
+Get device status (BLE-first, API-fallback)
+Check if API is available for this device
+Check if BLE is available for this device
+Poll device status if needed (passive polling)
+Returns true if device should be polled (passive polling interval elapsed)
+Register a custom fallback handler
+Optionaloptions: FallbackHandlerOptionsSend multiple commands in sequence (all must succeed) +Used for Curtain 3, bulbs, strips, and other multi-step devices
+Send multiple commands (returns true if any succeed) +Used for fallback operations with complex patterns
+Enable or disable circuit breaker
+Enable or disable connection intelligence
+Enable or disable fallback
+Universal mode setting command +BLE: 0x57 0x03 [modeByte] +API: 'setMode' (if available)
+Mode value (number or string, per-device enum recommended)
+Example usage: +await device.setMode('auto') +await device.setMode(1)
+Returns a CommandResult object indicating success and mode info.
+Enable or disable retry logic
+Unregister a fallback handler
+Enum for log levels.
-Log levels for debugging and diagnostics
+SwitchBot BLE Model identifiers
+SwitchBot BLE Model Names
+The node-switchbot is a Node.js module that allows you to interact with various SwitchBot devices. You can control your SwitchBot (Bot)'s arm, operate your SwitchBot Curtain, and manage your SwitchBot Lock. Additionally, you can monitor temperature and humidity using the SwitchBot Thermometer & Hygrometer (Meter), and check the status of the SwitchBot Motion Sensor and SwitchBot Contact Sensor.
This module now supports both Bluetooth Low Energy (BLE) and the SwitchBot OpenAPI, providing more flexibility and options for interacting with your devices.
Please note that most of this module was developed by referencing the official BLE API and OpenAPI documentation. However, some functionalities were developed through trial and error, so there might be inaccuracies in the information obtained from this module.
To install the node-switchbot module within your project, use the following command:
To install the node-switchbot module within your project, use the following command:
$ npm install --save node-switchbot
-To see a breakdown of how to use the BLE functionality of this project, visit the BLE (Bluetooth Low Energy) documentation.
-To see a breakdown of how to use the OpenAPI functionality of this project, visit the OpenAPI documentation.
-v4.0.0 introduces a unified hybrid approach that automatically uses BLE when available with seamless API fallback.
+import { SwitchBot } from 'node-switchbot'
const switchbot = new SwitchBot({
token: 'YOUR_TOKEN', // OpenAPI token (optional for BLE-only)
secret: 'YOUR_SECRET', // OpenAPI secret (optional for BLE-only)
enableBLE: true, // Enable BLE discovery (Linux/macOS)
enableFallback: true, // Auto-fallback between BLE/API
})
// Discover all devices (BLE + API)
const devices = await switchbot.discover()
// Control devices
const bot = switchbot.devices.get('YOUR_DEVICE_ID')
await bot.press()
// Get status
const status = await bot.getStatus()
console.log(status)
// Cleanup
await switchbot.cleanup()
+
+
+// Bot - Press/Switch control
await bot.turnOn()
await bot.turnOff()
await bot.press()
// Bot with Password Protection (BLE only)
const protectedBot = new WoHand({ id: 'YOUR_BOT_ID', password: 'A1b2' })
await protectedBot.setPassword('A1b2') // Set 4-char alphanumeric password
await protectedBot.press() // Commands are automatically encrypted
await protectedBot.clearPassword() // Remove password protection
// Curtain - Position control
await curtain.open()
await curtain.close()
await curtain.setPosition(50) // 50% open
// Lock - Lock/Unlock
await lock.lock()
await lock.unlock()
// Bulb - Color and brightness
await bulb.turnOn()
await bulb.setBrightness(80)
await bulb.setColor(255, 0, 0) // Red
// Meter - Read sensors
const meterStatus = await meter.getStatus()
console.log(meterStatus.temperature, meterStatus.humidity)
+
+
+See the examples directory for more usage patterns.
+To see a breakdown of how to use the BLE functionality of this project, visit the BLE (Bluetooth Low Energy) documentation.
+To see a breakdown of how to use the OpenAPI functionality of this project, visit the OpenAPI documentation.
+Breaking Changes in v4.0.0:
+SwitchBot class replaces separate SwitchBotBLE and SwitchBotOpenAPI classesswitchbot.devices.get(id) instead of direct discovery resultsMigration Example:
+// v3.x (old)
import { SwitchBotBLE, SwitchBotOpenAPI } from 'node-switchbot'
const ble = new SwitchBotBLE()
const api = new SwitchBotOpenAPI(token, secret)
// v4.0.0 (new)
import { SwitchBot } from 'node-switchbot'
const switchbot = new SwitchBot({ token, secret, enableBLE: true })
+
+
+
Error thrown when API request fails
+