Skip to content

Instantly share code, notes, and snippets.

View MorningZ's full-sized avatar

Stephen MorningZ

  • Central Florida
View GitHub Profile
@MorningZ
MorningZ / node-red-ha-notification
Created February 12, 2021 01:47
Node-RED flow to send notification with image to Home Assistant
/******* DO NOT COPY THIS COMMENT PART ********
It is so hard to find dynamically built JSON payloads to make
Home Assistant Call Service calls. After watching this video
where he has things pretty much hard coded I thought I'd put
together this little flow to show the structure needed to build
the payload to pass into a Call Service node. The "data.data"
property was a hanging point for me, but this works.
Reference:
@MorningZ
MorningZ / node-red-trakt.json
Last active October 28, 2020 00:28
Node-RED Flow to retrieve Trakt.TV data via API
[{"id":"c53ac113.a919d","type":"tab","label":"Trakt.TV","disabled":false,"info":""},{"id":"ec79305c.42be2","type":"inject","z":"c53ac113.a919d","name":"Generate User Code","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":160,"wires":[["96bf6703.d41748"]]},{"id":"65039fcb.ef24e","type":"http request","z":"c53ac113.a919d","name":"Device Code","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":510,"y":160,"wires":[["5b11c69d.ee7ef8"]]},{"id":"70b69bf4.282ae4","type":"debug","z":"c53ac113.a919d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":915,"y":160,"wires":[],"l":false},{"id":"5b11c69d.ee7ef8","type":"json","z":"c53ac113.a919d","name":"","property":"payload","action":"obj","pretty":false,"x":615,"y":160,"wires":[["70b69bf4.282ae4","307d6238.83d7ce"]],"l":false},
@MorningZ
MorningZ / node-red-attributes.json
Created August 4, 2020 15:26
Node-RED Flow for Hubitat Battery Levels and Temperatures
[{"id":"8315935d.f4bf5","type":"tab","label":"Retrieve Attributes","disabled":false,"info":""},{"id":"f7bd1d06.ced7c","type":"http request","z":"8315935d.f4bf5","name":"Retrieve all given levels","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://HUBITAT-IP-ADDRESS/apps/api/MAKER-API-ID/devices/all?access_token=MAKER-API-TOKEN","tls":"","persist":false,"proxy":"","authType":"","x":810,"y":200,"wires":[["c2bfc020.0b7e8"]]},{"id":"8897885a.fd8598","type":"debug","z":"8315935d.f4bf5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1195,"y":200,"wires":[],"l":false},{"id":"704ee71f.e0b3e8","type":"inject","z":"8315935d.f4bf5","name":"Battery Levels","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"battery","x":570,"y":180,"wires":[["f7bd1d06.ced7c"]]},{"id":"c63b192a.511458","type":"inject","z":"8315935d.f4bf5","name":"Temperatures","props":[{"p":"topic",
@MorningZ
MorningZ / hibitat_ikea_furtyr.groovy
Created June 22, 2020 15:50
Hubitat Driver - IKEA Furtyr
/**
* Added to HE on April 24, 2020
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
@MorningZ
MorningZ / node-red-backup-on-reboot.json
Created June 13, 2020 21:52
Node-RED: Backup flows and settings on restsrt
[{"id":"e0be58b2.7ddf98","type":"file in","z":"e9d24fcf.7516d","name":"Flows","filename":"/config/node-red/flows.json","format":"utf8","x":355,"y":100,"wires":[["a2f5e367.c78e3"]],"l":false},{"id":"959b7810.2ab598","type":"file","z":"e9d24fcf.7516d","name":"Flows","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","x":510,"y":100,"wires":[["5b4ffafb.686684"]]},{"id":"84dbd1e4.78bc","type":"inject","z":"e9d24fcf.7516d","name":"Create Backups","topic":"","payload":"restarted","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"300","x":420,"y":58,"wires":[["e0be58b2.7ddf98"]]},{"id":"a2f5e367.c78e3","type":"function","z":"e9d24fcf.7516d","name":"Set filename","func":"\n// Add file name from ISO date: 2020-04-25T23:13:54.138Z\nlet hit = (new Date()).toISOString().match(/^(\\d{4})[-](\\d{1,2})[-](\\d{2})[T](\\d{2})[:](\\d{2})/);\n\nmsg.filename = \"/config/node-red/backups/\" + hit[1] + \"-\" + hit[2] + \"/\" + hit[3] + hit[4] + hit[5] + \"_flows.json\";\n\nreturn msg;",
@MorningZ
MorningZ / hubitat-sengled-dimmer.groovy
Created May 4, 2020 23:49
Hubitat - Sengled Dimmer Switch Driver
/**
* Copyright 2019 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
@MorningZ
MorningZ / nr-hubitat.txt
Created April 27, 2020 17:51
Node-RED list for Hubitat Users
Must Have:
node-red-contrib-hubitat (Node-RED to Hubitat communication)
node-red-node-rbe (continue down flow only if a value changes)
node-red-contrib-noop (Simple placeholder node to help visualizations)
Palettes to help with logic:
node-red-contrib-stoptimer2 (timer with ability to stop/cancel)
node-red-contrib-bigtimer
node-red-contrib-boolean-logic-ultimate
node-red-contrib-easing (fading/dimming)
@MorningZ
MorningZ / node-red-backup.json
Created April 26, 2020 12:29
Node-RED: Automatically backup flows, creds and settings
[
{
id: "4542a4c1.d485bc",
type: "file in",
z: "294e068a.106daa",
name: "Flows",
filename: "/home/username/.node-red/flows_servername.json",
format: "utf8",
x: 155,
y: 360,
@MorningZ
MorningZ / myq_nodered_mqtt.flow
Last active April 25, 2020 21:10
MyQ Flow for Node-RED / MQTT
[{"id":"507826e5.3ffbf8","type":"inject","z":"874c5955.ab41f8","name":"Status: Timer","topic":"garage/status","payload":"","payloadType":"date","repeat":"30","crontab":"","once":true,"onceDelay":"","x":220,"y":720,"wires":[["b1c4af88.5978d"]]},{"id":"23b3616.20e559e","type":"http request","z":"874c5955.ab41f8","name":"Call for token","method":"POST","ret":"obj","paytoqs":false,"url":"https://myqexternal.myqdevice.com/api/v4/User/Validate","tls":"","persist":false,"proxy":"","authType":"","x":875,"y":680,"wires":[["49214e77.d3055"]],"l":false},{"id":"e34ac162.30a6a","type":"debug","z":"874c5955.ab41f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1015,"y":680,"wires":[],"l":false},{"id":"968bcaf0.5e0e68","type":"function","z":"874c5955.ab41f8","name":"Credentials","func":"\nreturn {\n \"payload\": {\n \"username\" : \"XXXXXXXXX\",\n \"password\" : \"XXXXXXXX\"\n },\n \"headers\": {\n ContentType : \"applicatio
@MorningZ
MorningZ / query-users.sql
Created April 18, 2020 17:10
SQL Security Audit Report
/*
Found the base of this query on StackOverflow, I've gone through and cleaned some things up and given some options
Security Audit Report
1) List all access provisioned to a sql user or windows user/group directly
2) List all access provisioned to a sql user or windows user/group through a database or application role
3) List all access provisioned to the public role
Columns Returned:
UserName : SQL or Windows/Active Directory user account. This could also be an Active Directory group.