Jump to content
  • Sign Up
Støtt hjemmeautomasjon.no!

GCalSeer - En plugin for kobling mot Google og Microsoft kalendere - 0.0.5.0


Guahtdim

Recommended Posts

Holder omsider på å sette opp kalenderintegrasjon i Homeseer nå, etter at dette ble lagt på is for en stund siden.

Chat GPT 4 har hjulpet med å lage et script som setter string på 7 devicer dersom det er kalenderhendelser. Dette er for å få turnusen min inn i Homeseer. Kode med GetItemsFromCalendar klarte ikke GPT4 å få til å fungere, så da får jeg dessverre bare hentet ut startdato/-tid og subject. Verdiene kom ut i GMT-tidssone, så dette måtte korrigeres.

Dersom noen vil se på en måte å få ut mer informasjon fra eventene (feks med GetItemsFromCalendar) er det bare å komme med tips eller redigere scriptet.

Screenshot2023-07-22052839.jpg.3913502a9365ddc81958ca6b34ba0e99.jpg
 

Imports System.Globalization

Sub Main(ByVal Parms As Object)
    Try
        Dim tDeviceToday As Integer = 1461
        Dim tDeviceTomorrow As Integer = 1462
        Dim tDevice2Days As Integer = 1463
        Dim tDevice3Days As Integer = 1464
        Dim tDevice4Days As Integer = 1465
        Dim tDevice5Days As Integer = 1466
        Dim tDevice6Days As Integer = 1467

        Dim tCalendar = "Turnuskalender"
        Dim tDays = 7 ' This is the number of days the script will get events from

        Dim allEvents As Object()
        allEvents = hs.PluginFunction("GCalSeer", "", "GetItemsFromMsCalendar", New Object() {tCalendar, tDays})

        Dim today As Date = Date.Today
        Dim deviceList As Integer() = {tDeviceToday, tDeviceTomorrow, tDevice2Days, tDevice3Days, tDevice4Days, tDevice5Days, tDevice6Days}

        Dim timeZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time")
        
        For i As Integer = 0 To tDays - 1
            Dim thisDay = today.AddDays(i).ToString("yyyy-MM-dd")
            Dim eventsForThisDay = ""

            For Each ev As Object In allEvents
                Dim eventString As String = ev.ToString()
                If eventString.StartsWith(thisDay) Then
                    Dim dateTimeString As String = eventString.Substring(0, 16) ' get the date and time part of the event string
                    Dim eventDateTime As DateTime = DateTime.ParseExact(dateTimeString, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture)

                    Dim offset As TimeSpan = timeZone.GetUtcOffset(eventDateTime)
                    Dim correctedDateTimeString As String = eventDateTime.Add(offset).ToString("yyyy-MM-dd HH:mm") ' correct the time

                    eventsForThisDay &= "<br>" & correctedDateTimeString & eventString.Substring(16) & "</br>" ' append the rest of the event string
                End If
            Next

            If eventsForThisDay = "" Then
                eventsForThisDay = "No Events Scheduled"
            End If

            hs.SetDeviceString(deviceList(i), eventsForThisDay, True)
            hs.WriteLog("test", "events for " & thisDay & ": " & eventsForThisDay)
        Next

        hs.WriteLog("test", "---=== DONE ===---")
    Catch ex As Exception
        hs.WriteLog("", "Exception in script: " & ex.Message)
    End Try
End Sub

 

Edited by Im_IB
Link to comment
Share on other sites

  • 3 weeks later...
WHEN
GCalSeer: A google calendar event occurs...
 GCalSeer: Any calendar event:
in calendar  
  empty.png Turnuskalender
Advanced options
Occurs:  
Trigger when event occurs now  
Offset:  

empty.pngTrigger before event with offset  0 Hours 55 Minutes    Edit Time

 

Span

empty.pngDo not trigger if adjacent events
Regexp handling:            
empty.pngNo regexp handling
Trigger more than once :            
empty.pngTrigger more than once during calendar event



ERROR: The trigger for GCalSeer cannot be displayed due to this exception: Object reference not set to an instance of an object.
 

Er det noe jeg har gjort feil her, som trigger denne feilmeldingen?

Edited by Im_IB
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.