Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const debug = require('debug')('TuyaStub');
* @param {Object} options
* @param {String} options.id ID of mock device
* @param {String} options.key key of mock device
* @param {String} [options.ip=localhost] IP address of mock device
* @param {Object} options.state inital state of device
* @example
* const stub = new TuyaStub({ id: 'xxxxxxxxxxxxxxxxxxxx',
Expand All @@ -22,6 +23,7 @@ class TuyaStub {

this.id = options.id;
this.key = options.key;
this.ip = options.ip ? options.ip : 'localhost';

this.parser = new MessageParser({key: this.key, version: 3.1});
}
Expand Down Expand Up @@ -73,7 +75,7 @@ class TuyaStub {
options.interval = options.interval ? options.interval : 5;

// Encode broadcast
const message = this.parser.encode({data: {devId: this.id, gwId: this.id, ip: 'localhost'}, commandByte: CommandType.DP_QUERY});
const message = this.parser.encode({data: {devId: this.id, gwId: this.id, ip: this.ip}, commandByte: CommandType.DP_QUERY});

// Create and bind socket
this.broadcastSocket = dgram.createSocket({type: 'udp4', reuseAddr: true});
Expand Down