Node-Red Flow Samples/Sharing

@mike - Have been having fun playing around with finite state machines. Wanted to post an image of my simple sequence I've done to handle timed lighting controls based on home/away + guests.

I am using the "node-red-contrib-finite-state-machine" node vs "node-red-contrib-state-machine" node - I kinda like the ability to code in the transitions via JSON. Also note - I left out the actual light control part. For that I have separate sublows for each state and am using the "node-red-contrib-presence-faker" node to control timing/on/off etc...

As an aside - I'm a really "fascinating" and "interesting" guy apparently at least according to my wife. :laughing: :thinking: :cry:

4 Likes

A totally non-biased view. :stuck_out_tongue_winking_eye:

Sadly my wife's comments are usually sarcastic and more often accurate in their intent than I would care to admit.. ah well what does she know about the thrill of Finite State Machine transitions anyway?

:rofl:

1 Like

I suggest you ask her.
:rofl:

Well I tried and that's why I ended up posting here.. :rofl:

3 Likes

That looks good. I might transition. The one I use has a start up error that I asked about here.

1 Like

I did not really test the node-red-contrib-state-machine node because I mistakenly thought you were referring to the node-red-contrib-finite-statemachine node and installed that instead. Since I was able to get it to work and it was updated more recently I decided to keep it instead.

You should be able to easily port your sequence over though.. except for the JSON config bit they seem very similar.

Oh did you check out this one? Looks like you can update from your node and not worry about anything.

That does look interesting. How does one delete a node type when it's in use? It doesnt seem intuitive (to me).

@mike - probably via the command line and npm... would back everything up first though.

Something like this from the Node-RED directory:

npm uninstall node-red-contrib-state-machine
npm i node-red-contrib-persistent-fsm

Then restart - I had to do something similar for the Alexa CakeBread node update.

1 Like

Thanks, that was perfect. I initially tried it in the wrong Node Red directory, but had a second go in the right directory. It all works, without hours of fixing. Thanks!

1 Like

Has anyone got a flow to get the wan IP address of their router? Was just looking at the Remote Admin thread and got me to thinking this would be useful if you don't have a static address assigned by your ISP and you could get an email or notification when the address changes.

Yep.

[{"id":"a09b3bd.8915bc8","type":"inject","z":"5c6662a7.2c252c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3600","crontab":"","once":true,"onceDelay":"120","topic":"","payload":"","payloadType":"date","x":190,"y":160,"wires":[["3f7a6cc3.64ad74"]]},{"id":"5864920b.31491c","type":"switch","z":"5c6662a7.2c252c","name":"","property":"payload.publicIPv4","propertyType":"msg","rules":[{"t":"eq","v":"publicIP","vt":"flow"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":160,"wires":[["444aaea.c21305"],["596f2616.aaedd8","cb730a2e.6d1518","d88731a4.c8589"]]},{"id":"596f2616.aaedd8","type":"change","z":"5c6662a7.2c252c","name":"Store IPv4 ","rules":[{"t":"set","p":"publicIP","pt":"flow","to":"payload.publicIPv4","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":160,"wires":[[]]},{"id":"cb730a2e.6d1518","type":"change","z":"5c6662a7.2c252c","name":"Pushover","rules":[{"t":"set","p":"device","pt":"msg","to":"Mike","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"\"IP Address changed to \" & $.payload.publicIPv4 & \"\"","tot":"jsonata"},{"t":"set","p":"sound","pt":"msg","to":"none","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":200,"wires":[["bcec03a0.1f11f"]]},{"id":"3f7a6cc3.64ad74","type":"ip","z":"5c6662a7.2c252c","name":"ip","https":false,"timeout":"5000","internalIPv4":true,"internalIPv6":true,"publicIPv4":true,"publicIPv6":false,"x":370,"y":160,"wires":[["5864920b.31491c"]]},{"id":"444aaea.c21305","type":"rbe","z":"5c6662a7.2c252c","name":"","func":"rbei","gap":"","start":"","inout":"out","septopics":false,"property":"payload.publicIPv4","x":770,"y":120,"wires":[["f2678e98.6865c"]]}]
2 Likes

Thanks - is that the node-red-contrib-ip node?

Yes. node-red-contrib-ip

I also have a pushover notification coming out of the top switch, which I removed....it notifies me of the change in public IP address.

3 Likes

You could also look at the Hub Info device driver for Hubitat. It's got a new feature to get the external IP.

2 Likes

The speedtest node was (for me) completely useless... It reported like 20MBps when going to Speedtest.net would show 400 and would also be around 20 if my provider was having a problem and Speedtest.net showed 90. So I built one that uses Fast.com:

It's on the order of 50% of the speed I get from Speedtest.net and is the same as the result from Fast.com

5 Likes

Hello all, I'm learning about node-red and love the additional capabilities it adds to hubitat, especially the dashboards. I have a beginner question and did a lot of searching but couldn't find a clear answer anywhere.

I am experimenting to find if the node-red dashboard would make a nice wall-panel touch display. I have some temperature line charts which I love and now I am trying to control a dimmable light using the ui_switch and ui_slider. Like the standard hubitat dashboard, the switch and slider should both control the light, and the UI should respond to changes when the light is controlled from elsewhere (this is the part that overly complicates the flow).

I have cobbled something together that works, but would like to know if I am on the right track or if there is a better way. If this is a good enough way then I will try to figure out how to make it into a subflow so I can re-use it for many lights.

From left to right I have

  • Device - the dimmable light switch. Receives "level" (dim) and "switch" (on/off) events.
  • Function - route message to the proper UI element while also formatting message properly as needed for next node
  • UI dashboard elements - switch and slider.
    • From the input (left) side it receives events and updates the display. I turned off "pass through" so there will be no infinite loop
    • Output (right) side - If you click the switch or slide the slider, sends command to the device
  • Change nodes - format message as needed by command node
  • Command node - control the light

ui

This might be useful to anyone looking to replicate a "wait until" flow. The first inject node set the flow context to First and starts the timeout timer. The second inject node is passed through if sent before the timeout and resets the flow context to "none"

@Royski

As a way to streamline your dummy Alexa Routines that you have to do, my brother pointed this out for Alexa:

It seems that you could create a bunch of different phrases that you use and just tell Alexa to respond with "ok". I haven't played with it yet but I hope that it would eliminate a bunch of dummy routines that just wait. My brother got to 50 "questions" and it was still going strong.

I haven't had a chance to play with it but I think it would streamline both of our setups.

3 Likes