Announcement

Collapse
No announcement yet.

Trying to store time device has turned off for calculation

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

    Trying to store time device has turned off for calculation

    The goal is to work out the time difference in minutes for the following

    I turn on my hot water in a script, with 21:55 + x minutes (x being determined in the script) I have another event which can turn the hot water off before. If that happens, I want to know how many minutes early the hot water has turned off.
    I have the time it should have turned off with the 21:55 + x
    What I need is the how to determine the time hot water has turned off (and store that time in a variable ?)
    then I should be able to just subtract one from the other to have my result (lets call it y)

    I store the value of x in a .ini file, and would like to write the y value also the the .ini (this part is easy I can do that)

    #2
    Originally posted by mikee123 View Post
    I turn on my hot water in a script, with 21:55 + x minutes (x being determined in the script)
    I do not understand what you are doing. Can you be more specific?
    I have another event which can turn the hot water off before. If that happens, I want to know how many minutes early the hot water has turned off.
    Does this involve a HS device? What, exactly, are you turning on and off?
    I have the time it should have turned off with the 21:55 + x
    What I need is the how to determine the time hot water has turned off (and store that time in a variable ?)
    Will an event that is triggered by the hot water being turned off do what you want? I'm thinking of a virtual device that gets turned on when the hot water is turned on and off when the hot water is turned off. The device time of that device should give you the time the hot water was on, and the device last change should give you the time the hot water was turned off. Is it more complicated than that?
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

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

    Comment


      #3
      I have got an idea. If I create an event which runs when my how water turns off. That event runs a script, which stores the time the event runs in a variable. That variable I can then write to my .ini file to be used for the calculations etc...

      So something like that

      switch off time = time now

      writing to the .ini I can do, just setting the current time to the variable is what I need

      I think that is possible and would be the easiest solution. Probably makes more sense then trying to explain what I am trying to do.

      Just one more thing. Would it then be possible in another script to say

      time1 - switch off time = y

      so just subtract to time stamps to get the result in minutes ?

      Comment


        #4
        If I understand what it is you need, then this would give you the elapsed minutes from 2 datetime values stored as strings.

        In the example the elapsed minutes would be a negative value.

        Paul..

        Code:
        Dim SchedOffTime As String = "04/03/2018 21:55:00"
        Dim ActOffTime As String = "04/03/2018 20:18:25"
        
        Dim ElapsedMins As Long = DateDiff(DateInterval.Minute, CDate(SchedOffTime), CDate(ActOffTime))

        Comment


          #5
          Originally posted by sooty View Post
          If I understand what it is you need, then this would give you the elapsed minutes from 2 datetime values stored as strings.

          In the example the elapsed minutes would be a negative value.

          Paul..

          Code:
          Dim SchedOffTime As String = "04/03/2018 21:55:00"
          Dim ActOffTime As String = "04/03/2018 20:18:25"
          
          Dim ElapsedMins As Long = DateDiff(DateInterval.Minute, CDate(SchedOffTime), CDate(ActOffTime))

          Yes that is the 'easier' part of what I need, that is giving me the minutes elapsed. Now, how do I set the CDate(ActOffTime) ?
          As I said, my idea is to hace the hot water device changing to off trigger an event. In that event. a script runs and sets CDate(ActOffTime) to the curent time. I actually only need the time, date is not needed as the maximum difference will be 39 minutes (as the maximum time the hot water is on is 39 minutes)

          The actual script which determines how many minutes my hot water is on for, has been written by a very helpful chap... named Paul (sooty)
          I have created another event which cancels my hot water once its reached a certain temperature. I want to determine every day how many minutes which I will the add up and store in my .ini file. This just as an explanation of what I am trying to do. The final adding up of the values and storing I understand by now (thanks to your script !)

          Comment


            #6
            I can't remember the original script now Mike (getting old)
            If you want to email me your script I'll have a look tomorrow.

            When you calculate the off time (21:55 + X minutes), how is that then used to actually switch the water off, assuming it has not already been switched off early?

            To keep things tidy you can use a single "hot water" script and just call different subs (from an HS event) within that script rather than having multiple scripts.

            Perhaps (as you mention) in your (early off) event you can call the script with a sub that gets the scheduled off time (from the ini file) and calculates the minutes etc.

            Paul..

            Comment


              #7
              Its getting a bit late now for me, I'll email you the ols script + explanations tomorrow evening

              Thanks

              Comment

              Working...
              X