Announcement

Collapse
No announcement yet.

Show Event Absolute Time in Text item

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

    Show Event Absolute Time in Text item

    Hello all,

    I want to place the trigger time for an event on a screen. I have tried various methods but can't seem to get it to work. If I have to use a script, I want to pass the name if the event so I can reuse it for other items. Also, I believe I read that scripts run every so many seconds. I would want this one to run only on screen open if possible as my intention is to change the value and write it back to the event.
    Karl S
    HS4Pro on Windows 10
    1070 Devices
    56 Z-Wave Nodes
    104 Events
    HSTouch Clients: 3 Android, 1 iOS
    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

    #2
    So I was able to do this by creating a virtual device representing the event absolute time and setting the string value to the time such as 16:30. I then have a script that reads the device string and set the event time to that value. This is called by an event that occurs when the virtual device is set to any status. In HStouch I just set the item's StatusTracking to the virtual device.

    The script works with a manually triggered event. I pass the time to the script using the optional parameters: ("Main","14:00")

    When I try to pass values in HSTouch to the same script, I get an error about converting 'System.String[]' to 'System.String' Here is my code. All I want to do is pass a value from an element on a HStouch screen.

    Code:
    Sub Main(parm as String)
    
    Dim NewTime as String
    
    NewTime = parm
    
    hs.writelog("", "Passed Value: " & NewTime)
    
    hs.SetDeviceString ("v20", NewTime)
    
    End Sub
    I have tried many things including:
    • Sub Main(ByVal parm as string)
    • Sub Main(parm as object)
    • Sub Main(ByVal parm as object) - Different error and wrong value read
    • NewTime = parm
    • NewTime = parm(0)


    Any ideas as to what is needed to make the types match or how this should be written to take the value of an element and use it to set the new time?
    Karl S
    HS4Pro on Windows 10
    1070 Devices
    56 Z-Wave Nodes
    104 Events
    HSTouch Clients: 3 Android, 1 iOS
    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

    Comment


      #3
      parm(0) should contain the element's value, as long as it just a plain text object in HSTouch.
      I know that NewTime = parm should throw an error, but not sure why NewTime = parm(0) doesnt work.

      Can you replace your script with:
      PHP Code:
      Sub Main(ByVal parm as Object)
      hs.writeLog("debug","[" parm(0) & "]")
      End Sub 
      and let's see what is coming across. We need to make sure it's indeed a text object and not some type of list value. Also, in your HSTouch setup, are you sure it's setup to send over the right element?

      Also, I have a video that shows how to pass an element's value to a script:
      http://board.homeseer.com/showthread.php?t=153797
      Last edited by rmasonjr; May 8, 2013, 03:17 PM. Reason: added link to video
      HS4Pro on a Raspberry Pi4
      54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
      Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

      HSTouch Clients: 1 Android

      Comment


        #4
        Interesting.

        I made the change. When I use the Event, the log has:
        debug [1]
        When the Optional parameters setting is:
        ("Main","14:00")

        And when I test the HStouch screen using the Windows Client, I get
        debug [9:00]
        debug [Patio Light]
        9:00 is the value of the element NewStartTime, and what I want. "Patio Light" is nothing on the current screen. The Action Editor shows ScriptParameter1 as having NewStartTime selected. When I select this, it is coming from the list box and starts with the active screen's name "Crock Pot"

        "Patio Light" is the Text in a button I placed with a Name of Label on the main screen. I renamed it to PatioLight and still get the same. And No, the Text value of NewStartTime is not "Patio Light" but "9:00" I do open the screen in question on top of the main screen.
        Karl S
        HS4Pro on Windows 10
        1070 Devices
        56 Z-Wave Nodes
        104 Events
        HSTouch Clients: 3 Android, 1 iOS
        Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

        Comment


          #5
          Ok - let's try this and see if we are getting some list of values:

          PHP Code:
          Sub Main(ByVal parm as Object)
          dim x as integer

          for x=0 to parm.Length-1
          hs
          .writeLog("debug","parm(" ")=[" parm(x) & "]")
          next x

          End Sub 
          I'm just typing this code in, so not sure if the syntax is good. We are trying to dump out everything in parm regardless of the length.
          HS4Pro on a Raspberry Pi4
          54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
          Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

          HSTouch Clients: 1 Android

          Comment


            #6
            Changing the script to:
            Code:
            Sub Main(ByVal parm as Object) 
            hs.writeLog("debug","[" & parm(1) & "]") 
            End Sub
            Gives me "[4]" from the event (meaning each character is passed as 1 item in an array?)
            And from HStouch I get an error that the Indexis outside the array.
            Karl S
            HS4Pro on Windows 10
            1070 Devices
            56 Z-Wave Nodes
            104 Events
            HSTouch Clients: 3 Android, 1 iOS
            Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

            Comment


              #7
              The second script gives me:

              From the Event:
              debug parm(4)=[0]
              debug parm(3)=[0]
              debug parm(2)=[:]
              debug parm(1)=[4]
              debug parm(0)=[1]

              And from HStouch I get the same as before:
              debug parm(0)=[9:00]
              debug parm(0)=[Patio Light]
              Karl S
              HS4Pro on Windows 10
              1070 Devices
              56 Z-Wave Nodes
              104 Events
              HSTouch Clients: 3 Android, 1 iOS
              Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

              Comment


                #8
                I figured out why HStouch was appearing to run the script twice. I apparently set the ActionsWhenPressed to run the script and somehow selected the Patio Lights button. The correct value is being passed under the ActionsWhenReleased action. Now to just get the values formatted properly...
                Karl S
                HS4Pro on Windows 10
                1070 Devices
                56 Z-Wave Nodes
                104 Events
                HSTouch Clients: 3 Android, 1 iOS
                Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                Comment


                  #9
                  OK, so I do not think I will be using this script in an event in HomeSeer, but only via HStouch, so I am not writing a check in for the two scenarios. I had it as an event for easy checking. This is now working in HStouch:

                  Code:
                  Sub Main(ByVal parm as Object) 
                  
                  Dim NewTime as String
                  
                  NewTime = parm(0)
                  
                  hs.writelog("", "Passed Value: " & NewTime)
                  
                  hs.SetDeviceString ("v20", NewTime)
                  
                  NewTime = Replace(NewTime, ":", "")
                  hs.SetDeviceValue ("v20", NewTime)
                  
                  End Sub
                  Setting the Device Value runs a second script that then changes an even't start time, which is a HomeSeer Event.

                  Thank you for all your help!

                  Karl
                  Karl S
                  HS4Pro on Windows 10
                  1070 Devices
                  56 Z-Wave Nodes
                  104 Events
                  HSTouch Clients: 3 Android, 1 iOS
                  Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                  Comment


                    #10
                    excellent! no problem!
                    HS4Pro on a Raspberry Pi4
                    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                    HSTouch Clients: 1 Android

                    Comment


                      #11
                      Ok,, so I have tried many things to show the time as a 12 hour AM/PM format but can't get it to work. I am saving the device string value in a 24 hour format "hh:mm" and trying to convert it to "HH:mm tt" in the display in HStouch but this isn't working out.

                      I tried variations of
                      Code:
                      [$SCRIPT=&hs.DeviceString("v20").ToString("hh:mm tt")]
                      in a Text item's Text Appearance Property.

                      Is it possible to call a hidden text item in a $SCRIPT call like above and do this? I am trying to avoid having multiple devices to do what I need. the bottom line is I want to show and change an event's absolute start time. So I am saving the start time in the string of a device and changing that via a script but for a better acceptance at home, I would like to show the time as 12 hour AM/PM and not 24 hour. Any ideas on how to get this piece?
                      Karl S
                      HS4Pro on Windows 10
                      1070 Devices
                      56 Z-Wave Nodes
                      104 Events
                      HSTouch Clients: 3 Android, 1 iOS
                      Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                      Comment


                        #12
                        Generally, I try to keep away from $SCRIPT whenever possible. It was/is a bit of a resource hog. The way I do it is to create another virtual device for display only. I have a lot of virtual devices with HSTOUCH_ in the name just for display only and enable status tracking when changed. I also take advantage of the same device's value so that I can assign colors in hstouch. It's a bit kludgy in that you have an extra device, but it works ok.

                        In HS3, I hope we can assign even more values to devices for display purposes.
                        Last edited by rmasonjr; May 9, 2013, 11:03 AM. Reason: spelling...
                        HS4Pro on a Raspberry Pi4
                        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                        HSTouch Clients: 1 Android

                        Comment


                          #13
                          I think changed my scripts to work on the Device's Value so everything works with a number, and use the Device String to store the 12 hour time. I guess I would rather jump through this in the code than add another device that is nothing more than a variable. Maybe we can get Variables for each HStouch page as opposed to using a hidden Text item.

                          I am just trying to limit the number of devices I have that are nothing more than variables for scripts or HStouch. I am doing this by using the Value and String properties of an item to give me 2 variables. I would also like to use the Status as a third variable to display alternate text, but it appears that the method you show in your sample video to do this does not work when I have set the Value and String properties. I have the StatusTrackingNormal set to the Device and alternate text being set for valid property settings of the associated settings. The text that appears is the the same as the Value if I select Use Value, and the Status if I select Use Status Text. If I select Use Status Image I cannot define any text. So since I have custom settings for these Device Properties, the test for alternate text (StatusColors MatchMode) apparently fails. It appears this method uses the Value and String properties of the Device and not the actual Status setting. Does this seem right?
                          Karl S
                          HS4Pro on Windows 10
                          1070 Devices
                          56 Z-Wave Nodes
                          104 Events
                          HSTouch Clients: 3 Android, 1 iOS
                          Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                          Comment


                            #14
                            I've had better luck with matching on DeviceValue and changing font colors based on that.
                            DeviceStatus is a little buggy and is going away in HS3 anyway, so I wouldnt use it.
                            HS4Pro on a Raspberry Pi4
                            54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                            Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                            HSTouch Clients: 1 Android

                            Comment

                            Working...
                            X