Announcement

Collapse
No announcement yet.

AK Google Calendar plugin introduction / instructions / screenshots

Collapse
This topic is closed.
X
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    AK Google Calendar plugin introduction / instructions / screenshots

    My plugins:
    Click image for larger version  Name:	ikea_64.png Views:	0 Size:	2.1 KB ID:	1421180​​
    AK IKEA
    Click image for larger version  Name:	Square64.jpg Views:	0 Size:	2.8 KB ID:	1421181​​
    AKSquare
    Click image for larger version  Name:	Bond64.png Views:	0 Size:	5.1 KB ID:	1421176​​
    AKBond
    Click image for larger version  Name:	Sonoff64.png Views:	0 Size:	5.6 KB ID:	1421182​​
    AKSonoff
    Click image for larger version  Name:	Shelly64.png Views:	0 Size:	6.5 KB ID:	1421184​​
    AKShelly
    Click image for larger version  Name:	gates  - 3.jpg Views:	0 Size:	93.7 KB ID:	1423325
    AKRemootio
    Click image for larger version  Name:	AKEnphaseEnvoy64.png Views:	0 Size:	8.7 KB ID:	1421179​​
    AKEnphaseEnvoy
    Click image for larger version  Name:	AKGoogleCast64.png Views:	0 Size:	1.5 KB ID:	1421178​​
    AKGoogleCast
    Click image for larger version  Name:	AKGoogleCalendar64.png Views:	0 Size:	3.4 KB ID:	1421177​​
    AKGoogleCalendar
    Click image for larger version  Name:	AKSmartDevice64.png Views:	0 Size:	6.0 KB ID:	1421183​​
    AKSmartDevice
    Click image for larger version  Name:	AKHeatmiserNeo64.jpg Views:	0 Size:	2.1 KB ID:	1421185​​
    AKHeatmiserNeo
    Click image for larger version  Name:	AKTracdown500 - New.png Views:	0 Size:	300.3 KB ID:	1423326
    AKTracdown
    .
    .
    Google Calendar plug-in for displaying calendar events, triggering HS events based on upcoming calendar event (reminder, start, and end). HS Event actions for creating Google calendar events (both Event Start and Event End).


    https://shop.homeseer.com/collection...lug-in-for-hs3


    Features:

    1. The plugin creates a parent root device for each Google Calendar you have setup. In addition it creates two calendar groups with configurable time range for each (i.e. default Today and Tomorrow calendars, or a week)

    Click image for larger version  Name:	Main.png Views:	2 Size:	470.9 KB ID:	1299311

    2. Detailed Event information - for each event by clicking on the event device:

    Click image for larger version

Name:	EventDetails.PNG
Views:	27
Size:	370.5 KB
ID:	1479267


    3. HS Event Triggers: (1) Calendar Event Reminder, (2) Calendar Event Start, (3) Calendar Event End

    Lots of global variables for use in Actions:


    Click image for larger version  Name:	TriggerBeforeStart.png Views:	0 Size:	35.1 KB ID:	1328182

    Click image for larger version  Name:	TriggerReminderConfig.PNG Views:	342 Size:	33.3 KB ID:	1328184


    4. HS Event Actions: (1) Create Calendar Event, (2) Set Event End

    I.e. instead of creating two separate calendar events for Gates Open / Gates Close - one event is created with event end time corresponding to Gates Close:

    Click image for larger version

Name:	ActionConfig.PNG
Views:	28
Size:	237.6 KB
ID:	1479266


    Click image for larger version  Name:	Capture.PNG Views:	0 Size:	39.4 KB ID:	1328183

    #2
    1. Configuring Google Credentials

    Since Google use OAuth2 authentication protocol (which is not designed for console applications) this can be most difficult part depending on your OS and your setup.

    For initial credentials setup you have to use web browser on same computer where HS server is installed and logged in in your browser with your Google email.

    Other options are supported too (below).


    For Linux please see post #6 first and this thread !

    Go to Google Calendar device configuration:

    Click image for larger version

Name:	CredConfig.PNG
Views:	29
Size:	143.6 KB
ID:	1479268

    Option 1. Easiest option (great if it works):
    .
    (a) click on "Enable the Google Calendar API" link,

    (b) then "Enable the Google Calendar API" button. Give the app any name, select "Desktop App":
    .
    Click image for larger version

Name:	image_98413.jpg
Views:	28
Size:	25.2 KB
ID:	1479270
    Click image for larger version

Name:	image_98414.jpg
Views:	27
Size:	10.3 KB
ID:	1479271
    Click image for larger version

Name:	image_98415.jpg
Views:	28
Size:	8.0 KB
ID:	1479272
    Click image for larger version

Name:	image_98417.jpg
Views:	27
Size:	21.8 KB
ID:	1479273
    .
    (c) This should bring a window with "Client ID" and "Client Secret" which you should copy to your Google Calendar Credentials configuration.

    (d) Click button and follow the OAuth2 authentication procedure.

    (e) Then all your Google Calendars should appear below.




    Option 2. If the above didn't work for some reason:
    .
    - click "Create Google API Credentials" link,
    - then click on "Create Credentials" button and select "OAuth Client ID",
    - then "Other" for "Application type" and give it any name.
    - The rest should be same as for option 1 above:



    Click image for larger version

Name:	CredentialsConsole.PNG
Views:	27
Size:	183.6 KB
ID:	1479269

    .


    Option 3. If both options above fail (especially on Linux or headless HS server) -
    .

    Comment


      #3
      2. Configuration Options

      The plugin creates a parent root device for each Google Calendar you have setup (real calendars). In addition it creates two calendar groups with configurable time range for each (i.e. default Today and Tomorrow virtual calendars).

      General Configuration:

      1. Event display date separator - to display event start date/time on new line use "<BR>". To display date in brackets use one of "(", "[", "{". If left blank - no event start date displayed.

      2. Date and Time display format - see Custom date and time format strings

      3. All Day Event start time (offset from 0:00 - positive or negative)


      For all calendar groups (both real and virtual calendars) you can configure:

      1. Number of events you want to display (default 5). Plugin will create a child device for each calendar event. To disable this calendar set the Events to 0.

      2. Update rate (default 15 minutes). This only matters for detecting newly creating events. The plugin will automatically reduce the update delay closer to the event. To disable this calendar can set Update rate to 0:00.

      3. Show Started Events - events in progress started, but not ended. If unchecked - the started event will disappear from HS.

      For each real calendar additionally:

      1. Include in Today
      2. Include in Tomorrow

      If you want to show events from this calendar in Today/Tomorrow calendars

      For each virtual calendar additionally:

      1. Range Start - when the time range for this calendar start, i.e. default 0:00 for Today and "1 Day" for Tomorrow
      2. Time Range - default 1 Day for both, can be changed, i.e. to 7 days to show one week events.
      3. Range Type (Fixed/Moving) - i.e. for Today calendar if "fixed" is selected - the display range will be always fixed from 0:00 to 24:00. For "moving" range show the events starting from "now" for the next 24 hours.


      Click image for larger version  Name:	MainConfigNew.jpg Views:	345 Size:	134.1 KB ID:	1372137

      Comment


        #4
        3. HS Event Triggers/Actions

        HS Event Triggers:

        (1) Calendar Event Reminder
        (2) Calendar Event Start
        (3) Calendar Event End
        (4) Number of Calendar Events


        Click image for larger version  Name:	TriggerBeforeStart.png Views:	1067 Size:	35.1 KB ID:	1328181




        HS Event Actions:

        (1) Create Calendar Event


        Click image for larger version

Name:	ActionEventStart.PNG
Views:	30
Size:	109.4 KB
ID:	1479274

        (2) Set Event End

        Click image for larger version

Name:	ActionsEventEnd.png
Views:	27
Size:	197.5 KB
ID:	1479275

        Comment


          #5
          4. Important Notes

          1. Trigger functionality depends on the calendar configuration and works only for Calendar events displayed in HS. For example if you create a trigger for Event Reminder in Today Calendar and the Calendar Event starts tomorrow (so isn't displayed in Today calendar) and the event reminder is set for "One Day before the event" - it won't trigger. In other words, the Event Reminder trigger for Today Calendar only triggers for events starting today (i.e. within 24 hours)

          2. For same reason if you want to use Event End Trigger - then "Show Started" option should be enabled for this calendar.

          3. And for the same reason if you disable updates for particular calendar (by setting number of events or update frequency to 0) - triggers for this calendar won't work.

          4. Event Reminder Triggers work only for the reminder set explicitly for the event - not the default reminders. Google Calendar API provides only reminder "overrides" by default. It is possible though to get the default reminders to work if required - please add Feature Request.

          5. For some calendars Google doesn't send the clean Name, instead it provides an ugly looking ID. In this case I recommend in Google calendar settings set the calendar description field to the display name you want to see in HS - the plugin then will use the description instead of the name.

          Comment


            #6
            Configuring Google Credentials (on Linux)

            Note: Google Chrome is not available for Raspberry PI, see this post for alternatives.

            Problem I found with authenticating with Google from HS - it's caused by HS running as root, for authentication it tries to start a web browser, but on Linux running browsers as root normally is not allowed:
            Code:
            Running Firefox as root in a regular user's session is not supported
            Here's what I did to make it work:

            1. Install Google Chrome
            Code:
            wget wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
            sudo dpkg -i google-chrome-stable_current_amd64.deb
            2. To let Chrome run as root:

            Code:
            sudo vi /opt/google/chrome/google-chrome
            # Find a line starting from "exec -a" and replace it with:
            exec -a "$0" "$HERE/chrome" "$@" --no-sandbox --user-data-dir
            For test try starting Chrome as su

            Note 1: You need to set Chrome as default browser, so when HS starts the browser - it will choose Chrome.

            Code:
            sudo google-chrome
            Note 2: It's highly recommended first to login in Google Chrome with gmail and password before trying to get OAuth2 authentication.

            Now you should be able to obtain OAuth2 ClentID and ClientSecret, copy them to the plugin config page and click "Submit" (see post #2). Then HS will start the Chrome browser and ask for authorisation.

            Comment


              #7
              Configuring Google Credentials (on Linux / Headless)

              Requires Mono 5.20 and above.

              For headless installation I created a little app authenticator.exe (attached) which you can run anywhere (after obtaining ClientID and ClientSecret, see post #2).

              Note: I also recommend to use this app for testing your Mono version before you actually try to use the plugin. It makes it easier to troubleshoot Google Calendar API Mono .NET dependencies.

              Code:
              authenticator.exe ClientID ClientSecret

              It should request "User login & consent" and receive "Authorisation code" and on success print list of your calendars:
              Code:
              *********************************************
              Credential file saved to: D:\My\Temp\Release\token.json
              
              D:\My\Temp\Release\token.json\Google.Apis.Auth.OAuth2.Responses.TokenResponse-user
              
              *********************************************
              pp08kp35e77ap05mmm94a00gmk@group.calendar.google.com HS-Heat #f691b2
              i04d1nir7395dmril3dvpstijg@group.calendar.google.com HS-Gates #16a765
              jgcuopiksi78f231qq5t23b2pg@group.calendar.google.com Homeseer #fbe983
              95dfa41185hao6gmvpss2nelro@group.calendar.google.com HS-TV #ffad46
              All you need to do now - in Google Calendar Credentials configuration click Click image for larger version  Name:	upload_cred.PNG Views:	1 Size:	3.5 KB ID:	1300476 and point to the file received above (
              Google.Apis.Auth.OAuth2.Responses.TokenResponse-user). This should copy the file to the plugin bin folder on HS machine.
              Alternatively you can copy the file manually to "HomeSeer HS3\Bin\AKGoogleCalendar\token.json" folder (may need to create "token.json" folder first)

              Then click "Submit" button to apply the credentials (you still need the ClientID and ClientSecret fields).

              [EDIT]
              authenticator.exe is included in the plugin install from ver. 1.0.0.11 (downloaded version from this post may become incompatible with later plugin versions)

              Comment


                #8
                Good news - Mono 6 will be released soon which fixes the memory leak in Google Calendar API. Preview release is available here.

                Comment


                  #9
                  Mono 6.0.0 (released 17 Jul 2019) which should fix the memory leak. May I ask everybody to verify?
                  I.e. set ResetGCalTime and MaxGCalMemory to 0 - so RemoteGCal service shouldn't be used, the plugin will communicate with Google directly. Please monitor plugin memory for a few days.
                  If the memory leak is not present - I will happily remove unnecessary complex RemoteGCal service.

                  Comment


                    #10
                    Confirmed - memory leak on Linux is fixed - no RemoteGCal service is required anymore.

                    Comment


                      #11
                      In version 3.0.0.28 (in BETA section) I added some configuration for event display (see post #13)

                      Comment


                        #12
                        Version 3.0.0.33 - Added "Enable" calendar checkboxes (on all config screens) - to disable unused calendars, instead on setting update frequency to Zero

                        Comment


                          #13
                          Ver 3.0.0.34 - Added offset time to All Day Events (positive or negative)

                          Click image for larger version

Name:	MainConfigNew.jpg
Views:	717
Size:	134.1 KB
ID:	1372135

                          Comment


                            #14
                            Ver 3.0.0.36 - Fixed re-connecting to Google after an error

                            Comment

                            Working...
                            X