Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including tplink-smarthome-simulator with all npm packages installed. Try it out:

var tplinkSmarthomeSimulator = require("tplink-smarthome-simulator")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

tplink-smarthome-simulator v2.0.0

TP-Link Smarthome Device Simulator

tplink-smarthome-simulator

NPM Version Build Status codecov

Kasa Screenshot

TP-Link Smart Home Device Simulator

I created this so I could automate my tests for tplink-smarthome-api.

See more examples.

debug is used for output. To see all messages set the DEBUG environment variable. To see everything:

DEBUG=* node examples/multi-device.js

To see most:

DEBUG=*,-device:udp,*:error node examples/multi-device.js
'use strict';

const Device = require('..').Device;
const UdpServer = require('..').UdpServer;

let devices = [];

// If you setup virtual interfaces or aliases you can have unique ips to work with Kasa app.
// On a mac you can run `sudo ifconfig en0 alias 10.0.0.200`
devices.push(
  new Device({
    port: 9999,
    address: '10.0.0.200',
    model: 'hs100',
    data: { alias: 'Mock HS100', mac: '50:c7:bf:8f:58:18', deviceId: 'A100' },
  })
);
devices.push(
  new Device({
    port: 9999,
    address: '10.0.0.201',
    model: 'hs105',
    data: { alias: 'Mock HS105', mac: '50:c7:bf:d8:bf:d4', deviceId: 'A105' },
  })
);
devices.push(
  new Device({
    port: 9999,
    address: '10.0.0.202',
    model: 'hs110',
    data: { alias: 'Mock HS110', mac: '50:c7:bf:0d:91:8c', deviceId: 'A110' },
  })
);
devices.push(
  new Device({
    port: 9999,
    address: '10.0.0.203',
    model: 'hs200',
    data: { alias: 'Mock HS200', mac: '50:c7:bf:46:b4:24', deviceId: 'A200' },
  })
);
devices.push(
  new Device({
    port: 9999,
    address: '10.0.0.204',
    model: 'lb100',
    data: { alias: 'Mock LB100', mac: '50:c7:bf:49:ca:42', deviceId: 'BB100' },
  })
);
devices.push(
  new Device({
    port: 9999,
    address: '10.0.0.205',
    model: 'lb120',
    data: { alias: 'Mock LB120', mac: '50:c7:bf:90:9b:da', deviceId: 'BB120' },
  })
);
devices.push(
  new Device({
    port: 9999,
    address: '10.0.0.206',
    model: 'lb130',
    data: { alias: 'Mock LB130', mac: '50:c7:bf:b1:04:d3', deviceId: 'BB130' },
  })
);

devices.forEach((d) => {
  d.start();
});

UdpServer.start();
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free