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

ubnt-mfi

v0.0.1

Published

Node.js library for communicating with a Ubiquiti mFi controller

Downloads

8

Readme

Install

npm install ubnt-mfi

Example

const mFi = require('ubnt-mfi')

var controller = new mFi({
  host    : '192.168.1.7',
  username: 'nodejs',
  password: 'password'
})
controller.listSensors().then(function(sensors){
  console.dir(sensors)
}, function(e){
  console.log("Failed:",e)
})

API

INSTANTIATION
var controller = new mFi({
  //REQUIRED:
  host    : //string: hostname or IP
  username: //string: admin username
  password: //string: admin password
  //OPTIONAL:
  protocol: //string : https (default) or http
  port    : //integer: default is 6443
})
FUNCTIONS

Calling a function will return a promise. If the promise is successful, the data returned by mFi will be converted to an object literal with some basic type fixes (date values will become date objects).

controller.listSensors().then(/* promise functions go here! */)

If the promise fails, either 'not authorized' or 'unrecoverable error' will be returned, the former indicating an authentication failure and the latter serving to generalize all other manner of failures including host not found, address unavailable, connection refused, etc.

Please understand this library is based on an undocumented API. We've implemented some discovered functions, but haven't yet taken time to detail their arguments or reply values.

Background

We prefer insteon for home automation, which is oriented towards enthusiast developers and offers a rich ecosystem of devices. There is a lot of exciting stuff happening in the automation/IoT market and we look forward to seeing what the thread group brings out. We needed a way to integrate an mFi temperature sensor with existing automation logic, which was the impetus for creating this library.

WHAT

mFi is ubiquiti's machine-to-machine control and automation system. With mFi, you can control power outlets, relays, and serial devices while collecting data from various sensors including temperature, motion, electrical current, and contact sensors (door/window).

This is a nodejs library for polling data from an mFi controller. mFi devices need to be connected to (and configured in) an mFi controller; this library will communicate with the mFi controller and expose the data collected from the devices connected to it so that you can use that data in your own nodejs application.

WHY

This is a bit of a po-TAY-to / po-TAH-to question. There are two ways to look at how to integrate mFi with other automation equipment. mFi is great by itself and can be used as the master controller capable of leveraging custom sensors as well as URL actions. Both of these features help mFi expand the automation realm beyond the devices and systems offered by ubiquiti.

But we preferred a different design where an independent master controller collects data from mFi as if it were just another network element. With this approach, we don't have to write action triggers in mFi and can consolidate control logic on a separate system.

HOW

How indeed. Ubiquiti has a lot of interesting things going on with their unifi line, but they haven't put a lot of effort into advancing the mFi product line. There is an API exposed through the mFi controller, but it's not published and not supported by ubiquiti. We've reverse-engineered portions of that API by watching network traffic through chrome browser while navigating an mFi controller.

LICENSE

LGPLv3