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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dyson-node

v0.2.3

Published

Hook in to the dyson link api

Readme

dyson-node

npm version Node.js Package

A library for connecting to dyson fans

Installation

npm install --save dyson-node

Usage

To use the dyson node package you will need to first have a dyson link account. For an account you can sign up here or signup through the dyson link application for Google Play and Apple App Store.

Account

Before you can control the devices you will need to first sign in to your account so that you can access your devices.

const { DysonAccount } = require('dyson-node');

const account = new DysonAccount(process.env.DYSON_EMAIL,process.env.DYSON_PASSWORD);

account.login().then(() => {
  account.getDevices().then(async devices => {
      console.log(devices);
  }).catch(err => console.error(err));
}).catch(err => console.error(err));

This can also be done using async/await instead of traditional promises.

async function asyncStart(){
  const account = new DysonAccount(process.env.DYSON_EMAIL,process.env.DYSON_PASSWORD);
  await account.login();
  const devices = await account.getDevices();
  console.log(devices);
}

asyncStart();

Device

Once you have a list of devices you will be able to create a device object and start controlling the device.

const { DysonAccount, DysonDevice } = require('dyson-node');

// ...
const devices = await account.getDevices();
const device = new DysonDevice(devices[0]);
// ...

To get notified when the device or environment updates you can pass in callbacks that will get called when this information is updated.

function fanStateCallback(data) {
    console.log('Fan state', data);
}

function environmentCallback(data){ 
    console.log('Environment state', data);
}

const device = new DysonDevice(devices[0], fanStateCallback, environmentCallback);

There are two methods of connecting the device autoConnect and connectManually. autoConnect uses mdsn to search the devices network for the local record for the serial number of the device. After you have connected to the device you can use the device methods to control it.

device.autoConnect()


Connect to the device automaticly using mdsn.

device.connectManually(name: string, deviceIP: string)


Connect to the device using a manual known IP address.

device.requestCurrentData()


Make a request for the current data. This will send a MQTT message to the device requesting the fan state and environment state. To get the state values you will need to pass in a callback to the constructor of the device (mentioned above).

device.setFanSpeed(speed: number)


Set the fan speed percentage. Minimum value 0. Maximum value 100.

device.setAuto()


Set the device to Auto mode. If it is alrready on auto mode it will toggle it off.

device.setHeatMode(force: boolean?)


Turn the heat mode on. If the heat mode is already on then it will be toggled off. If you pass in the force flag then heat mode will be set on regardless of what state the current heat mode is.

device.setFanOff()


Turn the fan off.

device.setFanOn()


Turn the fan on.

device.setFanFocused()


Set the fan to focused mode. If the fan is already in focused mode then this will toggle off.

device.setNightMode()


Set the fan to night mode. If the fan is already in night mode then this will toggle off.

device.setRotate()


Set the fan to rotate. If the fan is already rotating then this will toggle off. Currently there is not a way to pass in the angle to rotate.

device.setHeatThreshold(celcius: number)


Set the heat threshold for the device. This will also turn on heat mode.

Example code

const { DysonAccount, DysonDevice } = require('dyson-node');

const account = new DysonAccount(process.env.DYSON_EMAIL,process.env.DYSON_PASSWORD);

account.login().then(() => {
    account.getDevices().then(async devices => {
        const device = new DysonDevice(devices[0]);
        await device.autoConnect();
        // If on heat mode then turn off heat mode
        if(device.fanState._heat){
            device.setHeatMode();
        }
        // Set fan speed to 50%
        device.setFanSpeed(50);
    }).catch(err => console.error(err));
}).catch(err => console.error(err));

Current supported decvices

  • HP04

Note: Although this should work for most 2018 dyson fans it has not been tested. Feel free to make a PR to add support for another device.

Credits

As there is no offical documentation on the dyson API the following repositories helped in understanding and setting up how it works