Skip to content

Commit

Permalink
Improved leak sensor handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie committed Jan 5, 2025
1 parent 2f89123 commit 36f69ec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/Device Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ These are devices the code has been tested to work with.
* 2635-222 - On/Off Module
* 2672-222 - LED Bulb 240V Edison
* 2843-222 - Open/Close Sensor _(same as 2421)_
* 2852-222 - Water Leak Sensor
* 2867-222 - Alert Module
* 2868-222 - Siren
* 2982-222 - Smoke Bridge
Expand Down
40 changes: 28 additions & 12 deletions modInsteon.vb
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@
strTemp = strTemp & InsteonSmokeBridgeResponse(x(ms + 7))
ElseIf FromAddress = My.Settings.Insteon_SumpAlarmAddr AndAlso Flags = 203 AndAlso x(ms + 5) = 0 AndAlso x(ms + 6) = 0 Then
strTemp = strTemp & InsteonSumpAlarmResponse(Command1)
ElseIf Flags = 203 AndAlso x(ms + 5) = 0 AndAlso x(ms + 6) = 0 AndAlso IsWaterLeakDetector(FromAddress) Then
strTemp = strTemp & InsteonWaterLeakResponse(Command1)
ElseIf Flags = 207 AndAlso x(ms + 5) = 0 AndAlso x(ms + 6) = 0 AndAlso IsWaterLeakDetector(FromAddress) Then
strTemp = strTemp & InsteonWaterLeakResponse(Command1, Command2)
Else
strTemp = strTemp & " Command1: " & Hex(Command1) & " (" & modInsteon.InsteonCommandLookup(Command1) & ")" & " Command2: " & Hex(Command2)
End If
Expand Down Expand Up @@ -1218,13 +1218,13 @@
''' <param name="strAddress">Insteon address in XX.XX.XX format</param>
''' <returns>True if in database as a water leak detector</returns>
Function IsWaterLeakDetector(ByVal strAddress As String) As Boolean
Dim devcat As String = ""
Dim subcat As String = ""
Dim devcat As Integer = 0
Dim subcat As Integer = 0

modDatabase.ExecuteReader("SELECT DevCat FROM INSTEON_DEVICES WHERE Address = '" + strAddress + "'", devcat)
modDatabase.ExecuteReader("SELECT SubCat FROM INSTEON_DEVICES WHERE Address = '" + strAddress + "'", subcat)
modDatabase.ExecuteScalar("SELECT DevCat FROM INSTEON_DEVICES WHERE Address = '" + strAddress + "'", devcat)
modDatabase.ExecuteScalar("SELECT SubCat FROM INSTEON_DEVICES WHERE Address = '" + strAddress + "'", subcat)

If devcat = "16" AndAlso subcat = "8" Then
If devcat = 16 AndAlso subcat = 8 Then
Return True
Else
Return False
Expand Down Expand Up @@ -2072,13 +2072,29 @@
End Select
End Function

Function InsteonWaterLeakResponse(ByVal ToBit As Byte) As String
Function InsteonWaterLeakResponse(ByVal ToBit As Byte, ByVal StatBit As Byte) As String
Select Case ToBit
Case 17
My.Application.Log.WriteEntry("ALERT: Water Leak Detected!", TraceEventType.Warning)
modSpeech.Say("Water leak detected")
modMail.Send("Water leak detected", "Water leak detected")
Return "Water Leak Detected"
Select Case StatBit
Case 1
My.Application.Log.WriteEntry("Leak sensor reports dry", TraceEventType.Information)
Return "Leak sensor reports dry"
Case 2
My.Application.Log.WriteEntry("ALERT: Water Leak Detected!", TraceEventType.Warning)
modSpeech.Say("Water leak detected")
modMail.Send("Water leak detected", "Water leak detected")
Return "Leak sensor reports wet"
Case 4
My.Application.Log.WriteEntry("Leak sensor heartbeat, dry", TraceEventType.Information)
Return "Leak sensor reports dry"
End Select
Case 19
Select Case StatBit
Case 4
My.Application.Log.WriteEntry("Leak sensor heartbeat, wet", TraceEventType.Warning)
modMail.Send("Water leak detected", "Water leak detected")
Return "Leak sensor reports wet"
End Select
Case Else
Return "New or Unknown Message Detected"
End Select
Expand Down

0 comments on commit 36f69ec

Please sign in to comment.