TuyaStub
A stub implementation of the
Tuya protocol for local testing.
Parameters
Name |
Description |
options.state Object
(default {} )
|
inital state of device
|
options.id String
|
ID of mock device
|
options.key String
|
key of mock device
|
options.ip String
(default localhost )
|
IP address of mock device
|
options.respondToHeartbeat Boolean
(default true )
|
sends pong if true in response to pings
|
Example
const stub = new TuyaStub({ id: 'xxxxxxxxxxxxxxxxxxxx',
key: 'xxxxxxxxxxxxxxxx',
state: {'1': false, '2': true}});
Instance Members
Starts the mocking server.
Parameters
port (Number
= 6668
)
port to listen on
Call to cleanly exit.
shutdown()
â–¸
startUDPBroadcast(options)
Starts the periodic UDP broadcast.
startUDPBroadcast(options:
Object)
Parameters
Name |
Description |
options.port Number
(default 6666 )
|
port to broadcast on
|
options.interval Number
(default 5 )
|
interval, in seconds, to broadcast at
|
â–¸
setProperty(property, value)
Sets a property of the mock device.
setProperty(property:
String, value: any): any
Parameters
Returns
any
:
updated property value
â–¸
getProperty(property)
Gets a property of the mock device.
getProperty(property:
String): any
Parameters
Returns
any
:
property value
Gets entire state of the mock device.
Returns
Object
:
device's state
Sets entire state of the mock device.
Parameters
Returns
Object
:
updated state