Announcement

Collapse
No announcement yet.

Detect when new project is deployed?

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

    Detect when new project is deployed?

    Has anyone figured out a way to detect when a new project is deployed to a client? I've got some event logic I'd like to trigger when a project is first loaded.

    #2
    Any of you HS3Touch gurus have an answer to determining if a project has been deployed to a client? How about a related question - Can you retrieve the Text assigned to a control/element from HS3?

    Comment


      #3
      Originally posted by mterry63 View Post
      Can you retrieve the Text assigned to a control/element from HS3?
      I don't understand your question. Can you give an example? How is the text assigned?

      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #4
        Sorry for the lack of context, I'll try to fill in a bit. The question is related to several threads on the board about having a single project for multiple clients, and recognizing/tracking the clients state individually once deployed/connected.

        Using jon00's log monitor the client connection process is pretty straightforward to tie the 2 events together, e.g. a client connected, which client was it, so you can setup the logic to id and track the client. Since the client name and connected event are tied in the log, no issues there. Event logic is used to set a hidden text control to unique client IDs once the client connects. I also have some devices for tracking what screen the client is on. I guess the general idea is that HS3 can track some sort of "state machine" for the client.

        Then I realized that if you have several clients connected and have setup tracking and states, what happens if you deploy an updated project to one of the clients? The text control is wiped out back to the project default and the screen tracking is no longer accurate if the client wasn't on the "IsMain" screen. The client stays connected during the project deployment, so the trick of using the log event doesn't apply. So I was trying to envision a way to automatically recover the client with the ID, and screen state without forcing a disconnect/reconnect.

        I actually buckled down after I posted and figured out how to make it recover automatically after a project deployment, one of the key components was evaluating the text of a HS3Touch control from HS3.

        So to answer you question, Say I've created a text box (control type HS_Label) with a static text of 0 (zero). After deploying the project, the text box has the text changed to 1234 by an HS3 event, which is the assigned client ID. Now I want to be able to evaluate if the text is 0 (which would happen on another project deployment) or 1234 (no project deployment).

        I realize this is making the client and HS3 event engine a little more tightly coupled than was probably originally conceived, but people have been able to make HS3Touch do a lot it wasn't really scoped for.


        Comment


          #5
          Sounds like a great project, but beyond both my needs and experience. Thanks for the insights though. I'm betting that it's great fun to push against the limits of the capabilities.
          Mike____________________________________________________________ __________________
          HS3 Pro Edition 3.0.0.548, NUC i3

          HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

          Comment


            #6
            Originally posted by mterry63 View Post
            Any of you HS3Touch gurus have an answer to determining if a project has been deployed to a client? How about a related question - Can you retrieve the Text assigned to a control/element from HS3?
            A couple of thoughts:

            Are you aware of the "[$zipcode]" trick for passing the name of the client to the server?

            For interrogating a client text element, you could always create a "hidden" element that will pass parameters to the server when pressed (or released), then use the pseudo element press (or release) from an event action to press that hidden element.

            Comment


              #7
              I am doing something similar, but using an event to trigger a script to check on client's status and check for new log-ons/log-offs. I had it running every 8 seconds in this video, but upped it to every 4 seconds for use in my new location:

              https://youtu.be/uK1DYlD3ZUg

              Comment


                #8
                Originally posted by aa6vh View Post


                For interrogating a client text element, you could always create a "hidden" element that will pass parameters to the server when pressed (or released), then use the pseudo element press (or release) from an event action to press that hidden element.
                What would that look like? I'm not sure I follow your description.


                Comment


                  #9
                  Originally posted by mterry63 View Post

                  What would that look like? I'm not sure I follow your description.

                  This is my work-araound.

                  I have hidden buttons on a specific HSTouch screen that can be called to "press and release" elsewhere, that pass parameters to a script:

                  Click image for larger version  Name:	Hidden Button.PNG Views:	0 Size:	330.7 KB ID:	1408479

                  This is a script that does a few things, but the larger, bold text is the part that uses the parameters sent from the HSTouch client to act on the information. In this case, virtual devices are updated with client info: Name of client and current screen it's on.

                  The rest of what you see checks to see if users need to be notified (via mms & pushover) when a camera screen is accessed.

                  Code:
                  'HS3 Script 2019-02-01 JG Rev 12-02-2019
                  Sub Main(ByVal parm As Object)
                  
                  ' Get Valid User names and passwords
                  Dim User1Name, User2Name, User3Name, User4Name, User5Name
                  Dim Cam1Name, Cam2Name, Cam3Name, Cam4Name, Cam5Name
                  Dim Cam6Name, Cam7Name, Cam8Name, Cam9Name, Cam10Name
                  
                  Cam1Name = hs.DeviceStringByName("Camera1") 'Get camera names that were set up by owner
                  Cam2Name = hs.DeviceStringByName("Camera2")
                  Cam3Name = hs.DeviceStringByName("Camera3")
                  Cam4Name = hs.DeviceStringByName("Camera4")
                  Cam5Name = hs.DeviceStringByName("Camera5")
                  Cam6Name = hs.DeviceStringByName("Camera6")
                  Cam7Name = hs.DeviceStringByName("Camera7")
                  Cam8Name = hs.DeviceStringByName("Camera8")
                  Cam9Name = hs.DeviceStringByName("Camera9")
                  Cam10Name = hs.DeviceStringByName("Camera10")
                  
                  Dim myTime as Date = Now
                  
                  Dim TabName, ScreenName, TabletName, TabletScreen, TName, strTo, strFrom, strSubject, strMessage
                  strFrom = "Info@EyeNetAutomationSystems.com"
                  strSubject = "Cam View Alert" ' message title
                  
                  [SIZE=18px][B]TabName = parm(1).ToString ' Get tablet name from HSTouch
                  ScreenName = parm(0).ToString ' Get screen name from HSTouch
                  TabletName = TabName & "Name"
                  TabletScreen = TabName & "Screen"
                  TName = hs.DeviceStringByName(TabletName)
                  
                  hs.SetDeviceStringByName(TabletScreen,ScreenName,true) 'Set client virtual device to current screen
                  hs.SetDeviceValueByName(TabletName,100) 'Flag client as logged on
                  strMessage = CStr("Tablet " & TName & " now on screen: "& ScreenName & " at " & myTime.ToLongTimeString)
                  hs.writelog("HSTouch", strMessage)[/B][/SIZE]
                  
                  If ScreenName = Cam1Name or ScreenName = Cam2Name or ScreenName = Cam3Name or ScreenName = Cam4Name or ScreenName = Cam5Name or ScreenName = Cam6Name or ScreenName = Cam7Name or ScreenName = Cam8Name or ScreenName = Cam9Name or ScreenName = Cam10Name or ScreenName = "Camera Screen" Then
                  Dim UNotify, UN, UCarrier, UC, UPhone, UP, P, TN, TName1
                  P = 1
                  Do While P < 6 'Go through all 5 users to check for Text Alert 2 (Cam screen notify)
                  UN = "User" & P & "TextAlert2"
                  UNotify = hs.GetINISetting("Users", UN, "", "EyeNet.ini") 'Get user text alert flag 2 (notify when camera screens accessed)
                  If UNotify = "Yes" Then 'Concatenate string to properly send MMS message to appropriate phone number and carrier
                  TN = "Tablet" & P & "Name"
                  TName1 = hs.DeviceStringByName(TN)
                  UC = "User" & P & "Carrier"
                  UCarrier = hs.GetINISetting("Users", UC, "", "EyeNet.ini") 'Get user cell carrier (to append proper email address)
                  UP = "User" & P & "Phone"
                  UPhone = hs.GetINISetting("Users", UP, "", "EyeNet.ini") 'Get user phone number
                  If UCarrier = "ATT" Then
                  strTo = CStr(UPhone & "@text.att.net")
                  End If
                  If UCarrier = "Verizon" Then
                  strTo = CStr(UPhone & "@vtext.com")
                  End If
                  If UCarrier = "Sprint" Then
                  strTo = CStr(UPhone & "@messaging.sprintpcs.com")
                  End If
                  If UCarrier = "T-Mobile" Then
                  strTo = CStr(UPhone & "@tmomail.net")
                  End If
                  If UCarrier = "Google Fi" Then
                  strTo = CStr(UPhone & "@msg.fi.google.com")
                  End If
                  hs.SendEmail(strTo, strFrom, "", "", strSubject, strMessage, "")
                  hs.WriteLog("Camera", CStr(TabName & " is viewing: " & ScreenName))
                  Dim pushoverParams(8) As Object
                  pushoverParams(0) = "All Clients" 'Device/Group - must matched with a device name already in the plugin or 'All Clients' CASE SENSITIVE
                  pushoverParams(1) = strMessage 'Message Body
                  pushoverParams(2) = "EyeNet Automation Camera Alert" 'Message Title
                  pushoverParams(3) = "normal" 'low/normal/high/emergency
                  pushoverParams(4) = Nothing 'Message Sound - must match from list already in HomeSeer
                  pushoverParams(5) = Nothing 'Message URL
                  pushoverParams(6) = Nothing 'Message URL Title
                  pushoverParams(7) = Nothing 'API String
                  pushoverParams(8) = Nothing 'Attachment
                  hs.PluginFunction("Pushover 3P", "", "Pushscript", pushoverParams)
                  End If
                  P = P + 1
                  Loop
                  End If
                  
                  End Sub
                  '0 = AT&T: @text.att.net
                  '1 = Verizon: @vtext.com (or @vzwpix.com for photos and video)
                  '2 = Sprint: @messaging.sprintpcs.com
                  '3 = T-Mobile: @tmomail.net
                  '4 = Google Fi: @msg.fi.google.com
                  Hope that makes sense.

                  Comment


                    #10
                    Thanks for the details. How do you set the TabletID and CurrentScreen elements in HSTouch? I'm assuming TabletID is done once every time the project is deployed, but CurrentScreen would have to be dynamically maintained.

                    Always interesting to learn from other peoples approaches.

                    Comment


                      #11
                      Originally posted by mterry63 View Post
                      Thanks for the details. How do you set the TabletID and CurrentScreen elements in HSTouch? I'm assuming TabletID is done once every time the project is deployed, but CurrentScreen would have to be dynamically maintained.

                      Always interesting to learn from other peoples approaches.
                      Like I mentioned in an earlier post, you can use the "[$zipcode]" trick to fill in the TabletID element automatically.

                      Comment


                        #12
                        Originally posted by mterry63 View Post
                        Thanks for the details. How do you set the TabletID and CurrentScreen elements in HSTouch? I'm assuming TabletID is done once every time the project is deployed, but CurrentScreen would have to be dynamically maintained.

                        Always interesting to learn from other peoples approaches.
                        You are correct, I have a hidden field with the TabletID that I change when I deploy the project. I wish I had thought of aa6vh's $zipcode idea way back when - that would have saved some coding!

                        You are alos correct about CurrentScreen parameter. That hidden text element is changed each time a button is pressed to change screens. It's a bit of work, but it was the only solution I could come up with

                        Comment

                        Working...
                        X