Announcement

Collapse
No announcement yet.

How to enter time in HST?

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

    How to enter time in HST?

    Hi,

    Has anyone created a screen where you can enter a time? (besides using a text-field + the virtual device keyboard)
    (example: an alarmclock)

    - Entering 4 digits (hh:mm)

    DJ

    #2
    Originally posted by DJF3 View Post
    Hi,

    Has anyone created a screen where you can enter a time? (besides using a text-field + the virtual device keyboard)
    (example: an alarmclock)

    - Entering 4 digits (hh:mm)

    DJ
    Yes, see attached. Selection boxes x 2 - only with five minute intervals though...
    Last edited by mrhappy; November 15, 2012, 07:54 AM.

    Comment


      #3
      Nice. A couple of questions..

      The 'list' with hours and minutes.. What type of control is that?

      When you select a number in the list, what's the action?
      (how do you set the time on the right side of the screen)

      When finished, how do you get this info into homeseer?
      (do you run a script or is there another way?)


      Thank you!
      DJ

      Comment


        #4
        Originally posted by DJF3 View Post
        Nice. A couple of questions..

        The 'list' with hours and minutes.. What type of control is that?

        When you select a number in the list, what's the action?
        (how do you set the time on the right side of the screen)

        When finished, how do you get this info into homeseer?
        (do you run a script or is there another way?)


        Thank you!
        DJ
        They are both list boxes, I just drop them onto the page (the backgrounds and selectors are set to transparent) and then insert the values for the times in the List_Labels and List_Values properties in the designer.

        Theres no action as such when you click on the list, what happens is when the button 'Set Alarm' is pressed then a script is called, two parameters are passed to that script being the list box for hours and minutes. The script then does the work about storing the time for the alarm, this is stored in a device and that device is status tracked to the element on the right hand side of the screen.

        The script is then checked every minute to check whether the current time is the one stored in the device which came from HSTouch. If the time is the same then something is done about it (set a device, play wave file, play the radio etc etc)...

        Give me a shout if you want the script or I ain't explained it well enough, the script is pretty basic though it just does some string checking and thats about it...

        Comment


          #5
          **SHOUT**

          Getting close to having HST clients in the bedroom, so I would LOVE to have that! I'm only got 10 or so days left on my evaluation, so I'd like to try this on my HTC Hero to see if it's compatible.

          --Dan
          Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

          Comment


            #6
            Here it goes...I think there is still some bits that needed to be ironed out but its essentially simple;

            3 x Devices

            Q54 - Alarm State
            Q55 - Alarm Time
            Q56 - Alarm Sound (Radio/Alarm Sound)

            When the 'Set Alarm' button is called from HSTouch then it passes the two list box parameters to the Main subroutine, this sets the Q55 alarm time device.

            A recurring event set up at one minute intervals then calls this script but calls the CheckAlarm sub. If it finds the alarm then it sets the Q54 value to 3 for ringing. Theres an event set up with the trigger of Q54 changing to value 3 and the action of this event is to call the SndAlarm subroutine (it also shows an alarm clock screen on HSTouch clients) - this will execute some TTS or play the radio depending on the status of my house (device Q1 is a day/night setting) and the selection in HSTouch.

            Theres a further conditional event based on Q54 having the value of 4, if this is the case then its a recurring event (time to suit) that is a snooze timer - just sends some TTS to remind me that I am an inherently lazy individual.

            The buttons in HSTouch are relatively simple, the radio/alarm buttons just change the value of Q56 to 1/0 and the disable alarm turns Q54 to 2 so the alarm does not sound.

            I probably made it more complicated than I needed to but it seems to work and actually wake me up (a small miracle in itself) - you might be able to consolidate some of the events into parts of the scripts...I made it in a bit of a rush

            Code:
            Sub Main(ByVal Parms As Object)
            
            'takes the values from HSTouch, saves them to the time device
            'Q54 (Alarm State) - 1 for enabled, 2 for disabled, 3 for ringing, 4 for snooze
            
            Call EnableAlarm("")
            're-enable the alarm
            
            Dim SplitStrHr() As String
            Dim SplitStrMin() As String
            
            'hs.writelog("AlarmTest", Parms(0) & Parms(1))
            
            SplitStrHr = Split(Parms(0), Chr(7))
            SplitStrMin = Split(Parms(1), Chr(7))
            
            hs.setdevicestring("Q55", SplitStrHr(0) & ":" & SplitStrMin(0), True)
            'set the time to the device string
            
            
            
            End Sub
            
            Sub AddButtons(ByVal Parms As Object)
            
            'at the buttons to the alarm state 
            
            End Sub
            
            Sub CheckAlarm(ByVal Parms As Object)
            
            'pick the value from the device, then check this against the current time
            
            Dim CurrentAlarmTime As String = hs.devicestring("Q55")
            
            
            Dim DataDate As Date = Now()
            
            Dim CurrentTime As STring = DataDate.ToString("HH:mm")
            
            If CurrentTime = CurrentAlarmTime Then
            
            'change the value to alarm state
            'then have a conditional event
            
            hs.setdevicevalue("Q54", 3)
            hs.setdevicestring("Q54", "Alarm", True)
            hs.writelog("Alarm", "Alarm State")
            
            else
            
            'hs.writelog("Alarm", "Normal State")
            
            End If
            
            
            'hs.writelog("AlarmClock", "Current Time: " & currenttime & " - Alarm Time: " & currentalarmtime & " Alarm State: " & hs.devicestring("Q54"))
            
            End Sub
            
            Sub DisableAlarm(ByVal Parms As Object)
            
            hs.setdevicevalue("Q54", 2)
            hs.setdevicestring("Q54", "Disabled", True)
            
            End Sub
            
            Sub EnableAlarm(ByVal Parms As Object)
            
            hs.setdevicevalue("Q54", 1)
            hs.setdevicestring("Q54", "Enabled", True)
            
            End Sub
            
            Sub Alarm(ByVal Parms As Object)
            
            hs.setdevicevalue("Q56", 1)
            hs.setdevicestring("Q56", "Alarm Sound", True)
            
            End Sub
            
            Sub Radio(ByVal Parms As Object)
            
            hs.setdevicevalue("Q56", 2)
            hs.setdevicestring("Q56", "Radio", True)
            
            End Sub
            
            Sub AlarmOff(ByVal Parms As Object)
            
            hs.setdevicevalue("Q54", 1)
            hs.setdevicestring("Q54", "Enabled", True)
            
            End Sub
            
            Sub Snooze(ByVal Parms As Object)
            
            hs.setdevicevalue("Q54", 4)
            hs.setdevicestring("Q54", "Snooze", True)
            
            
            End Sub
            
            Sub SndAlarm(ByVal Parms As Object)
            
            If hs.devicevalue("Q56") = 1 then
            
            'play the wave file for the alarm
            'hs.playwavefile(hs.apppath & "\aclock.wav")
            'play it also on the HSTouch clients (SDL?)
            
            dim i as integer
            
            for i = 1 to 5
            hs.speak("get up", True, "joggler:Bedroom")
            hs.waitsecs(1)
            next
            
            hs.waitsecs(15)
            
            if hs.devicevalue("Q54") = 3 then
            hs.writelog("Alarm", "Still on alarm, not off yet - go to snooze")
            hs.setdevicevalue("Q54", 4)
            hs.setdevicestring("Q54", "Snooze", True)
            end if
            
            'if it is still set to alarm after 15seconds then turn it onto snooze mode
            
            ElseIf hs.devicevalue("Q56") = 2 Then
            
            'play the radio instead
            'ignore snooze mode here considering music will be playing?
            'maybe not
            
            'I only want the radio if it is considered to be daytime, else go back to speech
            
            If hs.devicevalue("Q1") = 0 then
            'its daytime so play the radio
            hs.runex("radio.vb", "Main", "8")
            else
            
            'play the alarm as its still night time
            
            dim i as integer
            
            for i = 1 to 5
            hs.speak("get up", True, "joggler:Bedroom")
            hs.waitsecs(1)
            next
            
            hs.waitsecs(30)
            'give me 30 seconds to turn the alarm clock
            
            if hs.devicevalue("Q54") = 3 then
            hs.writelog("Alarm", "Still on alarm, not off yet - go to snooze")
            hs.setdevicevalue("Q54", 4)
            hs.setdevicestring("Q54", "Snooze", True)
            end if
            
            end if
            
            
            
            End If
            
            End Sub

            Comment


              #7
              Originally posted by mrhappy View Post
              Yes, see attached. Selection boxes x 2 - only with five minute intervals though...
              This looks fantastic. I have one small problem in that I have never managed to get my head round list box's. Any possibility you could post the Touchscreen files as an attachment, although at this point I have no idea, short of creating a screen with the same name then overwiting the files, as to how to import them into my Touchscreen setup.
              sigpic
              A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

              Comment


                #8
                Originally posted by Gogs View Post
                This looks fantastic. I have one small problem in that I have never managed to get my head round list box's. Any possibility you could post the Touchscreen files as an attachment, although at this point I have no idea, short of creating a screen with the same name then overwiting the files, as to how to import them into my Touchscreen setup.
                I'll post the project if you wan't but its unlikely to help you as it's going to complain very quickly about missing graphics/device/events references and its one screen of a project of 20 screens.

                I've copied it to a new project instead and attached it here (with some of the graphics if they are any good to you) - if all else fails you could open two copies of the designer and copy the list boxes between this project and your own.
                Last edited by mrhappy; August 17, 2012, 10:02 AM.

                Comment


                  #9
                  Originally posted by mrhappy View Post
                  I'll post the project if you wan't but its unlikely to help you as it's going to complain very quickly about missing graphics/device/events references and its one screen of a project of 20 screens.

                  I've copied it to a new project instead and attached it here (with some of the graphics if they are any good to you) - if all else fails you could open two copies of the designer and copy the list boxes between this project and your own.
                  Thanks.
                  sigpic
                  A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                  Comment


                    #10
                    Very nice project,thanks for sharing.
                    I have everthing setup like you descripe,but ran to one problem.
                    When I have a alarm time at 8:00 and the alarm is on Disabled then everyday at 8:00 the alarm still goes off.
                    I can't figure out what I have set wrong.
                    Any help on this appreciate.

                    Comment


                      #11
                      Originally posted by antoon View Post
                      Very nice project,thanks for sharing.
                      I have everthing setup like you descripe,but ran to one problem.
                      When I have a alarm time at 8:00 and the alarm is on Disabled then everyday at 8:00 the alarm still goes off.
                      I can't figure out what I have set wrong.
                      Any help on this appreciate.
                      Sorry about that its the script I think (it could be done with a condition on the alarm sounding event instead), never noticed it myself - it could probably be simpler really.

                      I think that amending this will solve it;

                      Code:
                      If CurrentTime = CurrentAlarmTime Then
                      
                      'change the value to alarm state
                      'then have a conditional event
                      
                      If hs.devicevalue("Q54") = 2 then
                      hs.writelog("Alarm", "Alarm Time however disabled")
                      Else
                      hs.setdevicevalue("Q54", 3)
                      hs.setdevicestring("Q54", "Alarm", True)
                      hs.writelog("Alarm", "Alarm State")
                      End If
                      
                      else
                      
                      'hs.writelog("Alarm", "Normal State")
                      
                      End If
                      That should work I think...

                      Comment


                        #12
                        Thanks for changing this.
                        It is working 100% now.

                        Comment


                          #13
                          I should also mention, there was a 1.0.16 client for Android put together. I was running at my house until the demo ran out. They fixed the custom list boxes! Whoo hoo!

                          Now if I can get the 25% off pricing, I'd bite.

                          --Dan
                          Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

                          Comment


                            #14
                            Well I messed it up somehow.
                            I went by your directions, mrhappy, but I have no idea what I did wrong.

                            The Alarm sound wouldn't fire and so I watched the status page and the log.
                            I set the alarm time and it shows in the device as it should...
                            until the first time the "checkalarm" event runs after setting the time.
                            Then the device string gets messed up.
                            See below pics--
                            Is it possible to have a screen grab of your events for this alarm clock?

                            Thank you,
                            Tim
                            Attached Files
                            FB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188

                            HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3

                            Comment


                              #15
                              As far as I can see at the minute mine works, there may have been problems with the script though. This is my entire script, I have some things that are specific to my setup (for example I have options to wake up to radio, buzzer or an event which sets some lighting) which you may need to change. I have included the events I have for this, some you will not need.

                              Essentially every minute the alarm is checked by the Alarm Check event, this event is not run if the alarm is in an alarm state because once the time goes one minute after the alarm time then it will think it is no longer the alarm time - essentially cancelling the snooze mode out. Once the alarm time is met then the value changes to 3, this then triggers the alarm event which runs the alarm routine in the script. I am sure there is a reason I don't do this all in the script but the reason escapes me at the minute.

                              Code:
                              Const LT As String = "Alarm Clock"
                              
                              Sub Main(ByVal Parms As Object)
                              
                              'takes the values from HSTouch, saves them to the time device
                              'Q54 (Alarm State) - 1 for enabled, 2 for disabled, 3 for ringing, 4 for snooze
                              
                              Call EnableAlarm("")
                              're-enable the alarm
                              
                              Dim SplitStrHr() As String
                              Dim SplitStrMin() As String
                              
                              SplitStrHr = Split(Parms(0), Chr(7))
                              SplitStrMin = Split(Parms(1), Chr(7))
                              
                              hs.setdevicestring("Q55", SplitStrHr(0) & ":" & SplitStrMin(0), True)
                              hs.writelog(LT, "Alarm Set To: " & SplitStrHr(0) & ":" & SplitStrMin(0))
                              
                              'set the time to the device string
                              
                              End Sub
                              
                              Sub CheckAlarm(ByVal Parms As Object)
                              
                              'pick the value from the device, then check this against the current time
                              
                              Dim CurrentAlarmTime As String = hs.devicestring("Q55")
                              
                              Dim DataDate As Date = Now()
                              
                              Dim CurrentTime As STring = DataDate.ToString("HH:mm")
                              
                              If CurrentTime = CurrentAlarmTime Then
                              
                              'change the value to alarm state
                              'then have a conditional event
                              
                              If hs.devicevalue("Q54") = 2 then
                              hs.writelog(LT, "Alarm Time however disabled")
                              Else
                              hs.setdevicevalue("Q54", 3)
                              hs.setdevicestring("Q54", "Alarm", True)
                              hs.writelog(LT, "Alarm State")
                              End If
                              
                              else
                              
                              'hs.writelog("Alarm", "Normal State")
                              
                              End If
                              
                              End Sub
                              
                              Sub DisableAlarm(ByVal Parms As Object)
                              
                              hs.setdevicevalue("Q54", 2)
                              hs.setdevicestring("Q54", "Disabled", True)
                              hs.writelog(LT, "Alarm Disabled")
                              
                              End Sub
                              
                              Sub EnableAlarm(ByVal Parms As Object)
                              
                              hs.setdevicevalue("Q54", 1)
                              hs.setdevicestring("Q54", "Enabled", True)
                              hs.writelog(LT, "Alarm Enabled")
                              
                              End Sub
                              
                              Sub Alarm(ByVal Parms As Object)
                              
                              hs.setdevicevalue("Q56", 1)
                              hs.setdevicestring("Q56", "Alarm Sound", True)
                              hs.writelog(LT, "Alarm Sound")
                              
                              End Sub
                              
                              Sub Radio(ByVal Parms As Object)
                              
                              hs.setdevicevalue("Q56", 2)
                              hs.setdevicestring("Q56", "Radio", True)
                              hs.writelog(LT, "Radio Sound")
                              
                              End Sub
                              
                              Sub Lights(ByVal Parms As Object)
                              
                              hs.setdevicevalue("Q56", 3)
                              hs.setdevicestring("Q56", "Lights Only", True)
                              hs.writelog(LT, "Lights Only")
                              
                              End Sub
                              
                              Sub AlarmOff(ByVal Parms As Object)
                              
                              hs.setdevicevalue("Q54", 1)
                              hs.setdevicestring("Q54", "Enabled", True)
                              hs.writelog(LT, "Alarm Deactivated")
                              
                              End Sub
                              
                              Sub Snooze(ByVal Parms As Object)
                              
                              hs.setdevicevalue("Q54", 4)
                              hs.setdevicestring("Q54", "Snooze", True)
                              hs.writelog(LT, "Alarm Snooze")
                              
                              End Sub
                              
                              Sub SndAlarm(ByVal Parms As Object)
                              
                              If hs.devicevalue("Q56") = 1 then 'this is a check of what the alarm is set to 
                              
                              if hs.devicevalue("Q1") = 1 then
                              'its night time still so trigger the lighting event
                              hs.triggerevent("Alarm Clock Wakeup") 'event still in existence
                              else
                              
                              'play the wave file for the alarm
                              
                              hs.speak(hs.getapppath & "\aclock.wav", True, "*:*")
                              
                              hs.waitsecs(60) 'gives me a chance to do something about it
                              
                              	if hs.devicevalue("Q54") = 3 then
                              		hs.writelog(LT, "Still on alarm, not off yet - go to snooze")
                              		hs.setdevicevalue("Q54", 4)
                              		hs.setdevicestring("Q54", "Snooze", True)
                              	end if
                              
                              end if 
                              
                              ElseIf hs.devicevalue("Q56") = 2 Then 'it is radio  mode
                              
                              'I only want the radio if it is considered to be daytime, else go back to speech
                              
                              If hs.devicevalue("Q1") = 0 then
                              	'its daytime so play the radio
                              	hs.runex("radio.vb", "Main", "1")
                              else
                              
                              	hs.triggerevent("Alarm Clock Wakeup")
                              
                              	hs.waitsecs(60)
                              
                              	if hs.devicevalue("Q54") = 3 then
                              		hs.writelog(LT, "Still on alarm, not off yet - go to snooze")
                              		hs.setdevicevalue("Q54", 4)
                              		hs.setdevicestring("Q54", "Snooze", True)
                              	end if
                              
                              end if
                              
                              ElseIf hs.devicevalue("Q56") = 3 'the alarm mode is set to lights only
                              
                              hs.triggerevent("Alarm Clock Wakeup")
                              
                              End If
                              
                              End Sub
                              What I suspect is happening in your case is the incorrect data is going to the script parameter, that indicates it is being set from HSTouch incorrectly. There should be no letters in the time display at all. Take a look in HSTouch and see if your action editor looks like the below, if not then change it. In that shot also is the List_Values collection, make sure yours is populated also.
                              Last edited by mrhappy; August 17, 2012, 09:59 AM.

                              Comment

                              Working...
                              X