From 749aedc1709942a48b3c5b8ea3ef27fff5153880 Mon Sep 17 00:00:00 2001 From: Jacob Weisz Date: Mon, 27 Aug 2018 20:01:20 -0500 Subject: [PATCH] Track last time thermostat data updated Good for knowing if the status report data we're sending is actually current. --- App.config | 3 +++ My Project/Settings.Designer.vb | 11 +++++++++++ My Project/Settings.settings | 3 +++ modGlobal.vb | 4 ++-- modInsteon.vb | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/App.config b/App.config index 977af7a..854fc1f 100644 --- a/App.config +++ b/App.config @@ -227,6 +227,9 @@ True + + + diff --git a/My Project/Settings.Designer.vb b/My Project/Settings.Designer.vb index 2fe7bc5..40173fc 100644 --- a/My Project/Settings.Designer.vb +++ b/My Project/Settings.Designer.vb @@ -855,6 +855,17 @@ Namespace My Me("Global_LoadModulesAsync") = value End Set End Property + + _ + Public Property Global_TimeThermostatLastUpdated() As Date + Get + Return CType(Me("Global_TimeThermostatLastUpdated"),Date) + End Get + Set + Me("Global_TimeThermostatLastUpdated") = value + End Set + End Property End Class End Namespace diff --git a/My Project/Settings.settings b/My Project/Settings.settings index d63c874..f52d7c0 100644 --- a/My Project/Settings.settings +++ b/My Project/Settings.settings @@ -206,5 +206,8 @@ True + + + \ No newline at end of file diff --git a/modGlobal.vb b/modGlobal.vb index 33daa3a..cc634e7 100644 --- a/modGlobal.vb +++ b/modGlobal.vb @@ -164,11 +164,11 @@ Public Module modGlobal End Function Function SendStatusReport() As String - Dim strStatusReport As String = "The current time is " & Now() & vbCrLf & vbCrLf & "Home monitoring status is set to " & modGlobal.HomeStatus & "." & vbCrLf & vbCrLf & "The current inside temperature is " & My.Settings.Global_LastKnownInsideTemp & " F." + Dim strStatusReport As String = "The current time is " & Now() & vbCrLf & vbCrLf & "Home monitoring status is set to " & modGlobal.HomeStatus & "." & vbCrLf & vbCrLf & "The inside temperature read " & My.Settings.Global_LastKnownInsideTemp & " F at " & My.Settings.Global_TimeThermostatLastUpdated.ToShortTimeString & " on " & My.Settings.Global_TimeThermostatLastUpdated.ToShortDateString & "." If My.Settings.Insteon_ThermostatSlaveAddr <> "" Then strStatusReport = strStatusReport & " (Second reading: " & My.Settings.Global_LastKnownInsideTemp2nd & " F)" End If - If My.Settings.Global_TimeDoorLastOpened <> "" Then + If My.Settings.Global_TimeDoorLastOpened > DateTime.MinValue Then strStatusReport = strStatusReport & vbCrLf & vbCrLf & "The door was last opened at " & My.Settings.Global_TimeDoorLastOpened.ToShortTimeString & " on " & My.Settings.Global_TimeDoorLastOpened.ToShortDateString End If If My.Settings.Pihole_Enable = True Then diff --git a/modInsteon.vb b/modInsteon.vb index f95beaa..8561c7b 100644 --- a/modInsteon.vb +++ b/modInsteon.vb @@ -1834,6 +1834,7 @@ modDatabase.Execute("INSERT INTO ENVIRONMENT (Date, Source, Location, Temperature) VALUES('" + Now.ToUniversalTime.ToString("u") & "', 'Insteon " & FromAddress & "', 'Interior', " & CStr(Int(comm2 / 2)) & ")") If FromAddress = My.Settings.Insteon_ThermostatAddr Then My.Settings.Global_LastKnownInsideTemp = Int(comm2 / 2) + My.Settings.Global_TimeThermostatLastUpdated = Now() ElseIf FromAddress = My.Settings.Insteon_ThermostatSlaveAddr Then My.Settings.Global_LastKnownInsideTemp2nd = Int(comm2 / 2) End If @@ -1851,6 +1852,7 @@ modDatabase.Execute("INSERT INTO ENVIRONMENT (Date, Source, Location, Temperature) VALUES('" & Now.ToUniversalTime.ToString("u") & "', 'Insteon " & FromAddress & "', 'Interior', " & CStr(Int(comm2 / 2)) & ")") If FromAddress = My.Settings.Insteon_ThermostatAddr Then My.Settings.Global_LastKnownInsideTemp = Int(comm2 / 2) + My.Settings.Global_TimeThermostatLastUpdated = Now() ElseIf FromAddress = My.Settings.Insteon_ThermostatSlaveAddr Then My.Settings.Global_LastKnownInsideTemp2nd = Int(comm2 / 2) End If