npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

thsq-simulator

v1.0.1

Published

Javascript simulator for Thingsquare IoT mesh networks

Readme

Thingsquare device simulator

The thsq-simulator is a simulator for Thingsquare devices. This simulator can run on any desktop machine, which makes it easier to work with than the actual hardware.

The purpose of the simulator is to make backend integration and algorithm development easier.

Requirements

NodeJS and npm.

Installation

npm install --save thsq-simulator

Create a first simulator

Here's a full implementation of a simple simulator. This implementation can be modified to alter the behavior of the simulated devices. Save this content to simulator.js.

var thsqsim = require('thsq-simulator');
var getopts = require('getopts');
require('console-stamp')(console, { pattern : 'HH:MM:ss.l' });

function usage() {
    console.info('usage: node simulator.js -u <token> -d <num devices> -n <num networks>');
    console.info('<token> is an API token that can be retrieved from https://developer.thingsquare.com/web/, under the User tab, by checking the "Enable API access" checkbox');
    console.info('<num devices> is the number of simulated devices to spin up');
    console.info('optional: -f <frontend> -b <backend>');
    process.exit(1);
}

var options = getopts(process.argv.slice(2), {
    alias: {
        user: 'u',
        frontend: 'f',
        backend: 'b',
        networks: 'n',
        devices: 'd',
        platform: 'p',
        applatform: 'a',
        filename: 'F'
    },
    default: {
        frontend: 'b72af87d-42d7-4f09-bf8c-b9f721a3e6ef',
        backend: 'developer.thingsquare.com',
        networks: 1,
        devices: 10,
        proptime: 100,
        period: 3600 * 10,
    }
});

if (!options.user || !options.devices) {
    usage();
    return;
}

thsqsim.on('boot', function (device) {
});

thsqsim.on('variable', function (device, key, val, oldval) {
});

thsqsim.on('command', function (device, command, data) {
});


thsqsim.init({
    token: options.user,
    frontend: options.frontend,
    backend: options.backend,
    platform: options.platform,
    applatform: options.applatform,
    devices: options.devices,
    period: options.period,
    proptime: options.proptime,
    networks: options.networks,
    deadleaf: options.deadleaf,
    statefilename: options.filename }, function () {
        console.log('started');
});

Running the simulator

First grab an API key.

Go to https://developer.thingsquare.com/web/ and log in.

The API key can be found under the User tab (make sure to enable API access first).

Then run:

node thsq-simulator.js -u <API token from above> -n <number of simulated devices>

This will produce output similar to this:

$ node simulator.js -u <the API token> -n 10
[18:00:00.726] [LOG]    Creating device 0 / 11
[18:00:01.760] [LOG]    Creating device 1 / 11
[18:00:02.914] [LOG]    Creating device 2 / 11
[18:00:04.078] [LOG]    Creating device 3 / 11
[18:00:05.384] [LOG]    Creating device 4 / 11
[18:00:06.397] [LOG]    Creating device 5 / 11
[18:00:07.637] [LOG]    Creating device 6 / 11
[18:00:08.197] [LOG]    Creating device 7 / 11
[18:00:08.581] [LOG]    Creating device 8 / 11
[18:00:08.948] [LOG]    Creating device 9 / 11
[18:00:10.082] [LOG]    Creating device 10 / 11
[18:00:10.901] [LOG]    Creating device 11 / 11
[18:00:10.902] [LOG]    All simulated devices started

The simulated devices will then show up in https://developer.thingsquare.com/web/.

Customizing the simulator

By default simulated devices post a randomized value to the server variable t. To override what the device post, pass a periodiccallback parameters to the thsqsim.init function. Here's a full example of how to instead set and push a myvariable server variable.

function pushmyvariable(device) {
    device.pushVariable('s', 'myvariable', 'myvalue');
    device.sendStats();
}

thsqsim.init({
    ...
    periodiccallback: pushmyvariable,
    ...
});