Announcement

Collapse
No announcement yet.

Sending HSTouch client name to HS Script

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by Gerard View Post
    I also need this and started to set it up but have been delayed due to other projects. This is what I had come up with using what is avaliable today. Was also looking at writting a small plugin to make it more automatic.

    Current thoughts

    1) Install log monitor pluin http://board.homeseer.com/showthread.php?p=646405
    2) If you have 5 clients setup 5 buttons on hidden data screen
    3) Setup one text box on data screen named "Client Name"
    4) Set up each buton with action to set a diffent cline name into text box
    5) setup log monitor to trigger on client connect message in log and execute script"client update"
    6) script would send five messages, one to each specific client to press the correct button on that client
    7) Then in your substitution use the contents of "Client Nane"

    You could do this several ways slightly diffrent than this but that was my thoughts. I have not tested this yet.

    Gerard
    I agree with Zimmer62.

    Gerard, you make it work and It could work for me too. But I saw that thread some time ago about using the log monitor plugin and it never make it worked for me. It was too complicated for the time I had to play with this.

    This is simply something that should have been there at the start.

    I too put in a feature request (enhancement) in the new bug tracking system. I asked for the On connect trigger event.

    Comment


      #17
      Sulution to auto put the Computername in txt element

      To (auto)put the the name of the Computer/Tablet in a text element of the client I composed a VBS-script (plus .bat for 64-bit systems)

      You can use that Tabletname as a reference later, calling a HS-script from the client so that HS knows who's calling.

      This works for Windows tablets and has been tested for Windows7 64-bit.

      You have to make one event for each tablet with a name equal to their (Windows) computernames, that triggers a release action of a button on the client. You have as much buttons as there are Tablets.
      That button puts a reference name in a text element.
      (these steps may be obvious for you, I assume)

      Don't forget to remove the txt extension and to change the filelocation to where you put the files.

      The client is started by the VBScript TabletId.vbs or TabletId.bat for 64-bit clients.



      Wait a few second and voila!


      Happy scripting,
      Hammy
      Attached Files

      Comment


        #18

        Comment


          #19

          I have cobbled together a solution that works well using most of the pieces described in this thread, plus the HS3 JSON interface to track client changes of interest to HS3. Using the JSON URL allows leveraging the [$ELEMENT->screen:element] syntax in the project which is replaced with the client ID. Every time something occurs (like pressing a button that changes screens) the following example actions are triggered. Note that the second action is the "generic" glue that allows multiple clients to send separate status to HS3 with a single project file. Each time the second action is executed, a virtual device specific to this client is changed.

          I use this process with local control, but I believe it would work through myhs.homeseer.com as well. You would need to adjust the URLs below to not use a local IP.

          Click image for larger version  Name:	pic1.png Views:	0 Size:	16.1 KB ID:	1392546

          Click image for larger version  Name:	pic2.png Views:	0 Size:	87.3 KB ID:	1392547

          Breaking down the URL http://YOURHS3SERVER/JSON?request=controldevicebyvalue&ref=[$ELEMENT=NotSeen->varClient]&value=1

          YOURHS3SERVER - substitute your IP. Note that JSON control must be enabled on the HS3 Settings->Network Tab

          Click image for larger version  Name:	pic3.png Views:	0 Size:	11.7 KB ID:	1392548

          /JSON?request=controldevicebyvalue&ref= - Standard JSON command to set a device by value. There are other options, but I chose this.

          [$ELEMENT=NotSeen->varClient] - This gets replaced with the text in the element varClient. This is set to a virtual device reference number on client connection.

          &value=1 - This corresponds to the values in the virtual device. You can set a value for each screen the client may display, for example. Here's one of my virtual devices:

          Click image for larger version  Name:	pic4.png Views:	0 Size:	55.3 KB ID:	1392549

          Instead of virtual devices you could easily convert to scripts and global variables for example. I chose the device/event route.
          There are probably other ways to encode the client ID and send it to HS3, but the JSON interface was my choice and seems to work well.


          Basic logic:
          Client connects and triggers an event that sets an element text to the clients virtual device reference ID
          With every client change that needs to be tracked by HS3, the second Action show above is added to the project element action.

          Here are the components:
          Common project with a debug screen holding elements that are used in this process. This screen is never displayed
          Key project elements - text element called varClient, text element called txtJSONMessage, button elements for each potential client with actions to set the client ID in varClient
          Jon00 log monitor to trigger on client connect and disconnect messages
          Clients with different client name in settings
          Virtual devices for each client that holds the screen names and any special states that should trigger events
          Events that trigger on client connect and set a HSTouch screen element to the reference ID of the client virtual device
          Events that trigger on client disconnect

          Details:
          I installed Jon00 log monitor and setup log watching entries that look for client connect and disconnect log messages. Each client must have the client name set differently. In my testing I have clients SamTab2, SamTab3, TP420-1, and Pixel.

          Log Monitor (Free) found here: http://www.jon00.me.uk/index.shtml
          Install and configure the ini file found in the Configs folder in HS3 folder then run log monitor via the startup script. Read the docs!

          Example client settings:
          [Trigger1]
          HSLogging=1
          SearchType="HSTouch Server"
          SearchMessage="TP420-1 has CONNECTED"
          UseRegex=0
          WatchPeriod=0
          TriggerCount=1
          ReTriggerPeriod=1
          EventTrigger="Client Connected - TP420-1"
          ScriptTrigger=
          HSLogTriggerText="TP420 Client Startup Event Executed"
          Logging=0

          [Trigger2]
          HSLogging=1
          SearchType="HSTouch Server"
          SearchMessage="TP420-1 has DISCONNECTED"
          UseRegex=0
          WatchPeriod=0
          TriggerCount=1
          ReTriggerPeriod=1
          EventTrigger="Client Disconnected - TP420-1"
          ScriptTrigger=
          HSLogTriggerText="TP420 Client Shutdown Event Executed"
          Logging=0

          Note that in these configurations the Event names are listed by name. When the Event is triggered, a log entry is displayed with the LogTriggerText above for debug purposes. It's not necessary for the solution to work.

          Event example

          Click image for larger version  Name:	pic5.png Views:	0 Size:	36.3 KB ID:	1392550

          Project Text element configuration for txtJSONMessage

          Click image for larger version  Name:	pic6.png Views:	0 Size:	23.2 KB ID:	1392551
          Click image for larger version  Name:	pic7.png Views:	0 Size:	9.4 KB ID:	1392552
          It may not be necessary to set IsHTML, I didn't try it as False.

          Project file configuration for btnSetClientName

          Click image for larger version  Name:	pic11.png Views:	0 Size:	23.1 KB ID:	1392556
          The critical piece here is the Identification Name, it must match the event configuration. There's probably an easier and cleaner way than building a button for each client, potentially setting the element directly from an event or script. Maybe next time.

          The Actions when pressed are set here:

          Click image for larger version  Name:	pic9.png Views:	0 Size:	141.0 KB ID:	1392554

          In this case 1479 is the reference ID for the HS3 device for this client with the Status Text and graphics configured above.

          The second action

          Click image for larger version  Name:	pic10.png Views:	0 Size:	85.8 KB ID:	1392555

          Sets the device for this client to the setting "Home-Black" which is a cryptic way of saying the home screen for this project with a black background. I switch between Black and White backgrounds during day and night with events.

          At this point, the client has connected, changed the varClient from "blank" to it's client ID and now sends that ID on major changes I want to be aware of. This is independent of other clients running the same project that may have different states.

          Hopefully this is enough to get the idea. This particular project is very simple and just displays some controls for my Patio and pool. It only has 3 screens The concept could be expanded to get very complex. There are a lot of talented and clever examples in the forums of different screens.

          Hope people can expand on this and improve it.

          Attached Files

          Comment


            #20
            On another thread on this same subject, it was discovered that there is an easy way to have the actual tablet name in a text box, for Android and Ipad clients. The solution is to use the tablet's "Zipcode" setting (found on the tablet's setting menu). You can put text in that field. Then in the text element, place into it "[$ZIPCODE]" (without the quotes). The project's global zipcode field should be left blank. Now you can pass that text element as a parameter to a script file.

            Unfortunately for Windows clients, there does not appear to be a zip code setting. Perhaps using the button idea above (or just manually change that text box just before deployment to that windows computer, which is what I do).

            Comment


              #21
              https://forums.homeseer.com/forum/ho...nt#post1390216

              Comment

              Working...
              X