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-red-contrib-hubitat

v1.9.0

Published

Node Red module for Hubitat API

Downloads

101

Readme

node-red-contrib-hubitat

This collection of nodes allows to facilitate the use of Hubitat's API

hubitat-nodes

Installation

Requirements

  • Node-RED version >= 1.X.X

  • Hubitat with Maker API version >= 2.2.0.122

  • A dedicated Maker API instance with the following option enabled (for mode and location nodes):

    hubitat-maker-api-options

  • Information from the Make API application (app ID, token) (see Maker API documentation to find them)

From interface

Install node-red-contrib-hubitat from the

  • Menu -> Manage palette -> Install -> Search for hubitat -> Install it

    menu install

From command line

cd ~/.node-red
npm install node-red-contrib-hubitat

Nodes

  • command: To send command to Hubitat

  • device: To keep a device state. It fetch the device state when deployed, then listen for webhook events.

  • hsm: To keep the Hubitat Safety Monitor status (Armed Home, Armed Away, Armed Night and Disarmed). It fetch the status when deployed, then listen for webhook events.

  • hsm-setter: To set the Hubitat Hubitat Safety Monitor status (Disarmed, Armed Away, Armed Home ...)

  • mode: To keep the Hubitat mode (Day, Night, ...) state. It fetch the mode when deployed, then listen for

  • mode-setter: To set the Hubitat mode (Day, Night, ...)

  • location: To receive global location events (ex: systemStart, sunrise, sunset)

  • event: A generic node to receive all events.

  • request: A generic node to request any Hubitat's endpoints.

  • config: To setup Hubitat connection information. It also listen for webhook from Hubitat to dispatch events to other nodes.

Note: config node is a configuration node type, which means that it cannot be used directly, but used by other nodes.

Documentation

The documentation is embedded in the plugin. Once installed, consult the Help section in Node-RED interface and Examples section in Menu -> Import

Moreover, a lot of help can be found at the hubitat community forum

You can increase console log verbosity by changing log level from info to debug. See Node-RED documentation

Technical details

Configure webhook button

This button only setup the endpoint where to send Hubitat's events. It doesn't verify that events will be received by Node-RED. It's mandatory to make basic test flow after the configuration to be sure to receive webhook events.

Since there is no generic command to trigger a webhook event, no automatic configuration can be done.

Global device cache

When config node is deployed (including associated to a new node), it will fetch all devices attributes/states with Maker API. Then each device will be updated by events received on the webhook endpoint configured (default: /hubitat/webhook)

It means that if Node-RED doesn't receive events (lost on the network) then the cache will be out of sync. There are two ways to force refresh the internal cache.

  • Restart flows via NR interface (or deploy an hubitat node associated to the config)

    restart-flows

  • send a systemStart message (i.e. simulate restart of Hubitat hub)

    simulate-systemstart-schema

    simulate-systemstart-inject

    simulate-systemstart-request

Hardcoded dataType

Hubitat API doesn't return the same kind of object when using REST API vs events. Since this plugin is initialized with REST API and updated with events, it needs to shim the difference to allow the user to use the same flow with both values.

  • REST API will return values as object according the dataType
  • event will return values as string

Example

  • GET /apps/api/1/devices/1

    ...
    {
      "name":"temperature",
      "currentValue":20.47,
      "dataType":"NUMBER"
    }
    ...
  • Event

    {
      "name": "temperature",
      "value": "20.47"
      ...
    }

In the event, the quotes indicate a string. If nothing is done internally, it will be up to the user to always support string and object in his flows.

Requests and interface

All requests made by the GUI when configuring a node (ex: fetching devices or commands) is proxied by the Node-RED server. The browser never communicate directly with Hubitat hub.

location node events

The location node is quite weird, because there is no special attribute for location events. Then all events received that doesn't match other kind of events (i.e. device, mode and hsm) are sent to location node.

Hubitat requests rate limiting

To avoid errors from Hubitat hub, all requests to the hub are throttled to 4 simultaneous requests with a retry delay of 40ms.

Development

To run linters:

  • npm run-script linter

To run unit tests:

  • npm test

To validate node-red scorecard:

  • node_modules/node-red-dev/bin/run validate -o hubitat-scorecard.json