Announcement

Collapse
No announcement yet.

Using a calendar to change a virtual device

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

  • Using a calendar to change a virtual device

    I am using various google calendars, and with the help of this PI I display upcoming appointments and birthdays in virtual devices. Now I have created anotehr calendar, with public holidays and my holidays. I want to create a event (script) which turns a virtual device on if the calendar has an entry holiday. The calendar is called Holidays, and the only entries are all day events called Holiday.

    I use this script (which needs to be adapted) to grab events from my existing calendar to be displayed in my virtual device.

    Code:
    Sub Main(parm as object)
    
    Const ScriptName As String = "SendCalEvents"
    
        Dim allEvents As Object()
        Dim calevents as string = ""
    
    allEvents = hs.PluginFunction("BLGData", "", "GetCalendarEventsForXDays", new Object(){"xxx@gmail.com","Holidays",0})
    
    If allEvents.GetUpperBound(0) = -1
    
            ' calevents = ""
    
            hs.SetDeviceValueByRef(2035,0,true)
    
    Else
    
           ' For Each ev As Object In allEvents
    
               ' hs.writelog("Info", ev.StartDate & " " & ev.Name)
    
               ' calevents = calevents  & ev.StartDate.Substring(0, ev.StartDate.Length - 5)& " " & ev.Name & "<br>"
    
    
    
               hs.SetDeviceValueByRef(2035,100,true)
    
    End If
    
    
    End Sub

    How do I need to change this, to load todays events from Holidays (is {"xxx@gmail.com","Holidays",0}) that right ? I only need to determine if there is an entry, as that calendar is only to store holidays

  • #2
    I just tested this, it seems to work. What is not working yet, I would like to write into the log 'Holiday' when the script runs and it finds a holiday, if it doesnt 'no holiday'

    I tried adding:

    hs.writelog("No Holiday found in calendar")

    but got an error...

    Running script C:\Program Files (x86)\HomeSeer HS3\scripts\HolidayCalendar.vb :Exception has been thrown by the target of an invocation.Overload resolution failed because no accessible 'writelog' accepts this number of arguments.

    Got it.

    hs.writelog("Info", "No Holiday found in calendar") all seems to work now.

    I'll leave these posts as it might help others

    Comment


    • #3
      This a cleaned up version of the working script:

      Code:
      Sub Main(parm as object)
      
      Const ScriptName As String = "SendCalEvents"
      
          Dim allEvents As Object()
          Dim calevents as string = ""
      
      allEvents = hs.PluginFunction("BLGData", "", "GetCalendarEventsForXDays", new Object(){"xxx@gmail.com","Holidays",0})
      
      If allEvents.GetUpperBound(0) = -1
      
                 hs.writelog("Info", "No Holiday found in calendar")
      
      
                 hs.SetDeviceValueByRef(2046,0,true)
      
      Else
      
                 hs.writelog("Info", "Holiday found in calendar")
      
      
                 hs.SetDeviceValueByRef(2046,100,true)
      
      End If
      
      
      End Sub

      Comment

      Working...
      X