Getting started with node red

If your not seeing what it is that @csteele is referring too

Click that arrow next to the word "Sequence" and then highlight everything @aaiyar posted under it. Take that and "import"/paste it into NR. This will allow you to use other peoples flows in your system! It is one of the greatest things about NR, IMO. We can share flows/rules and do not need to make them from scratch.

If you import a flow that uses nodes you do not have installed NR will prompt you to install them. It is very cool. Being new as well, I have never shared one, so here goes....

This flow turns a light on 25%, but only between certain hours. It includes a timer shut off with a cancellation if more motion is detected. Enjoy!!

Flow / Sequence ....

[{"id":"222ab041.8e8c1","type":"within-time-switch","z":"2b8ea305.21e4dc","name":"8pm-7am","nameInt":"","positionConfig":"7d0e8fed.fdaa5","startTime":"20:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"07:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":560,"y":2060,"wires":[["abcaa912.89c168"],[]]},{"id":"7c799c3e.bdbfd4","type":"hubitat device","z":"2b8ea305.21e4dc","name":"Kitchen Beam Motion","server":"e40ec0b5.83be","deviceId":"2376","attribute":"motion","sendEvent":true,"x":160,"y":2080,"wires":[["9edd7657.da71f8"]]},{"id":"3293ddcd.b5fd52","type":"hubitat command","z":"2b8ea305.21e4dc","name":"Under cabinet lights On","server":"e40ec0b5.83be","deviceId":"590","command":"on","commandArgs":"","x":930,"y":2060,"wires":[["3c2d811a.2d4fce"]]},{"id":"9edd7657.da71f8","type":"switch","z":"2b8ea305.21e4dc","name":"Active/Inactive","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":2100,"wires":[["222ab041.8e8c1"],["c1ed629e.b8e3c"]]},{"id":"4a3b8913.620c88","type":"hubitat command","z":"2b8ea305.21e4dc","name":"Under cabinet lights Off","server":"e40ec0b5.83be","deviceId":"590","command":"off","commandArgs":"","x":1610,"y":2120,"wires":[[]]},{"id":"abcaa912.89c168","type":"hubitat command","z":"2b8ea305.21e4dc","name":"Set to 25%","server":"e40ec0b5.83be","deviceId":"590","command":"setLevel","commandArgs":"25","x":730,"y":2060,"wires":[["3293ddcd.b5fd52"]]},{"id":"1c972d21.76a9f3","type":"comment","z":"2b8ea305.21e4dc","name":"Under Cabinet Night Lighting","info":" - ","x":120,"y":2020,"wires":[]},{"id":"aa9b2768.d82258","type":"stoptimer","z":"2b8ea305.21e4dc","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":1400,"y":2120,"wires":[["4a3b8913.620c88"],[]]},{"id":"3c2d811a.2d4fce","type":"change","z":"2b8ea305.21e4dc","name":"Send STOP","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":2060,"wires":[["aa9b2768.d82258"]]},{"id":"11d3c06c.3197f","type":"hubitat device","z":"2b8ea305.21e4dc","name":"Kitchen Wide Motion","server":"e40ec0b5.83be","deviceId":"2759","attribute":"motion","sendEvent":true,"x":160,"y":2140,"wires":[["9edd7657.da71f8"]]},{"id":"d6cd7157.3ecb9","type":"switch","z":"2b8ea305.21e4dc","name":"Active/Inactive","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1200,"y":2120,"wires":[[],["aa9b2768.d82258"]]},{"id":"e43a4f26.c96bc","type":"hubitat device","z":"2b8ea305.21e4dc","name":"Kitchen Wide Motion","server":"e40ec0b5.83be","deviceId":"2759","attribute":"motion","sendEvent":false,"x":1000,"y":2120,"wires":[["d6cd7157.3ecb9"]]},{"id":"c1ed629e.b8e3c","type":"hubitat device","z":"2b8ea305.21e4dc","name":"Kitchen Beam Motion","server":"e40ec0b5.83be","deviceId":"2376","attribute":"motion","sendEvent":false,"x":600,"y":2120,"wires":[["4f52244f.6b7bcc"]]},{"id":"4f52244f.6b7bcc","type":"switch","z":"2b8ea305.21e4dc","name":"Active/Inactive","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"active","vt":"str"},{"t":"eq","v":"inactive","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":800,"y":2120,"wires":[[],["e43a4f26.c96bc"]]},{"id":"7d0e8fed.fdaa5","type":"position-config","z":"","name":"localPosition","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":99,"timeZoneDST":0,"stateTimeFormat":"3","stateDateFormat":"12"},{"id":"e40ec0b5.83be","type":"hubitat config","z":"","name":"Devices Hub","usetls":false,"host":"10.13.9.11","port":"80","appId":"2532","nodeRedServer":"http://10.13.9.15:1880","webhookPath":"/hubitat/webhook","autoRefresh":true,"useWebsocket":false}]

3 Likes

Yup. I think @csteele includes that node in his RPi build.

1 Like

17 posts were merged into an existing topic: Hubitat slowing down after a few days

I found the following useful:

Node-Red YouTube Channel

Hubitat Config Node

Node-RED + Home Assistant How-To - Although very HA orientated

1 Like

Keeping this back on topic, I found myself trawling through posts to find flows to give me inspiration or help on building nodes. I've started to collate them and may help others

Motion Flow


image

Motion Flow with Delay off (using node-red-contrib-stoptimer-varidelay)

Motion flow with Modes - Slightly different approach than the above 2 and different action depending on mode


image

Motion approach by @JasonJoel
image

Motion Lighting with time of day parameters by @csteele
image
Screen Shot 2020-07-16 at 9.23.52 AM
Screen Shot 2020-07-16 at 9.25.09 AM
Screen Shot 2020-07-16 at 9.26.00 AM

Setting mode with presence by @pat.richards
image

Turning on Porch Light by @aaiyar
Screen Shot 2020-07-16 at 11.28.54 AM

Under Cabinet lighting by @TechMedX
image

Basic Button Sequence by @waynespringer79


pico1
pico2
pico3

Light Control via music and Alexa by @stephen_nutt
image
The "On Device Activity" Device Node listens and if it hears Alexa, it turns Dining Room light on then turns it off 10 seconds later. If it hears Alexa Stop, it turns Dining Room light off.
The "On Audio Player State Change" Device Node listens and if "Playing" is in output payload, it turns Dining Room light on and cancels the mytimeout node which keeps the Dining Room light from turning off.

Know Idea what this does by @mike
image

TTS based on power by @JasonJoel
image
Screenshot 2020-03-31 at 11.05.40 AM

Garage Door Open/Closed and TTS by @aaiyar
image

Garage timeout based on active sensor by @stephen_nutt
image

Motion flows by @Royski (warning uses deCONZ)
image

6 Likes

Impressive work thank you for this... I wonder if we could set up a repository for flows maybe on github....

2 Likes

That would be cool, as I sometimes struggle to know what data is inside the nodes and would definitely help to have a searchable record as it would be incredibly simple for people to copy and alter instead of trying to re-create the wheel each time

2 Likes

+1 on each of these; I think the part I have been scratching my head over the most is what data is in each node and how each is set up to pass it on. Seeing more of the community flows and how members have them set up has made it a lot easier for me to wrap my head around how to set up flows a little better (without having to re-invent the wheel). Since it does seem to come up often, and using myself as an example, I definitely agree it would be most beneficial if there were a decent guide/repository for beginners to learn to take the dive into NR.

Each very helpful I found to get started, but just not enough for that final push to get everything to work.

Of course YOU could - no one is stopping anyone from doing that.

Funny how when people say "we" they really mean "not me" most of the time. :wink:

(OK - that was just a bit of teasing. It isn't a bad idea, but either someone would have to take the lead in making it and the long term maintenance of it, or it probably wouldn't get used.

Most end users aren't likely to load flows into it long term, and if they did without an administrator curating them for content and structure it would be a jumbled mess in a month.

So if this were to happen, someone needs to administrate/maintain the repository, which is not a trivial amount of work initially - and if the are ever major changes to the nodes or Maker API it would be a lot of work at that time as well.

I am well aware of how much work this idea is, which is why I won't be the one to do it.)

3 Likes

chuckles

I am more than willing to help and take on some of the work but I have only been using my HE for less than 6 months at this time and I believe we need some experience to make this work.

So yes I volunteer to help but not to lead

Fun thing to find out this morning; apparently NR runs everything in UTC time? Which would explain why I have been banging my head trying to figure out why flows were not triggering when I thought they should. Maybe I missed that small detail in the documentation somewhere :roll_eyes:

Once that was figured out...easy enough to finally get something simple working. I did find I like the light scheduler (noe-red-contrib-light-scheduler by niklaswall) for the graphical representation of on/off periods. Thanks to @Shaneb for the collation of various flows; I'm definitely finding NR on the visual aspect to be easier to wrap my head around than RM.

Most (although not all) Node-RED nodes will use local time. However, you have to have the timezone set correctly on the node-red host if you want to do logic based on local time.

How that timezone definition is done depends on where you are running it - Rpi, docker, k8s, etc. E.g. for docker you have to set an environmental variable "TZ" to the correct timezone.

2 Likes

I have a question about using HE and a Node Red Dashboard. I created switches, and got them to work great. Issue I have is with if a automation I have or a switch is manually turned on, it is not updated in the Node red dashboard. I see an example here for HomeSeer and keeping the dashboard in sync, but cant see one for Hubitat, and trying to move away from the built in HE dashboard to get a new NR one made (See: Keeping a Node-Red Dashboard in sync with HomeSeer - HomeSeer Message Board). I have searched, but see no examples from users, but I know some of you must have a dashboard, and if anyone is willing to share how they keep a light switch, etc in sync on the dashboard, I would REALLY appreciate a sample flow.

Here is a simple example..

Make sure you have "Send events" checked in your device node..

Here is the dashboard switch node config:

edit: the inject node at the beginning of the sequence is there to populate the dashboard when you "deploy" or restart Node-RED. It is set to only run once on startup.

edit2: changed the first picture to reflect correct "Change" node. Due to the on/off payloads in the dashboard switch it requires "on/off" input!

1 Like

I think the switch from payload / Jsondata is the part that I am missing. Is it possible to share that node. The on ? true/false. Thanks for the help ErkTrek,

Here is the basic switch node with JSONATA... You should be able to easily replicate the other stuff provided HE Nodes is set up properly and responding to events.

JSONATA Switch Node example

[{"id":"68a3910b.58ba8","type":"change","z":"af91369d.586338","name":"set msg.payload = JSONATA / payload.value = \"on\" ? true : false","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.value = \"on\" ? true : false","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":2400,"wires":[["a0faee22.68e82"]]}]

edit: I LOVE JSONATA stuff... makes it easy to do more complicated things in the stock switch nodes etc without having to use Function nodes. I also love Function nodes too though.. :wink:

edit2: I guess I could also have just done this...

payload.value = "on"

NOTE!!!!!!!
I made a slight error - the INPUT msg.payload MUST MATCH whatever is defined by the dashboard ON/OFF payloads so in my simple example above (which has been corrected) you would NOT use JSONATA!!!!!!!

2 Likes

But also if your not a jsonata type, you can easily do the same thing with 2 nodes - a switch node followed by a change node (or two).

2 Likes

Thank you Erktrek!

2 Likes

I do not know. Something I am not doing, I just dont know. Turn the light on, it does send the data, but the switch just doesnt manually show.

Screenshot by Lightshot - Flow

Screenshot by Lightshot - Light
Screenshot by Lightshot - Sending status.

I haven't added the on or off for the Dashboard switch yet, just trying to get the Dashboard to show correct status first if someone "flips" the light or the motion sensor turns on the light from the rule in a different flow

I definitely am missing something :confused:

I thought I got it when I changed the Dashboard switch to Boolean True/False, as the updates showed if the light was on. But nope :confused:

In your dashboard node, do you have it set to follow input or output status? Should be input, which is not the default.

Not at home, so can't show you a screenshot. But as I exclusively use Node-RED dashboards (for my very limited use of dashboards) I know this can/should work.