Announcement

Collapse
No announcement yet.

Passing Disarm code from HSTouch to DSC Plugin

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

    Passing Disarm code from HSTouch to DSC Plugin

    Hello,
    I am new to writing scripts and I have created an HSTouch screen where I can have someone type in their alarm code to arm/disarm the system, then saves it in parm(0) and then passes it to the script. I wondered if you could take a quick look at it to make sure I'm doing this correctly. I'm using the code Spud had in the DSC user guide.

    I've attached below a screen where I pull in the code from an HSTouch element and then run the below script:

    Sub Main(ByVal parm As Object)
    Dim inputcode
    inputcode = parm(0).ToString 'Gets input code from HST
    hs.PluginFunction("EnvisaLink", "", "SendKeystrokeString", new object[] { 1, inputcode]);return 0;

    End Sub
    Attached Files
    HS4 4.2.6.0 &HSTouch Designer 3.0.80
    Plugin's:
    BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee, Nest, AK Bond
    EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
    weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave

    #2
    I don't know if this is it, but it looks like your curly brace is closed with a square bracket:

    { 1, inputcode]

    Comment


      #3
      also, the example from the user guide is a C# script, here you are using VB, so I think the call to the plugin function should be:

      Code:
      hs.PluginFunction("EnvisaLink", "", "SendKeystrokeString", new Object() { 1, inputcode})

      Comment


        #4
        Originally posted by spud View Post
        also, the example from the user guide is a C# script, here you are using VB, so I think the call to the plugin function should be:

        Code:
        hs.PluginFunction("EnvisaLink", "", "SendKeystrokeString", new Object() { 1, inputcode})
        Thank you for the help! I've attached what I believe to be a vb script that includes all the above.
        Attached Files
        HS4 4.2.6.0 &HSTouch Designer 3.0.80
        Plugin's:
        BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee, Nest, AK Bond
        EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
        weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave

        Comment


          #5
          Thank you for this Script! , I have never tried using script before, but needing to get this working. I have entered the script. Now presently
          I have a button in HStouch desinated "ARM" for partition 1, previously the "when released" action was arming partiton 1. how do I change
          this so as to run this script and arm partition 1?

          Comment


            #6
            My script stopped working but here is what I had before. I am trying to get this to work again this weekend. I also switched from the HS DSC plugin to Invisalink because I wanted control over bypassing zones which the HS plugin doesn't support.

            const string keypadDeviceName = "Keypad"; //The name of the virtual device that keeps track of the string.
            const string LogID = "Keypad.cs";

            public object Main(object[] Parms)
            {
            return 0;
            }

            //Adds a new digit to our virtual device. When 4 digits are reached then the code
            // will be sent to the panel and the string of the virtual device will be reset.
            void ProcessKey(string value)
            {
            string deviceString = "";

            try
            {
            //Get the current string stored in the virtual device.
            deviceString = hs.DeviceStringByName(keypadDeviceName);
            //Add the new digit.
            deviceString = deviceString + value;
            //Update the virtual device with the new string.
            hs.SetDeviceStringByName(keypadDeviceName, deviceString, true);
            //If the string is 4 digits long then submit the code to the
            // DSC panel and reset the string of the virtual device.
            if(deviceString.Length >= 4)
            {
            Submit(null);
            Clear(null);
            }
            } catch(Exception e)
            {
            throw new System.Exception(string.Format("ProcessKey({0}) failed. Device string is {1}.", value, deviceString), e);
            }
            hs.WriteLog(LogID, "ProcessKey done");
            }

            //Sends the string to the DSC panel.
            public void Submit(object args)
            {
            string[] deviceString = null;

            try
            {
            deviceString = new string[1];
            deviceString[0] = hs.DeviceStringByName(keypadDeviceName) + "*";
            hs.PluginFunction("DSC Security", "", "ExecDSC", deviceString);
            }
            catch (Exception e)
            {
            throw new System.Exception(string.Format("Submit failed. Device string is {0}.", deviceString), e);
            }
            }

            //Deletes the string from the virtual device.
            public void Clear(object args)
            {
            try
            {
            hs.SetDeviceStringByName(keypadDeviceName, "", true);
            }
            catch(Exception e)
            {
            throw new System.Exception(string.Format("Clear failed."), e);
            }
            }

            //Deletes the last entered value from the virtual device, i.e. the right most number.
            public void Delete(object args)
            {
            string deviceString = "";
            try
            {
            //Get the current string stored in the virtual device.
            deviceString = hs.DeviceStringByName(keypadDeviceName);
            if (deviceString.Length > 1)
            {
            //The current string has at least two digits. Remove the last digit.
            deviceString = deviceString.Substring(0, deviceString.Length-1);
            }
            else
            {
            //There was either no or just one digit. Since the delete key was pressed
            // there will be no digit left, hence set the string to an empty string.
            deviceString = "";
            }
            //Write the value back to the virtual device.
            hs.SetDeviceStringByName(keypadDeviceName, deviceString, true);
            }
            catch(Exception e)
            {
            throw new System.Exception(string.Format("Delete failed.", deviceString), e);
            }
            }

            public void Key0(object args)
            {
            ProcessKey("0");
            }

            public void Key1(object args)
            {
            ProcessKey("1");
            }

            public void Key2(object args)
            {
            ProcessKey("2");
            }

            public void Key3(object args)
            {
            ProcessKey("3");
            }

            public void Key4(object args)
            {
            ProcessKey("4");
            }

            public void Key5(object args)
            {
            ProcessKey("5");
            }

            public void Key6(object args)
            {
            ProcessKey("6");
            }

            public void Key7(object args)
            {
            ProcessKey("7");
            }

            public void Key8(object args)
            {
            ProcessKey("8");
            }

            public void Key9(object args)
            {
            ProcessKey("9");
            }

            Comment


              #7
              Thanks, Actually, I can not read code. I have entered the code that is in this run per the "Creating a SCRIPT" instructions. I have found the HSTouch
              designer pretty easy to get around but haven't needed to enter script till this issue came up. I could really use all the help I can get to get through this.
              Thank You

              Comment


                #8
                "I have a button in HStouch designated "ARM" for partition 1, presently the "when released" action of this button is arming partition 1. Can you tell me how to enter this event that runs this script
                (Attached Filesrequesting and passing the user code and the function be "Arm partition 1" ? I presently have the script entered as a available event.
                Thank you for your help

                Comment


                  #9
                  +1


                  Devoir

                  Comment


                    #10
                    BJB Sorry, my work load at work has been increasing so I haven't had as much time to respond. I'll do my best to lay out everything, to be honest it's been quite a while since I've set this up so I may accidently leave something out. But I'll do my best to help when I can.

                    I have attached the script to this post that has been working in my system. You will need to download it and make sure that you change the extension ".txt" back to ".vb" and save the file into C:\Program Files\HomeSeer HS4\scripts

                    Also, you will need to setup a user in HS4 for each person that has an alarm code in your DSC system so that you can link the user code in Envisalink to the HS4 user and display their name in Pushover/email etc....

                    In order to setup HSTouch to Arm/Disarm the system with this plugin and have it display who Arm/Disarmed the system, you will need the below screens:

                    1) Setup one of your screens where you would like to have your Arm/Disarm buttons
                    On that screen you will need three buttons. (Disarm, Arm Stay & Arm Away)
                    Click image for larger version

Name:	Alarm buttons.png
Views:	240
Size:	26.3 KB
ID:	1538878

                    a) Disarm Button - Setup this button to Action Type: Show another screen on top of the current screen. and in the Screen field use your Keypad screen. (Keypad screen setup- will show later)
                    Click image for larger version

Name:	Disarm button action.png
Views:	179
Size:	12.2 KB
ID:	1538880

                    b) Arm Stay - Set it up with the below Action.
                    Click image for larger version

Name:	Arm StayAction.png
Views:	185
Size:	12.8 KB
ID:	1538879
                    c) Arm Away - Set it up with the below Action:
                    Click image for larger version

Name:	Arm AwayAction.png
Views:	179
Size:	13.4 KB
ID:	1538881

                    Create your Keypad screen where the user will enter their code that will then be passed from HSTouch to the script. I found these buttons searching the web for number buttons / png.
                    Click image for larger version

Name:	Keypad screen.png
Views:	187
Size:	24.2 KB
ID:	1538882
                    When you create the keypad:
                    1) Setup the Display element first. Create a Text box using the "Text Box" element, not the "Text" element. Then set your properties for that text box to the below.
                    Click image for larger version

Name:	Display properties.png
Views:	178
Size:	29.4 KB
ID:	1538884

                    2) Each numerical button will need to be setup to pass its value to the "Display" element.
                    Click image for larger version

Name:	numberkeysetup.png
Views:	173
Size:	13.2 KB
ID:	1538883
                    3) The "X" button that I have is used to clear the Display screen incase the user enters an incorrect number. Setup with this action:
                    Click image for larger version

Name:	clearbutton action.png
Views:	182
Size:	12.3 KB
ID:	1538885
                    4) The double arrow button is the one I use to pass the entered code to the script and is setup as below: (The second action you see here just closes the screen after it passes the code)
                    Click image for larger version

Name:	enterbutton action.png
Views:	181
Size:	21.3 KB
ID:	1538886

                    I think this should be everything that you will need to get this working with your HSTouch. Let me know how it goes! Good luck!


                    [ATTACH]n1538877[/ATTACH]
                    HS4 4.2.6.0 &HSTouch Designer 3.0.80
                    Plugin's:
                    BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee, Nest, AK Bond
                    EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
                    weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave

                    Comment


                      #11
                      Thank you for going step by step! Sorry for not acknowledging your work sooner "The Profit", I also have been heavily tied up. I was successful in getting all the steps completed, When attempting to Arm or disarm, I see no indication the script is running when I enter the user code. Watching the log, nothing is happening. I do see the script run when I run it via a event that I set up but with errors since no input is associated with the manual event. Do you have an idea of how I could trouble shoot the problem?
                      Thank you
                      BJB

                      Comment


                        #12
                        Originally posted by BJB View Post
                        Thank you for going step by step! Sorry for not acknowledging your work sooner "The Profit", I also have been heavily tied up. I was successful in getting all the steps completed, When attempting to Arm or disarm, I see no indication the script is running when I enter the user code. Watching the log, nothing is happening. I do see the script run when I run it via a event that I set up but with errors since no input is associated with the manual event. Do you have an idea of how I could trouble shoot the problem?
                        Thank you
                        BJB
                        I’m not aware of a way to show in the log when a script runs, but I have an event that triggers when the system has been Armed/Disarmed to send a pushover. In that event, make sure you have a few second wait before the action to send your pushover so that the Envisalink PI has a chance to populate who Armed/Disarmed the system first.

                        After entering your code into HSTouch and pressing your enter button, is your DSC system disarming? Is your “User Access” device showing the name of the user who disarmed the system after the code has been entered into HST?

                        One other thing to note, usually when someone arms the system by pressing the Arm Stay or Away button on the key pad, the “User Access” device will show Armed by system because no personal code is required to arm the system.


                        Sent from my iPad using Tapatalk
                        HS4 4.2.6.0 &HSTouch Designer 3.0.80
                        Plugin's:
                        BLBackup, BLOccupied, BLShutdown, EasyTrigger, Ecobee, Nest, AK Bond
                        EnvisaLink DSC, PHLocation, Pushover, SONOS, Blue Iris, UltraRachio3,
                        weatherXML, Jon00 Alexa Helper, Network Monitor, MyQ, Z-Wave

                        Comment


                          #13
                          "I’m not aware of a way to show in the log when a script runs, but I have an event that triggers when the system has been Armed/Disarmed to send a pushover. In that event, make sure you have a few second wait before the action to send your pushover so that the Envisalink PI has a chance to populate who Armed/Disarmed the system first."

                          The reason I see it in the log when running an the event is that it's an error message.

                          "After entering your code into HSTouch and pressing your enter button, is your DSC system disarming? Is your “User Access” device showing the name of the user who disarmed the system after the code has been entered into HST?"

                          After entering my code into HSTouch and pressing my enter button, the keypad goes away but I cant identify any action going on in the dsc app or the Eyezon web portal.

                          Thank you for taking a look, can you can think of a way to test and see where it is failing? or If I can corral my Grandson over here agian!

                          Comment


                            #14
                            Originally posted by The Profit View Post
                            BJB Sorry, my work load at work has been increasing so I haven't had as much time to respond. I'll do my best to lay out everything, to be honest it's been quite a while since I've set this up so I may accidently leave something out. But I'll do my best to help when I can.
                            <snip>
                            [ATTACH]n1538877[/ATTACH]
                            Originally I had my keypad "simulating" the actual DSC keypad, i.e. no display for the number and no enter key. Also just numbers. However, I really liked yours so I redesigned mine with a display. It also makes the script a lot easier (actually, I could have used a hidden text field). Thanks for this!!

                            Comment


                              #15
                              Hey "mulu", glad to hear you had success with this. I'm still not all the way there, having no response after entering the user code and keypad going away. Did you notice anything that had to be added or changed from "the profit"s step by step description?

                              Comment

                              Working...
                              X