Skip to content

Instantly share code, notes, and snippets.

Ubiquiti UniFi Presence Detection

Uses a UniFi node to monitor a UniFi management instance for named devices and their "Last Seen" values to determine device presence on the network.

Usage

  1. Install the node-red-contrib-unifi package.
  2. Past into a new or existing flow.
  3. Modify the UniFi node settings.
  4. Change the list of devices in the "Determine device presence" node. It maps the final MQTT topic that will be used to announce presence to the device name setup in UniFi for a client. Could be easily changed to be based on MAC address, etc., but if you name the devices in UniFi you can then later change those names without changing this flow.
@i8beef
i8beef / Node-Red TV Listing
Last active June 6, 2018 01:35
Node-Red TV Listing
# TV Listing
Reads TV listing from Zap2It on a schedule, and stores locally for usage. Exposes an endpoint that will generate sequential messages for MQTT to change channel.
# Usage
1. Ensure you have the node-red-contrib-primitives package installed, as this uses the iterator it provides.
2. Paste into a new flow.
3. Change the URL in the "Get current guide" node for your TV listings.
4. Update the "Set our shows" node to a list of shows you like (all lower-case, no punctuation with '&' converted to the word 'and').
[{"id":"5cbfde25.c029f","type":"chromecast-play","z":"afd66f30.afd4b","name":"","url":"","contentType":"","ip":"","x":490,"y":320,"wires":[["a15e9a18.739508"]]},{"id":"dfecb67.b53d648","type":"function","z":"afd66f30.afd4b","name":"Map target device","func":"let deviceIp = '192.168.1.111';\nswitch (msg.payload.device) {\n case 'kitchen home':\n deviceIp = '192.168.1.111';\n break;\n case 'bedroom home':\n deviceIp = '192.168.1.124';\n break;\n}\n\nreturn {\n payload: {\n ip: deviceIp,\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=' + encodeURIComponent(msg.payload.phrase) + '&tl=En-us',\n contentType: 'audio/mp3'\n }\n};","outputs":1,"noerr":0,"x":310,"y":320,"wires":[["5cbfde25.c029f"]]},{"id":"9f337059.9db22","type":"http in","z":"afd66f30.afd4b","name":"","url":"/ifttt/say","method":"post","swaggerDoc":"","x":110,"y":320,"wires":[["ff793b22.4a85b8","deca82ff.34579","dfecb67.b53d648"]]},{"id":"f

Google Actions API

An implementation of the Google Actions API for node-red. Implements SYNC, QUERY, EXECUTE, and REQUEST_SYNC.

Heavily based on the sample node.js implementation here.

Usage

  1. Ensure that the OAuth 2 for Google Actions flows have been put in place. This endpoint will verify the bearer token for requests against the token stores in that flow.
  2. Paste into a new flow.
@i8beef
i8beef / Node-Red OAuth2 For Google Actions.md
Last active July 30, 2018 18:37
Google Actions OAuth Flow

OAuth 2 Authorization Code Flow For Use With Google Actions

This flow provides a "fake" OAuth 2 implementation for use with the Google Actions API.

Exposes three endpoints:

  1. /google/oauth-auth - Main auth endpoint that Google will call to initialize an OAuth 2 handshake. Checks "client" and "client secret", and returns a login form.
  2. /google/oauth-login - Processes login form, verifies "auth key" provided and generates a new OAuth auth code that the caller (Google) can then exchange for a real OAuth 2 ticket via the last endpoint.
  3. /google/oauth-token - Allows the caller to exchange an "auth key" for a valid OAuth 2 token, or request a new token via refresh token.