Announcement

Collapse
No announcement yet.

Learning Node-Red - What do you do with it?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Learning Node-Red - What do you do with it?

    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?

    #2
    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

    Comment


      #3
      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.

      Click image for larger version

Name:	NodeRedUI.PNG
Views:	319
Size:	219.9 KB
ID:	1412543
      Click image for larger version

Name:	node.PNG
Views:	300
Size:	116.2 KB
ID:	1412544
      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


        #4
        I like what you have done, is this running on a tablet or other UI?

        Comment


          #5
          Originally posted by Black Cat View Post
          I like what you have done, is this running on a tablet or other UI?
          edit: I originally flagged this so an Admin would move it to Node-Red, it appears to have had other consequences....my apologies if it has.

          Comment


            #6
            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.

            Comment


              #7
              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


                #8
                Originally posted by kriz83 View Post
                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.
                Click image for larger version  Name:	 Views:	0 Size:	202.3 KB ID:	1412682

                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.

                Comment


                  #9
                  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


                    #10
                    Originally posted by kriz83 View Post

                    Click image for larger version Name:	 Views:	0 Size:	202.3 KB ID:	1412682

                    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.
                    Hi. kriz83 cool flow

                    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


                      #11
                      Originally posted by koburg View Post
                      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.
                      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;

                      Comment


                        #12
                        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;
                        My Dutch is very good 😄

                        —-
                        John

                        Comment


                          #13
                          My daughters are good at double dutch...

                          Comment


                            #14
                            Originally posted by Tillsy View Post
                            My daughters are good at double dutch...
                            That 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.



                            Comment


                              #15
                              Originally posted by kriz83 View Post
                              That 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.
                              I am not a huge fan of the HS event creator. I've been an advocate for the State machine flow for a years.

                              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:

                              Comment

                              Working...
                              X