Announcement

Collapse
No announcement yet.

Generate daily Max Min Email

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

    Generate daily Max Min Email

    Hi,

    I am looking to generate a daily email with the temperature data from an arduino sensor. The basic values are already in HS through MQTT. I need to create the max/min values which this plugin seems to do.

    Can you read this data from this plugin and feed it to emails created by an event?

    Thanks

    #2
    I'm afraid not. The plugin gets data by being notified directly by HS when a device value changes, so if your sensors aren't devices that are being monitored by the plugin, it won't know about their data values.

    Comment


      #3
      Hi,

      Sorry for not being clear.

      I have the MQTT plugin which means that you can create devices from MQTT feeds and the device value changes when a new MQTT message with a different value is received.

      So I can see from your user manual how to configure your plugin to create a db and presumeably the plugin can calculate max/min from the db.

      My query is how to extract those values into an email created by an event and sent once (or more times) per day.

      So the body of the email would be:

      "Report for dd/mm/yy

      Max temperature: xx C
      Min Temperature: zz C
      "

      Is that clearer?

      THX

      Comment


        #4
        Originally posted by adeux View Post
        Hi,

        Sorry for not being clear.

        I have the MQTT plugin which means that you can create devices from MQTT feeds and the device value changes when a new MQTT message with a different value is received.

        So I can see from your user manual how to configure your plugin to create a db and presumeably the plugin can calculate max/min from the db.

        My query is how to extract those values into an email created by an event and sent once (or more times) per day.

        So the body of the email would be:

        "Report for dd/mm/yy

        Max temperature: xx C
        Min Temperature: zz C
        "

        Is that clearer?

        THX
        What I'm planning to add for this is a plugin function that will allow a script to get the min/max/avg (over time) values for a given device ref between two dates. Then you can use the results (a pipe-delimited string of <min>|<max>|<avg>) to build the body of your email.

        Comment


          #5
          Originally posted by shill View Post
          What I'm planning to add for this is a plugin function that will allow a script to get the min/max/avg (over time) values for a given device ref between two dates. Then you can use the results (a pipe-delimited string of <min>|<max>|<avg>) to build the body of your email.
          Check out version 1.2.0 that I just published. I added new plugin functions you can call in a script to GetRangeStats (which gives you min, max & avg over a date range) and GetLastValue (which gives you the immediately preceding value for the specified device.

          Comment


            #6
            Hello,

            Were you able to get the script to work to for your daily report? I am looking to use the "GetRangeStats" component of this plugin, but my .vb scripting is less than stellar...

            Thanks,

            Adam

            Comment


              #7
              I sat down to write up a quick example, only to find out there was a defect in that function

              So a new version will be coming along shortly, but here's the code (minus the email part):

              Code:
              Public Sub Main(parms As String)
              
                  Dim astrParms() As String
              
                  Const IDX_PARMS_REF As Integer = 0
                  Const IDX_PARMS_DATE As Integer = 1
              
                  Dim intRef As Integer
                  Dim dtmDate As Date
              
                  Dim strDeviceStats As String
                  Dim astrStats() As String
              
                  Const IDX_STATS_MIN As Integer = 0
                  Const IDX_STATS_MAX As Integer = 1
                  Const IDX_STATS_AVG As Integer = 2
              
                  Dim dblMin As Double
                  Dim dblMax As Double
                  Dim dblAvg As Double
              
                  'Parse the parameters sent in into discrete variables
                  astrParms = parms.Split(",")
                  intRef = astrParms(IDX_PARMS_REF)
                  dtmDate = CType(astrParms(IDX_PARMS_DATE), Date)
              
                  'Ask the plugin for the stats
                  strDeviceStats = hs.PluginFunction("Device History", "", "GetRangeStats", {intRef.ToString(), dtmDate.ToString(), dtmDate.ToString()})
                      
                  'Parse the response into discrete variables
                  astrStats = strDeviceStats.Split("|")
                  If astrStats.Length() = 3 Then
                      dblMin = astrStats(IDX_STATS_MIN)
                      dblMax = astrStats(IDX_STATS_MAX)
                      dblAvg = astrStats(IDX_STATS_AVG)
              
                      'Do something with the output
                      hs.WriteLog("Device History", "Device " & intRef & " ranged from " & dblMin & " to " & dblMax & " on " & dtmDate.ToShortDateString)
                  Else
                      hs.WriteLog("Error", "Retrieval of stats for device " & intRef & " failed.")
                  End If
              
              End Sub

              Comment


                #8
                Awesome. Thanks for the quick reply. I will try it out tonight

                Comment


                  #9
                  Version 1.2.2 was just published, which you'll need in order to get that working.

                  Comment


                    #10
                    Works great, Thanks.

                    Great plugin by the way. Does exactly what I need

                    Comment


                      #11
                      I just tried to update to 1.2.2.0 and...

                      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	7.3 KB
ID:	1193379
                      HS4 Pro, 4.2.19.0 Windows 10 pro, Supermicro LP Xeon

                      Comment


                        #12
                        Originally posted by rprade View Post
                        I just tried to update to 1.2.2.0 and...

                        [ATTACH]64895[/ATTACH]
                        Could I ask you to have a look at https://forums.homeseer.com/showthread.php?t=192422, and open a new thread with some more details about your problem?

                        (Normally this happens if a plugin is running when you try to update it, btw.)

                        Comment


                          #13
                          So I made some tweaks to the .vb script that @shill generously created for me.

                          I modified a few things and added a few input parameters so I can select generically how many days in the past I want to go back from today. I also added input parameters for the internal devices that will store the Min/Max/Avg values.

                          I run a few of these scripts every day to generate the daily summary of important info which I send via e-mail.

                          Thanks again @shill for helping me with this
                          Attached Files

                          Comment

                          Working...
                          X