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

pimatic-mpower

v0.8.3

Published

A pimatic plugin for controlling Ubiquiti mFi controllable power outlets (mPower)

Downloads

4

Readme

pimatic-mpower

Pimatic plugin to control Ubiquiti MPower outlets.

For using this plugin it is not needed to have the mFi Controller Software running on a separate server, since the plugin directly communicates with the mPower outlet. For obtaining the IP address of the mPower outlet, you can use the "Ubiquiti Device Discovery Tool" which can be downloaded from https://www.ubnt.com/download/utilities/. To adjust the username, password and other configuration options of the mPower outlet you can login to the web-based administration interface by using the default login credentials ubnt/ubnt.

Plugin configuration

{
    "plugin": "mpower"
}

The plugin has the following configuration properties:

| Property | Default | Type | Description | |:------------------|:---------|:--------|:--------------------------------------------| | username | ubnt | String | The username for login | | password | ubnt | String | The password for login | | intervall | 5000 | Number | The update intervall in milliseconds |

Note that Currently it is not supported to use multiple mPower outlets that have different username/passwords.

Device configuration

{
    "id": "mpower-device",
    "name": "mPower",
    "class": "MPowerSwitch",
    "host": "192.168.x.y",
    "ports": [1]
},

Each of the ports of an mPower outlet must be individually configured by using the MPowerSwitch device class. The configuration options are as follows:

| Property | Default | Type | Description | |:---------------------|:---------|:--------|:----------------------------------------------------------------------------------------------------| | host | - | String | Hostname or IP address of the mPower outlet | | ports | [] | Array | The ports of the mPower outlet to use for the device. Empty array for all ports. | | hideSwitch | false | Boolean | If the switch should be hidden in the GUI | | additionalAttributes | [] | Array | The additional attributes that should also be collected. See the next section for more information. |

Remember that the port numbers of the mPower outlet start at 1. So the values in the ports configuration array are exactly what is printed beneath the ports on the mPower outlet. Further, if multiple ports are configured for a single device, the power in Watts is summed up and the state of the device is on iff all ports of the device are turned on, otherwise the state is off.

Additional Attributes

Beside the on/off-state and the power in Watts there are the following additional attributes that can be collected and displayed by using the additionalAttributes configuration option. Note that these additional attributes can only be used when the device is configured for a single port of the mPower outlet:

| Name of the property | Physical Unit | |:---------------------|:--------------| | current | Ampere | | voltage | Volt | | powerfactor | - | | energy | - |

For example a device configuration that uses these attributes can look as follows:

{
    "id": "mpower-device",
    "name": "mPower",
    "class": "MPowerSwitch",
    "host": "192.168.x.y",
    "ports": [1],
    "additionalAttributes": [
        "current",
        "voltage"
    ]
},

web-GUI customization

Especially when some additional attributes are enabled you might want to customize the web-GUI such that some of the additional attributes are hidden. For this you can use the xAttributeOptions in the device configuration options as follows:

{
    "id": "mpower-device",
    "name": "mPower",
    "class": "MPowerSwitch",
    "host": "192.168.x.y",
    "ports": [1],
    "additionalAttributes": [
        "current",
        "voltage",
        "powerfactor",
        "energy"
    ],
    "xAttributeOptions": [
        {
            "name": "state",
            "hidden": true
        },
        {
            "name": "current",
            "hidden": true
        },
        {
            "name": "voltage",
            "hidden": true
        },
        {
            "name": "powerfactor",
            "hidden": true
        },
        {
            "name": "energy",
            "hidden": true
        }
    ]
},

Further information

This plugin uses the more sophisticated WebSocket API of the mPower devices instead of the published HTTP API from here. The WebSocket API is not documented but is easier to implement and switching the state of a port by using WebSockets is much faster than by using the HTTP API. Hence, it is not guaranteed that this plugin works with future firmwares of the mPower devices since the WebSockets API may change at any time.

Version History

Version 0.8.X

  • Add possibility to use multiple ports for a single device.
  • Disable additional attributes per default, use the additionalAttributes configuration option to enable these attributes.
  • Automatic reconnect when WebSockets disconnects

Version 0.8.2

  • Update peer dependencies

Version 0.8.0

  • Initial Release