Zet dit ding in de Scripts directory, zorg dat de extentie .vb is en maak een event die het script dagelijks een keertje aftrapt. Dat is alles.
Vergeet natuurlijk niet "1325GB/22" postcode huisnummer combinatie te vervangen naar je eigen postcode/huisnummer!
Code: Select all
Sub Main(parm)
Dim ElapsedTime as Integer
Dim Bakkendag as String = hs.GetURLEx("http://www.bakkendagalmere.nl", "/kalender/1325GB/22", ElapsedTime, 80, False, False)
'hs.WriteLog("Bakkendag", Bakkendag)
Dim words As String() = Bakkendag.Split(vbCr)
Dim word As String
Dim Datum as Date = Nothing
Dim Summary as String = ""
For Each word In words
word = word.replace(vbLf, "")
If Left(word, 7) = "DTSTART" Then
Datum = DateTime.ParseExact(Right(word, 8), "yyyyMMdd", nothing)
End If
If Left(word, 7) = "SUMMARY" Then
Summary = word.replace("SUMMARY:", "").Trim
If Left(Summary, 10) = "Bakkendag:" Then
Summary = Summary.replace("Bakkendag:", "").Trim
End If
End If
If Datum <> Nothing and Summary <> "" Then
UpdateDevice(Summary, Datum)
Datum = Nothing
Summary = ""
End If
Next
End Sub
Sub UpdateDevice(Summary, Datum)
Dim dv As Scheduler.Classes.DeviceClass
Dim DagNaam as String
Select Case Weekday(Datum.Date, 1)
Case 1
DagNaam = "Zondag"
Case 2
DagNaam = "Maandag"
Case 3
DagNaam = "Dinsdag"
Case 4
DagNaam = "Woensdag"
Case 5
DagNaam = "Donderdag"
Case 6
DagNaam = "Vrijdag"
Case 7
DagNaam = "Zaterdag"
Case Else
DagNaam = "Onbekend"
End Select
Summary = Char.ToUpper(Summary(0)) & Summary.Substring(1)
hs.WriteLog("Bakkendag", Summary & ": " & Datum)
Dim ref as Integer = hs.GetDeviceRefByName("Status Afval " & Summary)
If ref <= 0 Then
ref = hs.NewDeviceRef(Summary)
dv = hs.GetDeviceByRef(ref)
dv.Location(hs) = "Afval"
dv.Location2(hs) = "Status"
dv.Device_Type_String(hs) = "Afval"
dv.MISC_Set(hs, &H10)
End If
If ref > 0 Then
hs.SetDeviceString(ref, DagNaam & " " & Datum.ToShortDateString, True)
hs.SetDeviceLastChange(ref, Datum)
End If
End Sub