Announcement

Collapse
No announcement yet.

HSTouch - unique command per client / user?

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

    HSTouch - unique command per client / user?

    I'd love to have a dashboard that shows all 6-8 tablets / clients by state (CONNECTED / DISCONNECTED) as well as last check-in time (10-minute regular check in?) and then be able to launch corrective actions if one is not responding.

    I haven't ever found a way to uniquely identify each tablet on the inbound command. In my perfect world, that might be a unique command per client by using the client name or user name of the client as part of an Event called? Or... something like that? Could potentially be an outbound web GET that I'd send to HS as a command. Could somehow use Tasker to do it. I'm open to any ideas!

    Ultimately, I want to assure that all tablets are actively responding - current status of whatever they're displaying - without randomly restarting them to assure it.


    #2
    Just had a thought on this... since I can tell HS to simulate pushing of a button - even on a screen that isn't showing - I think I could build a unique button for each tablet/client and send an event command to simulate pushing of each button, thus resetting a timer or variable or virtual device in HS. Assuming HST won't respond to this request when it's not responding... hm... a thought, at least?

    Comment


      #3
      HS events have an action "HSTouch Actions", "Simulate a Press of an Element". This can be defined per client or all clients. To make it easy I would just do it for all clients. You can set up a reoccurring timer that keeps doing this. Then the clients respond to that by triggering an event on the HS side which resets another timer, this time a timer for each client. If the timer reaches a certain value because it hasn't been reset then reset the client. I am not quite sure how that reset works, though.

      Comment


        #4
        I use Tasker for this. I have Tasker set a virtual HS switch to what the battery charge level is (0-100%), set to update when the battery level changes. If the battery is not 100%, I know that power has been lost to the tablet. Each tablet's Tasker code is set to update a different virtual switch, so I know which tablet the battery report is from.

        As far as tracking which tablets are online, I use the HS SpeakerClient call to determine if a specific tablet is online. It did require a little bit of scripting though.

        Comment


          #5
          Originally posted by mulu View Post
          HS events have an action "HSTouch Actions", "Simulate a Press of an Element". This can be defined per client or all clients. To make it easy I would just do it for all clients. You can set up a reoccurring timer that keeps doing this. Then the clients respond to that by triggering an event on the HS side which resets another timer, this time a timer for each client. If the timer reaches a certain value because it hasn't been reset then reset the client. I am not quite sure how that reset works, though.
          Yes! This is exactly what I did. It works. Using really short timers now... gotta dial in the right duration.

          Comment


            #6
            Originally posted by aa6vh View Post
            I use Tasker for this. I have Tasker set a virtual HS switch to what the battery charge level is (0-100%), set to update when the battery level changes. If the battery is not 100%, I know that power has been lost to the tablet. Each tablet's Tasker code is set to update a different virtual switch, so I know which tablet the battery report is from.

            As far as tracking which tablets are online, I use the HS SpeakerClient call to determine if a specific tablet is online. It did require a little bit of scripting though.
            I like the battery level idea. I'll add that info to my monitor list as well. Thank you.

            I'm am truly terrible with scripts... but I seem to have time now, so... care to share something from them? I wonder if Android tablets show up with the same speaker client info? Or is there a way in a script to see which HSTouch clients are online - similar to when using HST Designer?

            Comment


              #7
              Originally posted by gregoryx View Post
              I'm am truly terrible with scripts... but I seem to have time now, so... care to share something from them? I wonder if Android tablets show up with the same speaker client info? Or is there a way in a script to see which HSTouch clients are online - similar to when using HST Designer?
              I can show the script next time I am near my HS server. But in the meantime: I use the "hs.GetInstanceList()" call to return a comma separated list of host:instance names for the speaker clients online (the "Instance Name" is set on the tablet as part of HS Touch settings). Then just do a search of the returned string to see if your client name is in the string.

              Comment


                #8
                Originally posted by gregoryx View Post

                I like the battery level idea. I'll add that info to my monitor list as well. Thank you.

                I'm am truly terrible with scripts... but I seem to have time now, so... care to share something from them? I wonder if Android tablets show up with the same speaker client info? Or is there a way in a script to see which HSTouch clients are online - similar to when using HST Designer?
                Another way might be to use a log monitor and watch for speaker clients connecting/disconnecting.
                -Wade

                Comment


                  #9
                  As promised:

                  This is the code I use. It sets a virtual switch to on or off depending if the tablet is online. (SetVirtual is a separate subroutine that does the ICAP calls to change the switch values.)

                  Code:
                  Public Sub PollClients(ByRef parms As Object)
                    Dim sSpeakers As String, sVName(4) As String, sCName(4) As String
                    Dim sColor As String, sNewColor As String, I As Integer = 0, iRef As Integer
                    sSpeakers = "Tblt-tab10a,Tblt-tab10b,Tblt-note8,Tblt-note10,Tblt-firehd8a"
                    sVName = sSpeakers.Split(",") ' The Virtual Switch Names that reflect the Tablet state
                    sSpeakers = "TAB A 10,TAB10B,NOTE 8,NOTE10,FIREHD8A"
                    sCName = sSpeakers.Split(",") ' Their corresponding Speaker Client Names
                    sSpeakers = hs.GetInstanceList()
                    Do While I < 5
                      iRef = hs.GetDeviceRefByName(sVName(I))
                      If iRef > 0 Then
                        sColor = "on"
                        If hs.DeviceValue(iRef) = 0 Then sColor = "off"
                        sNewColor = "off"
                        If sSpeakers.Contains(sCName(I)) Then sNewColor = "on"
                        If sColor <> sNewColor Then
                          hs.WriteLog("Tablet Poll", "Changing " + sVName(I) + " to " + sNewColor)
                          SetVirtual(sVName(I), sNewColor)
                        End If
                      Else
                        hs.WriteLog("Tablet Poll", "Device not found: " + sVName(I))
                      End If
                      I = I + 1
                    Loop
                  End Sub

                  Comment


                    #10
                    Originally posted by aa6vh View Post
                    As promised:

                    This is the code I use. It sets a virtual switch to on or off depending if the tablet is online. (SetVirtual is a separate subroutine that does the ICAP calls to change the switch values.)
                    Thank you, . I'll try to make sense of it. Good a time as any try to learn it again... 🙄🤣

                    Comment


                      #11
                      Originally posted by cc4005 View Post

                      Another way might be to use a log monitor and watch for speaker clients connecting/disconnecting.
                      Well, shoot... never thought of that. UltraLog should work. I'll look for that as well. Thank you, Wade

                      Comment


                        #12
                        A while back, I asked HS tech support for a system variables with client name and current screen. They initially said that shouldn't be too difficult and they'd get back to me.

                        Two weeks later they said "Sorry, not at this time."

                        There's a workaround using the above hs.GetInstanceList() and I created hidden text fields with client name and current screen that get passed through to scripts that then update virtual devices for client names and screen they're on. It took some work, but I can now control behaviors based on what tablet calls what process, and can track where they are at any given time.

                        Here's what the client control interface looks like:

                        Click image for larger version

Name:	Client Control Screen.png
Views:	216
Size:	354.0 KB
ID:	1374325

                        And the main screen when client status is enabled:

                        Click image for larger version

Name:	Main Screen with Client Status.png
Views:	213
Size:	875.6 KB
ID:	1374326

                        Comment


                          #13
                          jgreenberg01 , that looks like exactly what I'm trying to build. And I've been asking for those variables for years now, as well. I re-visited it recently after getting Tasker working and thinking maybe I'd be able to use Tasker to help it happen. Then I get the above idea of looking in the logs... which is so genius because the logs seem pretty consistent? But only in testing. We'll see how they do if a tablet drops off.

                          So... can you elaborate on how this GetInstatanceList concept works? Maybe a sample script and/or event?

                          It looks to me like the first screen is showing exactly what I had initially envisioned: knowing what screen each client is on and such.

                          What do you mean by, "main screen when client status is enabled"? Would it look different without client status? Or are you just referring to the list of clients down the left side?

                          And... lest I forget... THANK YOU. So cool to know I'm not the only one thinking we should be able to "manage" the client devices better. 🙄

                          Comment


                            #14
                            Apologies, the "enabled" comment was confusing - it's not a built-in HS function. In my case, I don't need or want all users to have access to this information, so I can control access to those screens based on client or user.

                            The need arose back when I initially created my security alarm system and I wanted the disarm keypad to only pop up on specific tablets. At first, I had different versions of HSTouch screens for individual clients. That became cumbersome real fast as the number of client devices increased.

                            Once I figured out the workaround, I came up with all sorts of uses, some examples from the client control screen I shared in the earlier post:
                            • Which tablets should chime when a perimiter door/window opens
                            • Which tablets will boot up with, and use the alternate LCARS screens (yeah, I'm a sci-fi geek)
                            • Which tablets will control media by default, eg: I can say "Alexa, source TV", or source bluray, or source game, etc. The "media enabled" tablets will jump to the appropriate screen, as will the TV.
                            • The original alarm system control
                            • And of course which ones are logged on and what screen they're on
                            • Another function not shown is: I want to know know if a client access any of the camera screens. There's a script that will send an alert, via pushover and SMS to my phone with who, when, & what screen. The toggle for that function is on a different screen for user management.

                            I have a whole bunch of virtual devices that define what clients can/can't do - they evolved over time as I added functionality - and individual tablet access to each function is toggled from the client control screen above.

                            The reason I am explaining the history, is because, while you asked for a simple script, I'm going to share the current one in use which actually handles several things. It may be hard to follow, especially because I never went back and cleaned it up after about a bazillion revisions, but I'll answer any questions. It runs every 8 seconds to check for new logons or drop offs:

                            Code:
                            'HS3 Script 2019-01-01  JG
                            Sub Main(ByVal parm As Object)
                            
                                Dim CurrentTablets, i, T
                                Dim TabName, Tabname1
                                Dim CurrentTablet, CurrentTabletN, CurrentTabletL, CurrentTabletLCARS, CurrentTabletName, CurrentTabletLogged, CurrentTabletOff, CurrentTabletScreen
                                Dim TStatus(8) ' TStatus holds client logged status: 0 = Not connected, 1 = Connected, 2 = New Connection (for opening LCARS screen)
                                TStatus(0) = 0
                                TStatus(1) = 0
                                TStatus(2) = 0
                                TStatus(3) = 0
                                TStatus(4) = 0
                                TStatus(5) = 0
                                TStatus(6) = 0
                                TStatus(7) = 0
                            
                                CurrentTablets = hs.GetInstanceList
                                i = 0
                            
                                Dim TabletArray() as String = Split(CurrentTablets,":") ' Load the clients to TabletArray
                            
                                For Each P As String In TabletArray   ' strip out the server name to get just the tablet name for each logged in client
                                    If String.IsNullOrEmpty(P) Then Continue For
                                        TabName = TabletArray(i)
                                        TabName1 = TabName.split(",")
                            '            hs.writelog("Clients", CStr(" Tablet" & i & ": ") & TabletArray(i) & " truncated: " & TabName1(0))
                                        T = 0
                                        Do While T < 9
                                            CurrentTabletN = "Tablet" & T & "Name"
                                            CurrentTabletL = "Tablet" & T & "LCARS"
                                            CurrentTabletName = hs.DeviceStringByName(CurrentTabletN) ' Get current tablet name
                                            CurrentTabletLogged = hs.DeviceValueByName(CurrentTabletN) ' Get Current tablet logged on/off value
                                            CurrentTabletLCARS = hs.DeviceValueByName(CurrentTabletL) ' Get Current tablet LCARS on/off value
                                            If CurrentTabletName = TabName1(0)
                                                If CurrentTabletLogged = 0 
                                                    CurrentTabletScreen = "Tablet" & T & "Screen"
                                                    TStatus(T) = 2 ' this client was previously not connected
                                                    hs.SetDeviceStringByName(CurrentTabletScreen,"Floor Plan Screen",True)
                                                    If CurrentTabletLCARS = 100
                                                        ' The newly logged client's LCARS default is yes (100), so let's open the LCARS start screen
                                                        hs.PluginFunction("HSTouch Server", "", "ClientAction", New Object() {70, "Android" & ":" & TabName1(0), "LCARS Main", ""})
                            '                            hs.PluginFunction("HSTouch Server", "", "ClientAction", New Object() {70, "iPad" & ":" & TabName1(0), "LCARS Main", ""})
                                                        hs.writelog("Clients", CStr(" New LCARS Log On: " & CurrentTabletName))
                                                        hs.SetDeviceStringByName(CurrentTabletScreen,"LCARS Main",True)
                                                    End If
                                                Else
                                                    TStatus(T) = 1 ' this client was already connected, flag so the virtual device does not change to logged off
                                                End If
                                                hs.SetDeviceValueByName(CurrentTabletN,100)
                                                CurrentTabletOff = "Tablet" & T & "Screen"
                                                hs.SetDeviceValueByName(CurrentTabletOff,100)
                            '                    hs.writelog("Clients", CStr(" Tablet" & T & ": ") & CurrentTabletName & " Match: " & TabName1(0))
                                            Else
                            '                    hs.writelog("Clients", CStr(" Tablet" & T & ": ") & CurrentTabletName & " No Match: " & TabName1(0))
                            
                                            End If
                                            T = T + 1
                                        Loop                
                                        i = i + 1
                                Next
                            
                                hs.SetDeviceStringByName("CurrentClients",CurrentTablets,true)
                            
                                ' All the logged on clients have been marked, now let's go back and show the unlogged clients as such
                                T = 0
                                Do While T < 8
                                    If TStatus(T) = 0
                                        ' This client was not logged on, so show it off in virtual device
                                        CurrentTabletN = "Tablet" & T & "Name"
                                        CurrentTabletOff = "Tablet" & T & "Screen"
                                        CurrentTabletName = hs.DeviceStringByName(CurrentTabletN) ' Get current tablet name
                            '            hs.writelog("Clients", CStr(" Tablet: " & CurrentTabletName & " has been logged off"))
                                        hs.SetDeviceValueByName(CurrentTabletN,0)
                                        hs.SetDeviceValueByName(CurrentTabletOff,0)
                                        hs.SetDeviceStringByName(CurrentTabletOff,"Offline",True)
                                    End If
                                    T = T + 1
                                Loop
                            
                            End Sub
                            The script simply checks for logons, flags which ones are on/off, and sets up whether or not they are an LCARS client for use in other scripts.

                            I hope that helps, but I'm sure it's all clear as mud...

                            Comment


                              #15
                              Originally posted by jgreenberg01 View Post
                              Apologies, the "enabled" comment was confusing - it's not a built-in HS function. In my case, I don't need or want all users to have access to this information, so I can control access to those screens based on client or user.

                              The need arose back when I initially created my security alarm system and I wanted the disarm keypad to only pop up on specific tablets. At first, I had different versions of HSTouch screens for individual clients. That became cumbersome real fast as the number of client devices increased.

                              Once I figured out the workaround, I came up with all sorts of uses, some examples from the client control screen I shared in the earlier post:
                              It looks like your code does pretty much what mine does, except with a few embellishments. Same concept though.

                              I am still confused on how you prevented "tablet X" from accessing the alarm panel screen. Do you just brute force each of the "authorized" tablets to switch to the alarm screen (and leave the others untouched), or is it something else?

                              The problem I have found is there is no good way for the server to know which tablet actually made the request (and that is the enhancement we all want). My use of Tasker on the tablet (which can differentiate) is only a partial solution.

                              Comment

                              Working...
                              X