SwitchBotHandler

SwitchBotHandler

SwitchBot clientクラス SwitchBotのWebAPIを利用して状態取得や状態変更を実施する。 ユーザのTokenとSecretKeyが必要で、取得方法は公式に書いてあります。公式のドキュメントはこのモジュールのReadmeに参照先がかいてあります。

Constructor

new SwitchBotHandler(token, secret)

コンストラクタ
Source:
Parameters:
Name Type Description
token string switch bot token
secret string switch bot secret

Methods

getDevices(callback)

デバイスリストを取得する。デバイスリストを取得したらcallback関数を呼ぶ。
Source:
Parameters:
Name Type Description
callback function user function

getDevices(callback)

デバイスリストを取得する。デバイスリストを取得したらcallback関数を呼ぶ。
Source:
Parameters:
Name Type Description
callback function user function

(async) getDevicesSync() → {string}

デバイスリストを同期的に取得する。デバイスリストを取得したらreturnする。getDevicesのほうがパフォーマンスに優れる。
Source:
Returns:
Type:
string

(async) getDevicesSync() → {string}

デバイスリストを同期的に取得する。デバイスリストを取得したらreturnする。getDevicesのほうがパフォーマンスに優れる。
Source:
Returns:
Type:
string

getDeviceStatus(callback)

デバイスの状態取得
Source:
Parameters:
Name Type Description
callback function user function

getDeviceStatus(callback)

デバイスの状態取得
Source:
Parameters:
Name Type Description
callback function user function

(async) getDeviceStatusSync(deviceId) → {string}

デバイスの状態取得
Source:
Parameters:
Name Type Description
deviceId string deviceId
Returns:
Type:
string

(async) getDeviceStatusSync(deviceId) → {string}

デバイスの状態取得
Source:
Parameters:
Name Type Description
deviceId string deviceId
Returns:
Type:
string

getRequest(path, callback)

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
callback function
Throws:
error

getRequest(path, callback)

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
callback function
Throws:
error

getRequestHeaders() → {Headers}

内部関数:通信用HTTPヘッダ生成
Source:
Returns:
Type:
Headers
request headers for switch bot

getRequestHeaders() → {Headers}

内部関数:通信用HTTPヘッダ生成
Source:
Returns:
Type:
Headers
request headers for switch bot

(async) getRequestSync(path) → {string}

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
Returns:
Type:
string

(async) getRequestSync(path) → {string}

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
Returns:
Type:
string

postRequest(path, body, callback)

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
callback function
Throws:
error

postRequest(path, body, callback)

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
callback function
Throws:
error

(async) postRequestSync(path, body) → {string}

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
Returns:
Type:
string

(async) postRequestSync(path, body) → {string}

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
Returns:
Type:
string

setDeviceStatus(deviceId, _command, _params, callback)

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
callback function

setDeviceStatus(deviceId, _command, _params, callback)

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
callback function

(async) setDeviceStatusSync(deviceId, _command, _params) → {string}

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
Returns:
Type:
string

(async) setDeviceStatusSync(deviceId, _command, _params) → {string}

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
Returns:
Type:
string

SwitchBotHandler

SwitchBot clientクラス SwitchBotのWebAPIを利用して状態取得や状態変更を実施する。 ユーザのTokenとSecretKeyが必要で、取得方法は公式に書いてあります。公式のドキュメントはこのモジュールのReadmeに参照先がかいてあります。

Constructor

new SwitchBotHandler(token, secret)

コンストラクタ
Source:
Parameters:
Name Type Description
token string switch bot token
secret string switch bot secret

Methods

getDevices(callback)

デバイスリストを取得する。デバイスリストを取得したらcallback関数を呼ぶ。
Source:
Parameters:
Name Type Description
callback function user function

getDevices(callback)

デバイスリストを取得する。デバイスリストを取得したらcallback関数を呼ぶ。
Source:
Parameters:
Name Type Description
callback function user function

(async) getDevicesSync() → {string}

デバイスリストを同期的に取得する。デバイスリストを取得したらreturnする。getDevicesのほうがパフォーマンスに優れる。
Source:
Returns:
Type:
string

(async) getDevicesSync() → {string}

デバイスリストを同期的に取得する。デバイスリストを取得したらreturnする。getDevicesのほうがパフォーマンスに優れる。
Source:
Returns:
Type:
string

getDeviceStatus(callback)

デバイスの状態取得
Source:
Parameters:
Name Type Description
callback function user function

getDeviceStatus(callback)

デバイスの状態取得
Source:
Parameters:
Name Type Description
callback function user function

(async) getDeviceStatusSync(deviceId) → {string}

デバイスの状態取得
Source:
Parameters:
Name Type Description
deviceId string deviceId
Returns:
Type:
string

(async) getDeviceStatusSync(deviceId) → {string}

デバイスの状態取得
Source:
Parameters:
Name Type Description
deviceId string deviceId
Returns:
Type:
string

getRequest(path, callback)

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
callback function
Throws:
error

getRequest(path, callback)

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
callback function
Throws:
error

getRequestHeaders() → {Headers}

内部関数:通信用HTTPヘッダ生成
Source:
Returns:
Type:
Headers
request headers for switch bot

getRequestHeaders() → {Headers}

内部関数:通信用HTTPヘッダ生成
Source:
Returns:
Type:
Headers
request headers for switch bot

(async) getRequestSync(path) → {string}

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
Returns:
Type:
string

(async) getRequestSync(path) → {string}

内部関数:情報取得
Source:
Parameters:
Name Type Description
path string
Returns:
Type:
string

postRequest(path, body, callback)

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
callback function
Throws:
error

postRequest(path, body, callback)

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
callback function
Throws:
error

(async) postRequestSync(path, body) → {string}

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
Returns:
Type:
string

(async) postRequestSync(path, body) → {string}

内部関数:情報書き込み
Source:
Parameters:
Name Type Description
path string
body string
Returns:
Type:
string

setDeviceStatus(deviceId, _command, _params, callback)

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
callback function

setDeviceStatus(deviceId, _command, _params, callback)

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
callback function

(async) setDeviceStatusSync(deviceId, _command, _params) → {string}

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
Returns:
Type:
string

(async) setDeviceStatusSync(deviceId, _command, _params) → {string}

デバイスの状態変更
Source:
Parameters:
Name Type Description
deviceId string
_command string
_params string
Returns:
Type:
string