Announcement

Collapse
No announcement yet.

To script or not to script? - Other ways to get more event functionality

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

    To script or not to script? - Other ways to get more event functionality

    Please understand I currently don't even have a good base knowledge of different ways to go beyond events in HS4.

    Though I'm sure it will grow over time, my main wants and wishes are to be able to not write 10 events to get what IMHO should be able to be done in one. I've beat this horse plenty, but I just need more "switches" like else/else if/do/do while/for/etc. It makes my head hurt to bounce back and forth between all the other events I have to call from a master event to emulate that functionality.

    WAY back in the past I did a fair amount of program writing in with the Turbo C compiler, but I do mean way back (late 80's early 90's?). What I am wondering is if I need to go all the way to using something like Visual Studio...or if I can get most of everything I need directly in HS or with things I know nothing about, like Node Red.

    I'm being lazy asking first for some input vs digging through a bunch of docs to see what I can do with what, but I'm guessing people on this forum know better than anyone for HS4.

    Any suggestions would be greatly appreciated. THANKS!

    #2
    I'm an engineer by education, like you, did some programming back in the 80s and 90s when I was still in the trenches. I'm a technology executive now, while I could get my hands dirty writing code again, I have no time or desire at this point in my life. There are so many other things in my life that need my attention.

    I have yet to find any situation in HS4 that I can't accomplish in an event. Things that previously took scripts in HS3 (from looking around in forum examples) I find I can implement in HS4 with some careful planning and forethought. And tools like EasyTrigger are essential in order to do additional logic, comparisons and calculations all without writing scripts/code. The best way I can explain to approach your use-cases is to think in terms of state-machine design. This is partially accomplished by using virtual devices and counters to hold information you need to reference in an event and across other events.

    I'd also recommend visiting the Event Clinic in the HS3 forum, almost all the examples there apply to HS4 also since under the hood they are essentially still the same.

    Hope this helps.

    Comment


      #3
      I feel your pain. I am trying to stay away from scripts as much as possible and do everything in events, even if it takes a lot more steps. I hope HS finally will come out with the promised conditional actions which can emulate if then else scenarios. The reason why I avoid scripts isn't so much because I don't want to write scripts but because in case somebody else needs to take over from me and maintain the system it will be too complicated for them. Having said that, if you want to get into scripting this will help a lot:

      http://tenholder.net/tenWare2/tenScripting/Default.aspx

      Comment


        #4
        Originally posted by mulu View Post
        I feel your pain. I am trying to stay away from scripts as much as possible and do everything in events, even if it takes a lot more steps. I hope HS finally will come out with the promised conditional actions which can emulate if then else scenarios.
        I thought about this a lot.... and I still can't understand why anyone would need if-then-else in home automation. Either the event should trigger (and execute its actions) or it shouldn't.

        Could you explain a use-case where if-then-else is needed?

        Comment


          #5
          I'm kinda in the same boat - I used to write custom business applications back in the 80's & 90's in basic, bDase II, then dBase III, then clipper compiler. I had no intention of reactivating those long-dormant brain cells, but there were some things I simply could not see how how to accomplish through events.

          Primarily, I wanted a robust system that would be fully end-user configurable via HSTouch running on Android tablets. For that, I needed to know which tablets were logged on, what screens they were on, and which ones requested certain activities.

          I begrudgingly jumped back into writing scripts and I was able to accomplish what I set out to do. Two things about that:
          1. As @mulu said, I was worried that in the event I got hit by a falling meteorite, scripting would make it incredibly difficult for some else to follow. Then I realized that it would be my wife doing this, but she can barely use apps on her phone. Thus the desire to be able to configure HS3, now HS4 via a relatively easy-to-use GUI on tablets.
          2. Once I got back into the swing of things, and had some basic subroutines to build on, it became easier to do additional "unconventional" things via scripts as opposed to multi-level events
          And as @TC1 said - I'm busy and didn't really need to spend the time and rent valuable (and seemingly diminishing) space in my brain for this.

          I'm glad I did though, because as it turns out, the challenge was good for me.

          As always, YMMV though

          Comment


            #6
            I am a fan of scripting. In the 80's I spent nearly 6 years coding in c and fortran on real time engineering simulators. There are times when it makes solving the problem easier. Take watering the lawn. I could do it with events but it was not dynamic. I need to water all zones for a short time and do this for repeated cycles. I live in the west where water is a precious commodity. By using a script and HSTouch along with virtual devices, I have complete control over 11 zones, 3 cycles and control when a zone is specialized like flower beds. Not very practical with events.

            I have done keypads and keyboard scripts and have shared on the forum. It takes time to get back into scripts, but it opens so much flexibility to HS.

            the question really is - Is the pain of relearning worth the gain in flexibility. Personal decision!

            Comment


              #7
              Originally posted by AllHailJ View Post

              the question really is - Is the pain of relearning worth the gain in flexibility. Personal decision!
              Exactly. Everything you described can be done by a Rachio or most other modern irrigation controllers, and they also incorporate weather intelligence. My time is money and I'd rather plunk down around $200 than spend time coding and tweaking. Another reason is I like to decouple the major systems in my house (ie, irrigation, heat, A/C, etc) from each other and simply use HS for the coordination and data collection. That way if HS is down then all the other systems still function.

              Comment


                #8
                Personally, I'm not a fan of scripting ......
                Jon

                Comment


                  #9
                  Originally posted by jon00 View Post
                  Personally, I'm not a fan of scripting ......
                  Only coding plugins...

                  Comment


                    #10
                    TC1 - The reason I at least think scripting would make this easier would be something like this below. I'm sure everybody on the forum could probably show me a better way to do this...but this is an example I was working on yesterday.

                    The trigger is I arrive
                    IF it's before 5PM ...do X,Y,Z
                    ELSE if it's after 5PM do Y,A,B
                    ELSE if it's After 10 PM do R,S,T


                    I admit I suck at creating events, but is there a way to do that in a single HS event? I'm sure I could create devices to hold some state to get this done maybe, but that's even more to my point that the simplicity of tools available in HS4 is actually adding to complexity. The funny thing is that trigger logic has some great tools, which also helps make up for the lack of "do" switches. ...if you don't mind writing multiple events.

                    Comment


                      #11
                      Originally posted by ts1234 View Post
                      TC1 - The reason I at least think scripting would make this easier would be something like this below. I'm sure everybody on the forum could probably show me a better way to do this...but this is an example I was working on yesterday.

                      The trigger is I arrive
                      IF it's before 5PM ...do X,Y,Z
                      ELSE if it's after 5PM do Y,A,B
                      ELSE if it's After 10 PM do R,S,T


                      I admit I suck at creating events, but is there a way to do that in a single HS event? I'm sure I could create devices to hold some state to get this done maybe, but that's even more to my point that the simplicity of tools available in HS4 is actually adding to complexity. The funny thing is that trigger logic has some great tools, which also helps make up for the lack of "do" switches. ...if you don't mind writing multiple events.
                      The issue is that you are trying to combine three separate triggers into one event. And since each trigger has different outcomes, I don't see the advantage of trying to shoehorn all these into one event. What would you gain?

                      My approach? Create an Event Group called "Arrival" and then create three events in that group called "Before 5pm", "After 5pm" and "After 10pm"

                      Easy peasey in terms of organization and updating.

                      Comment


                        #12
                        You could use node red with a Switch node, which you could think of as a Select statement. It takes a variable and branches the flow (program) based on that value. I have written a number of scripts and that can work as well. Node red adds in the ability to connect with items which may not have a plugin. Other options presented are valid as well so I'm sure you are no closer to a decision.
                        Karl S
                        HS4Pro on Windows 10
                        242 Devices
                        56 Z-Wave Nodes
                        37 Events
                        HSTouch Clients: 3 Android, 1 iOS
                        Google Home: 3 Mini units 1 display

                        Comment


                          #13
                          I have no programming experience at all. I forced myself to learn VB.net off the internet because I absolutely needed scripts to do the things I wanted with Homeseer. It was worth the effort.

                          Comment


                            #14
                            Originally posted by TC1 View Post

                            I thought about this a lot.... and I still can't understand why anyone would need if-then-else in home automation. Either the event should trigger (and execute its actions) or it shouldn't.

                            Could you explain a use-case where if-then-else is needed?
                            Here is one scenario. If anybody has a better solution I am all ears. I have an HSTouch Designer project where I can select different audio zones. I created a virtual device that tracks the selected audio zone. Then on my HSTouch screen I have +/- buttons to increase/decrease the volume, <> buttons to go back or forward a song, etc. So I could create individual events that do something like "If audio source = xxx then do yyy". That means I have to create #OfSource * #OfActions events. With 8 audio zones and 8 different actions (I might add more) that's 64 events. If I had if-then-else statements then I only need to create 8 events with "If audio zone = xxx then". That an order of magnitude fewer events!!!

                            Comment


                              #15
                              Originally posted by mulu View Post

                              Here is one scenario. If anybody has a better solution I am all ears. I have an HSTouch Designer project where I can select different audio zones. I created a virtual device that tracks the selected audio zone. Then on my HSTouch screen I have +/- buttons to increase/decrease the volume, <> buttons to go back or forward a song, etc. So I could create individual events that do something like "If audio source = xxx then do yyy". That means I have to create #OfSource * #OfActions events. With 8 audio zones and 8 different actions (I might add more) that's 64 events. If I had if-then-else statements then I only need to create 8 events with "If audio zone = xxx then". That an order of magnitude fewer events!!!
                              I get it now, thanks for taking the time to explain. Since I've never done an HSTouch project I can't offer any useful insights.

                              Can you give an example that doesn't involve HSTouch?

                              Comment

                              Working...
                              X