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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-mihome

v0.0.32

Published

Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more

Downloads

596

Readme

Mi Home Devices Library

Control Mi Home devices via local network or cloud.

Supported devices

See DEVICES.md for full list of supported devices.

Installation

npm install node-mihome

Usage

const mihome = require('node-mihome');

Some devices aren't supported over local protocol (miIO) so you need to use cloud protocol (MIoT) to control those devices. User and password for Mi Account is required to use cloud protocol.

Init protocols

// local miIO
mihome.miioProtocol.init();

// local Aqara (ZigBee)
mihome.aqaraProtocol.init();

// cloud MIoT
const username = '[email protected]';
const password = 'password';
await mihome.miCloudProtocol.login(username, password);

Example cloud methods

const options = { country: 'cn' }; // 'ru', 'us', 'tw', 'sg', 'cn', 'de' (Default: 'cn')
await mihome.miCloudProtocol.getDevices(null, options); // return all devices from your acount with all information (deviceId, token, model ...) to create device in the next step
await mihome.miCloudProtocol.getDevices([deviceId1, deviceId2, ...], options); // get devices information from list ids
await mihome.miCloudProtocol.miioCall(deviceId, method, params, options); // call miio method with params via cloud protocol

Create device

const device = mihome.device({
  id: '100000', // required, device id
  model: 'zhimi.aircondition.v1', // required, device model

  address: '192.168.31.13', // miio-device option, local ip address
  token: 'abcdefgfabcdefgfabcdefgfabcdefgf', // miio-device option, device token
  refresh: 30000 // miio-device option, device properties refresh interval in ms
  
  parent: '1234abcd', // aqara-device option, gateway SID for aqara-protocol compatible device
});
device.on('properties', (data) => {
  console.log(data);
});
await device.setPower(true); // call the method
await device.init(); // connect to device and poll for properties
device.destroy();

List of properties and methods for specific device can be found at ./devices folder.

Comparison to other popular libraries

| | node-mihome | miio | | :--- |:----: | :-----:| | Implements miIO local protocol | yes | yes | | Implements MIoT cloud protocol: easy device token retrieval, many useful device information, control devices over internet, control devices which cannot be controlled from LAN, supports new devices e.g. Mi Air Purifier 3, etc. | yes | no | | Implements Aqara protocol (for ZigBee devices) | full | only read properties | | Number of supported devices, including new ones | large and counting | medium | | Library update frequency | medium | a long time since last update |

Roadmap

Reporting an issue and new devices support requests

Please report all issues you have found. Also, feel free to request support for new devices. Thanks!

Buy me a coffee

BTC: 1E9k2s3swbTwPRgHqjNHmxkWF8hf7uN2sc

ETH: 0x25b744eeb2a979f39e8375c8c9fac6db750438b1

Paypal: https://paypal.me/maxinminax