Tror jeg fikk det til.
Sub Main(ByVal Parms As Object)
Try
Dim calendarName = "Felles"
Dim numberOfDays = 1
Dim allEvents As Object
' Only run if the power is on
If (hs.DeviceValue(6644) = 1) Then
' If setpoint is lower than 35, set it to 38
Dim setpoint As Integer = hs.DeviceValue(6646)
If (setpoint < 35) Then
setpoint = 38
End If
' 1 degree pr hour, so the number of hours is the difference in temp now and setpoint
Dim hoursWarming As Integer = setpoint - hs.DeviceValue(6645)
If (hoursWarming > 0) Then
allEvents = hs.PluginFunction("GCalSeer", "", "GetItemsFromCalendar", New Object() {calendarName, numberOfDays})
For Each ev As Object In allEvents
' Trigger on word "Spa" in calendar
If ev.Subject.Equals("Spa") Then
' If there are less hours left than the required to reach setpoint, trigger heating event
If ev.StartDateTimeLocal < Now.AddHours(hoursWarming) Then
hs.TriggerEvent("Spa-kalendervarme-on")
' If the setpoint is below 35, change the setpoint
If (hs.DeviceValue(6646) < 35) Then
hs.TriggerEvent("Spa-kalendervarme-setpoint")
End If
End If
End If
Next
End If
End If
Catch ex As Exception
hs.WriteLog("", "Exception in script: " & ex.Message)
End Try
End Sub