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

miflora

v1.0.6

Published

Node.js package for the Xiaomi Plant Sensor Flower Care (Mi Flora)

Downloads

60

Readme

miflora

Node.js package for the Xiaomi Mi Flora Plant Sensor built on top of noble (maintained by abandonware).

npm language XO code style commit firmware licence

Have a look in the Wiki for more information on the sensor.


Prerequisites

Please see the Prerequisites section for noble.

Install

npm install miflora

Usage

The library uses async/await code syntax instead of Promises chaining in order to execute asynchronous code sequentially. Since all internal code is based on Promises you still can use the method().then().catch()-pattern regardless.

All examples use async/await syntax.

Discover devices

const devices = await miflora.discover();
console.log('devices discovered: ', devices.length);

In this example we listen for 10000 (default value) milliseconds (10 seconds) and print out the number of detected devices.

Discover devices (advanced)

const opts = {
  duration: 60000,
  ignoreUnknown: true,
  addresses: ['c4:7c:8d:65:d6:1d', 'c4:7c:8d:65:d5:26', 'c4:7c:8d:65:e6:20']
};
const devices = await miflora.discover(opts);
console.log('devices discovered: ', devices.length);

This time we listen for 60000 milliseconds (60 seconds) or until all devices from given opts.addresses have been discovered and print out the number of detected devices. If opt.ignoreUnknown is true, devices which are not in opt.addresses will be ignored in result.

Query device information

All query methods implicitly initiate a connection if none exists. You can call device.connect() explicitly if you like nevertheless.

The library however doesn't perform a disconnect implicitly. You can call device.disconnect() when you have finished you queries or let you disconnect automatically from the device after 10 seconds.

Firmaware & Battery

const data = await device.queryFirmwareInfo();
console.log(data);

Example output:

{ address: 'c4:7c:8d:65:e6:20',
  type: 'MiFloraMonitor',
  firmwareInfo: { battery: 100, firmware: '3.1.9' } }

Sensor values

const data = await device.querySensorValues();
console.log(data);

Example output:

{ address: 'c4:7c:8d:65:e6:20',
  type: 'MiFloraMonitor',
  sensorValues: { temperature: 21.1, lux: 104, moisture: 36, fertility: 1049 } }

Serial Number

const data = await device.querySerial();
console.log(data);

Combined query

const data = await device.query();
console.log(data);

Debugging

The library uses Debug with the logger names miflora and miflora:device. You can start your script with prefixing DEBUG=miflora* to see all debug output.

DEBUG=miflora* node yourapp.js

References

  • https://github.com/demirhanaydin/node-mi-flora
  • https://wiki.hackerspace.pl/projects:xiaomi-flora

Licence

MIT