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.
The
SwitchBotOpenAPIclass provides methods to interact with the SwitchBot OpenAPI. It allows you to retrieve device information, control devices, and manage webhooks.Example
Param: token
The API token used for authentication.
Param: secret
The secret key used for signing requests.