I use Node-red to have Alexa speaking the messages but it was more of a code copy than anythings. I'm learning it but I'm wondering what you all do with it?
Announcement
Collapse
No announcement yet.
Learning Node-Red - What do you do with it?
Collapse
X
-
The possibilities are almost limitless.
BTW. It would be better to move this post to the NodeRed forum
https://forums.homeseer.com/forum/ho...tions/node-red
-
I like it for the UI and now that there is a Homeseer Node it is very easy to get data from HS to Node-Red.
I also have a couple of events that trigger my echos to do things like stop all music when the phone is picked up and play music when the house is put in cleaning mode.
Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
Scripts = Various
- Likes 2
Comment
-
A lot of the automations we all create, in fact are state machines. Having every state in a different event is a bit cumbersome and can lead to errors.
For example changing the lights when coming home or leaving, when it gets dark, when you go to bed, ...
My multi-event automations are modeled in statemachines in NR, so I am sure only 1 of them can be active at a time.
- Likes 1
Comment
-
As the ui is browser based it can be viewed on any device. The screenshot is from a Windows device.
Sent from my SM-G973F using Tapatalk
Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
Scripts = Various
Comment
-
Originally posted by kriz83 View PostA lot of the automations we all create, in fact are state machines. Having every state in a different event is a bit cumbersome and can lead to errors.
For example changing the lights when coming home or leaving, when it gets dark, when you go to bed, ...
My multi-event automations are modeled in statemachines in NR, so I am sure only 1 of them can be active at a time.
I attached the statemachine for my lights.
It has 5 inputs. When triggered, the outcome of the statemachine depends on:
- The state of the other inputs
- The current state
In HS Events, this would be multiple events (or 1 big events with OR's and AND's):
- 5 triggers
- at least 4 conditions per trigger
So it is quite easy to make a mistake if you need to add an extra condition/trigger. Using NR makes this very easy, and I am assured that only 1 lighting profile can be active at any time. Furthermore, I have my statemachine under test.1 Photo
- Likes 1
Comment
-
thanks for sharing your projects, I love what you made with it. I'm just touching the surface here. Any good places where I can learn more? Youtube kind of sucks, 3 hours video to show 2 minutes of node-red and sometime is still very confusing. Not sure why they go on and on in slow pace with something simple. I'm trying to read from a csv file for testing node-red and I could not find a good youtube that explain it. Currently still having issues reading a simple file :-(
Comment
-
Originally posted by kriz83 View Post
I attached the statemachine for my lights.
It has 5 inputs. When triggered, the outcome of the statemachine depends on:
- The state of the other inputs
- The current state
In HS Events, this would be multiple events (or 1 big events with OR's and AND's):
- 5 triggers
- at least 4 conditions per trigger
So it is quite easy to make a mistake if you need to add an extra condition/trigger. Using NR makes this very easy, and I am assured that only 1 lighting profile can be active at any time. Furthermore, I have my statemachine under test.
I do daily Struct programming(plc controllers) but have not used node-red so much until now.
can you send/show the code used in the statemachine function.
thanks
Comment
-
Originally posted by koburg View PostI do daily Struct programming(plc controllers) but have not used node-red so much until now.
can you send/show the code used in the statemachine function.
Code:context.data = context.data || { "alarm": null, "donker": null, "slapen": null, "vakantie": null, "avondverlichting": null, } var slapenNetActief = false; switch (msg.topic) { case "alarm": context.data.alarm = msg.payload; break; case "donker": context.data.donker = msg.payload; break; case "slapen": if (context.data.slapen === false && msg.payload) slapenNetActief = true; context.data.slapen = msg.payload; break; case "vakantie": context.data.vakantie = msg.payload; break; case "avondverlichting": context.data.avondverlichting = msg.payload; break; } if (context.data.alarm !== null && context.data.donker !== null && context.data.slapen !== null && context.data.vakantie !== null) { var status = ""; if (slapenNetActief) { status = "Naar bed gaan"; } else if (context.data.vakantie && context.data.donker && context.data.alarm && context.data.avondverlichting) { status = "Vakantie - lichten aan"; } else if (context.data.vakantie && context.data.donker && context.data.alarm && !context.data.avondverlichting) { status = "Vakantie - lichten uit"; } else if (!context.data.donker && !context.data.alarm) { status = "Aanwezig - lichten uit (overdag)"; } else if (!context.data.donker && context.data.alarm) { status = "Afwezig - lichten uit (overdag)"; } else if (context.data.donker && context.data.alarm && context.data.slapen) { status = "Slapen - lichten uit"; } else if (!context.data.avondverlichting && context.data.donker && context.data.alarm) { status = "Nacht - lichten uit"; } else if (context.data.donker && !context.data.alarm && !context.data.slapen) { status = "Aanwezig - lichten aan"; } else if (context.data.donker && context.data.alarm && context.data.avondverlichting && !context.data.slapen) { status = "Afwezig - lichten aan"; } node.status({fill:"green",shape:"dot",text: status}); return { "payload": status }; } else { node.status({fill:"red",shape:"ring",text: "Undefined"}); } return null;
- Likes 1
Comment
-
Originally posted by kriz83 View Post
It's in dutch, but you should be able to get the idea
Code:context.data = context.data || { "alarm": null, "donker": null, "slapen": null, "vakantie": null, "avondverlichting": null, } var slapenNetActief = false; switch (msg.topic) { case "alarm": context.data.alarm = msg.payload; break; case "donker": context.data.donker = msg.payload; break; case "slapen": if (context.data.slapen === false && msg.payload) slapenNetActief = true; context.data.slapen = msg.payload; break; case "vakantie": context.data.vakantie = msg.payload; break; case "avondverlichting": context.data.avondverlichting = msg.payload; break; } if (context.data.alarm !== null && context.data.donker !== null && context.data.slapen !== null && context.data.vakantie !== null) { var status = ""; if (slapenNetActief) { status = "Naar bed gaan"; } else if (context.data.vakantie && context.data.donker && context.data.alarm && context.data.avondverlichting) { status = "Vakantie - lichten aan"; } else if (context.data.vakantie && context.data.donker && context.data.alarm && !context.data.avondverlichting) { status = "Vakantie - lichten uit"; } else if (!context.data.donker && !context.data.alarm) { status = "Aanwezig - lichten uit (overdag)"; } else if (!context.data.donker && context.data.alarm) { status = "Afwezig - lichten uit (overdag)"; } else if (context.data.donker && context.data.alarm && context.data.slapen) { status = "Slapen - lichten uit"; } else if (!context.data.avondverlichting && context.data.donker && context.data.alarm) { status = "Nacht - lichten uit"; } else if (context.data.donker && !context.data.alarm && !context.data.slapen) { status = "Aanwezig - lichten aan"; } else if (context.data.donker && context.data.alarm && context.data.avondverlichting && !context.data.slapen) { status = "Afwezig - lichten aan"; } node.status({fill:"green",shape:"dot",text: status}); return { "payload": status }; } else { node.status({fill:"red",shape:"ring",text: "Undefined"}); } return null;
—-
John
Comment
-
Originally posted by Tillsy View PostMy daughters are good at double dutch...
Off course, I moved the complexity into the javascript code now. But this code can be unit tested. That is not possible with HS events. I can make changes to the script while making sure I did not break anything.
Comment
-
Originally posted by kriz83 View PostThat should be G14 classified info ! ;-)
Off course, I moved the complexity into the javascript code now. But this code can be unit tested. That is not possible with HS events. I can make changes to the script while making sure I did not break anything.
That said, I am not sure how this is any better. You are writing a script to do the state machine in Java script. In Homeseer, I could have an event that would fire if any of the 5 things change, then call a script there with essentially the same code passing the reference to the 5 devices. I could unit test that. The state would be a virtual device (I'd like to see something like a HS counter be able to be set so that could be used as a SM- or a global string. Global variables go away when HS rebooted).
HS3 Pro Edition 3.0.0.435 (Windows Server 8.1 on ESXi box)
Plug-Ins Enabled:
Z-Wave:,RaspberryIO:,AirplaySpeak:,Ecobee:,
weatherXML:,JowiHue:,APCUPSD:,PHLocation:,Chromecast:,EasyTr igger:
- Likes 2
Comment
Comment