Announcement

Collapse
No announcement yet.

Intercept AirplaySpeak error

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

    Intercept AirplaySpeak error

    In some cases my speaker goes awry and AirplaySpeak throws an error message in the log. Is it based on an error code of the speak command? How could I intercept that error and based on that for example send a text message to alert me to reboot my speaker (that usually solves the issue).

    #2
    I use the below script to look for a 'failed connection' message in the log. Feel free to copy and adapt. I'm using a Global variable to keep track of the last time i searched the log, and trigger the script like every 10 minutes from an event. If it finds a failed connection log entry, it calls another event.

    Are there other errors that are issues in the log that i could look for?
    Btw, it would be easier if log entry were marked as error instead of info...

    Sub Main(parm as object)

    Dim Logs() As HomeSeerAPI.LogEntry
    Dim lngIndex as Long
    Dim LocDate as Date
    Dim LocTargetLogType as string = "AirplaySpeak"
    Dim LocTargetText as string = "INFO Connection to iW3 (192.168.0.105:1024) failed"
    Dim LocLogText50 as string
    Dim LastRan As Date = #8/14/2016 5:02:00 PM#
    Dim NewLastRan As Date
    Dim FoundDrop As Boolean = False

    NewLastRan = Now
    LastRan = hs.GetVar("lastlogscan")
    Logs = hs.GetLog_Date(LastRan, NewLastRan)
    hs.SaveVar("lastlogscan",NewLastRan)

    If Logs IsNot Nothing Then

    For lngIndex = LBound(Logs) to UBound(Logs)
    If String.Equals(LocTargetLogtype, Logs(lngIndex).LogType) Then
    LocLogText50 = Logs(lngIndex).LogText.SubString(0,50)
    If String.Equals(LocTargetText, LocLogText50)

    LocDate = Logs(lngIndex).LogTime
    hs.WriteLog("Info", "Found AirplaySpeak drop at " & LocDate.ToString("G"))
    FoundDrop = True
    hs.TriggerEvent("AirplaySpeak Speaker Dropped")
    Else
    ' hs.WriteLog("Info", LocTargetText & "-" & LocLogText50)
    End If
    Else
    ' hs.WriteLog("Info", LocString & "-" & Logs(lngIndex).LogType)
    End If

    Next lngIndex

    End If

    If FoundDrop = False
    hs.WriteLog("Info", "No AirplaySpeak drops found")
    End If
    End Sub

    Comment

    Working...
    X