Announcement

Collapse
No announcement yet.

Jon00 Cumulative Uptime Monitor For Homeseer Devices

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

    #76
    Bob,

    Whilst I know you were the one to request this script, I feel your suggestion is specific to you. Rather than create all these virtual devices, why not just store the previous uptime values to the ini file and then read all the data out to a single device. This is probably all I would do.
    Jon

    Comment


      #77
      Originally posted by jon00 View Post
      Bob,

      Whilst I know you were the one to request this script, I feel your suggestion is specific to you. Rather than create all these virtual devices, why not just store the previous uptime values to the ini file and then read all the data out to a single device. This is probably all I would do.
      Jon,

      Fair enough. But can you give me a hint on how I write ini data into a device?
      Regards, Bob

      Comment


        #78
        Bob,

        Here is an example. The script below assumes that you save the uptime data to the ini file with the following format:

        hs.SaveINISetting "Data","Dev1Day",hs.GetIniSetting("Device1","TotalUptime","" ,"Jon00Upti me.ini"),"Jon00Uptime.ini"

        Dev1Day is just variable to define the value for Device1 Daily use etc

        This will store all 3 television uptime data in a single device "Y7"

        PHP Code:
        Sub main()

        Dim Dev1Day,Dev1Week,Dev1Month
        Dim Dev2Day
        ,Dev2Week,Dev2Month
        Dim Dev3Day
        ,Dev3Week,Dev3Month

        Dev1Day
        =hs.GetIniSetting "Data","Dev1Day","","Jon00Uptime.ini"
        Dev1Week=hs.GetIniSetting "Data","Dev1Week","","Jon00Uptime.ini"
        Dev1Month=hs.GetIniSetting "Data","Dev1Month","","Jon00Uptime.ini"

        Dev2Day=hs.GetIniSetting "Data","Dev2Day","","Jon00Uptime.ini"
        Dev2Week=hs.GetIniSetting "Data","Dev2Week","","Jon00Uptime.ini"
        Dev2Month=hs.GetIniSetting "Data","Dev2Month","","Jon00Uptime.ini"

        Dev3Day=hs.GetIniSetting "Data","Dev3Day","","Jon00Uptime.ini"
        Dev3Week=hs.GetIniSetting "Data","Dev3Week","","Jon00Uptime.ini"
        Dev3Month=hs.GetIniSetting "Data","Dev3Month","","Jon00Uptime.ini"


        DevString="TV 1 - Yesterday: " Dev1Day " Last Week: " Dev1Week " Last Month: " Dev1Month
        DevString
        =Devstring "<br>TV 2 - Yesterday: " Dev2Day " Last Week: " Dev2Week " Last Month: " Dev2Month
        DevString
        =Devstring "<br>TV 3 - Yesterday: " Dev3Day " Last Week: " Dev3Week " Last Month: " Dev3Month

        hs
        .setdevicestring "Y7",Devstring,true

        End sub 
        Jon

        Comment


          #79
          Here is a question that I may have missed or not.

          When running the uptime script, I created an event to be a "recurring" event. For testing, I just set it to 1 minute. I would assume in real world, I would space it out longer.

          What would you suggest? 5 Minutes? 20 Minutes? Hour?

          Also, If I used a long span of time, say an hour and my A/C turned on and off 5 times in that hour and ran a total of 21 minutes, would it be tracked or just the last time it was on?

          Thanks!
          Steve

          Comment


            #80
            The use of the recurring script is only used to update the virtual device(s) displaying the current uptime.

            You need to trigger the script directly when the air-con goes on/off. Do you have a device setup in Homeseer that displays when it is on/off? Do you use events to turn it on/off? Let me know the details and I can assist with the best method to record the uptime.
            Jon

            Comment


              #81
              Today i installed this script and now i`m trying to get things going but i cannot figure out how to match a real device to an virtual device

              I did found the manual of the script but i would like run the script every minute to follow al devices

              Comment


                #82
                If you want to run the script every minute and track a real device, I am assuming you want to use its device status (on/off).

                For example, to track device "A1" you would use the following optional parameters when running the script. This assumes device 1:

                ("Main","1;$DS:A1")

                If you wanted to also track "A2" (with device 2) you would use:

                ("Main","1;$DS:A1|2;$DS:A2")
                Jon

                Comment


                  #83
                  It is working using the following string

                  Code:
                   
                  ("Main","1;$DS:Q33|2;$DS:Q38|3;$DS:Q28|4;$DS:Q20|5;$DS:Q39|6;$DS:A2|7;$DS:M2|8;$DS:M1|9;$DS:Q21|10;$DS:Q23|11;$DS:Q22|12;$DS:Q19|13;$DS:Q18|14;$DS:Q64|15;$DS:Q63|16;$DS:M3")

                  Comment


                    #84
                    Originally posted by Moskus View Post
                    This is fantastic!
                    I just thought to my self: "Perhaps there's an easy way to monitor how much my living room oven is used". And a quick search later I found this!


                    Two questions though:
                    - I have to run the script Jon00Uptime.vben each time I want to update the status devices? Or is it possible to let the UpdateScript internal timer take care of this?

                    - Would it be possible to add an "calculation line" to the plugin? This plugin is ideal to get an idea what it costs to have certain appliances running.

                    I know that my oven draws 1336 W when it's on. The price is approx 0.45 kr/kWh. If the device value of the Uptime device is in second, I'd like to run the following calculation:
                    DV * 1336 (effect) / 3600 (seconds in an hour) / 1000 (for kW) * 0.45 (price)

                    (or DeviceValue*1336/3600/1000*45 for short).

                    Can someone explain to me how to make a script using this type of calculation. What I want to do is use the amount of minutes the lights have been on (for example, my outside Landscaping lights. The total wattage is 500) my cost for electricity is .477 per kw hour. So say the lights were on for 5 hours a night ( this is [Device 1] on my .ini file, housecode "Y1". I know how to figure out the cost on a calculator, but doing a script I am way lost.

                    Also, a few posts later Jon00 said you can add the cost to the same line on the Virtual Device. That is what I am looking to do.

                    Some examples would be great.

                    Thanks in advance,
                    Steve

                    Comment


                      #85
                      I replied to your email. In short Jon00Uptime.vben runs to calculate the total uptime, then I run a script to calculate the price, and then run Jon00Uptime.vben again to display the calculated price.

                      The script is:
                      Code:
                          Public Sub Main(ByVal p_params As String)
                              Dim price As Single = 1.105 'NOK per kWh
                              Dim effect As Single = 1850 'Watt
                              Dim seconds As Integer = hs.DeviceValue("E17")
                              
                              Dim kWh as Single = Math.Round(effect / 1000 * seconds / 3600, 2)
                              hs.SaveIniSetting ("Device1","TextAfterValue","*- " & kWh & " kWh","Jon00Uptime.ini")
                          End Sub
                      HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                      Running on Windows 10 (64) virtualized
                      on ESXi (Fujitsu Primergy TX150 S8).
                      WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                      Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                      Comment


                        #86
                        Moskus, great way to consolidate information!

                        So, when you run it again, do you have to run "off" for every device that you are going to modify the text for? Is that all that you have to do to get the script to re-load all the information from the .ini ?

                        I'm considering doing this as it "just" makes sense. Right now I have a few virtuals for each thing I am tracking with this, yet your way seems so nice! I had not considered it.

                        --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


                          #87
                          Thanks Moskus for the quick response to my email. I tweaked the script a little to show the cost amount used by adding the Cost function and it shows up in the value box:

                          Public Sub Main(ByVal p_params As String)
                          Dim price As Single = .0477 '0.0477 'kr/kWh
                          Dim effect As Single = 230 'W
                          Dim seconds As Integer = hs.DeviceValue("Y3")

                          Dim kWh as Single = Math.Round(effect / 1000 * seconds / 3600, 2)
                          Dim Cost as Single = Math.Round(kWh * price, 2)
                          hs.SaveIniSetting ("Device3","TextAfterValue","* " & kWh & " kWh"+" $ " & Cost & " Amount","Jon00Uptime.ini")
                          End Sub

                          Just one question: Say I wanted to do this for 10 different lights, do I just make 10 different scripts and run all the scripts at once (run an event with Jon00.uptime.vben then all 10 scripts, then Jon00.uptime.vben again) and should I run the main script every minute and not log it so it will update the page every time I refresh the home page?

                          Just thinking that this could be a poor man's energy tracker!!!


                          Thanks,
                          Steve

                          Comment


                            #88
                            Several times a day I am receiving this error message:

                            3/18/2013 10:21:06 PM Error Initializing script run: File 'Jon00Uptime.vben' not found.
                            3/18/2013 10:24:06 PM Error Initializing script run: File 'Jon00Uptime.vben' not found.

                            It is not happening all the time but a few times an hour. I have the script running hidden every minute as per Jon00 says to do.

                            The script is in the proper area. Any ideas why I would be receiving this error?

                            Thanks,
                            Steve

                            Comment


                              #89
                              I don't really know. As the script exists, it must be a Homeseer error.

                              Just on the safe side, make sure you only allow once instance of the script to run.
                              Jon

                              Comment


                                #90
                                Error

                                I get error while trying to run the script

                                Error: Script compile error in encrypted script

                                Any solution?

                                Using HSpro 2.5.0.80

                                Comment

                                Working...
                                X