Difference between revisions of "Google Calendar"

From HSYCO
Jump to navigation Jump to search
(Created page with "This driver allows for the use of [https://www.google.com/calendar Google Calendar] as a scheduler. Category:I/O Server == HSYCO Configuration == Add a GOOGLECAL I/O Ser...")
 
 
(22 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
== HSYCO Configuration ==
 
== HSYCO Configuration ==
 
Add a GOOGLECAL I/O Server in the [[Settings#I/O Servers|I/O Servers section of the Settings]] and set its parameters:
 
Add a GOOGLECAL I/O Server in the [[Settings#I/O Servers|I/O Servers section of the Settings]] and set its parameters:
 +
 +
{{note|Note that the GOOGLECAL I/O Server doesn't count in the I/O servers license total, so you don't need an extra I/O Server license to use GOOGLECAL with HSYCO.}}
  
 
=== High Availability ===
 
=== High Availability ===
Line 29: Line 31:
 
|
 
|
 
|<id_list>
 
|<id_list>
|list of calendars IDs separated by ';'  (see [[Setup]] for details). Omit this option to use the primary calendar
+
|list of calendars IDs separated by ';'  (see [[#Setup|Setup]] for details). Omit this option to use the primary calendar
  
 
|-
 
|-
Line 36: Line 38:
 
|
 
|
 
|<nowiki><code></nowiki>
 
|<nowiki><code></nowiki>
|authorization code (see [[Setup]] for details)
+
|authorization code (see [[#Setup|Setup]] for details)
 +
 
 +
|-
 +
 
 +
|pre
 +
|
 +
|n > 0
 +
|if this option is added, the datapoints "<cal_name>.pre" are generated to show the upcoming events with an advance of n minutes
 +
 
 +
|-
 +
 
 +
|rowspan="2"|jsonevents
 +
|rowspan="2"|false
 +
|true
 +
|add JSON datapoints
 +
|-
 +
|false
 +
|do not add JSON datapoints
 +
|-
  
 
|}
 
|}
Line 42: Line 62:
 
== Setup ==
 
== Setup ==
  
The first time HSYCO connects to the Hue bridge, an authentication procedure is required. Configure the HUE I/O Server as described above and restart HSYCO. After few seconds the datapoint 'authentication' of the I/O Server will be set to '1'. At this point you have 30 seconds to manually press the button on the Hue bridge. From now on, HSYCO is authenticated and this procedure will be no longer needed.
+
=== Enable the Google Calendar API ===
  
'''N.B.''' the authentication is linked to the ID assigned to the HUE I/O Server. Changing the ID will require performing the authentication procedure again.
+
* Use [https://console.developers.google.com/start/api?id=calendar this wizard] to create or select a project in the Google Developers Console and automatically enable the API. Click the '''Go to credentials''' button to continue.
 +
* At the top of the page, select the '''OAuth consent screen''' tab. Select an '''Email address''', enter a '''Product name''' if not already set, and click the '''Save''' button.
 +
* Back on the '''Credentials''' tab, click the '''Add credentials''' button and select '''OAuth 2.0 client ID'''.
 +
* Select the application type '''Other''' and click the '''Create''' button.
 +
* Click '''OK''' to dismiss the resulting dialog.
 +
* Click the '''Download JSON''' button to the right of the client ID.
 +
* Move the downloaded file to HSYCO server, place it into a folder called "google-calendar" in the root and rename it "client_secret.json".
 +
 
 +
The "client_secret.json" can be reused for multiple I/O server instances, even on different HSYCO servers.
 +
 
 +
=== Create the calendar ===
 +
 
 +
* Go to [https://www.google.com/calendar/ Google Calendar] and create a Google account or use your personal one to login.
 +
* If you are going to use the primary calendar for this account you are done, go to the next section. If, on the other hand, you want to create a separate calendar for HSYCO (or more that one), continue here.
 +
* From the left column, click on the small option menu button on the right of '''My Calendars'''; select '''Create new calendar'''.
 +
* Enter a name, set the other settings as desired and click on '''Create calendar'''.
 +
* Find the created calendar from the list under '''My Calendars''', select the option menu button on its right and select '''Calendar settings'''.
 +
* Go to the section '''Calendar Address''' and copy the displayed '''Calendar ID'''.
 +
* Go to the settings of the I/O Server and set the value of the "calendars" option to the copied calendar ID. If you want to use more that one calendar, repeat the above procedure to create another one and add its ID to the "calendars" option using ';' to separate the IDs.
 +
 
 +
=== Authorize access ===
 +
 
 +
The first time the driver is started it requires access permission to the calendar information of the selected Google account. This procedure is necessary for each I/O Server instance created.
 +
 
 +
Shortly after the driver is started for the first time, the value of the datapoint "auth" will be set to a long URL string. Copy that URL and paste it into a browser. Login with the selected Google account and click on '''Accept'''.
 +
 
 +
The next page will show a code. Go to the settings of the I/O Server and set the value of the "code" option to this code; save and wait for the server to restart.
 +
 
 +
=== Scheduling events ===
 +
 
 +
To trigger an event on HSYCO during a specific time just create an event in the calendar for the selected time period and set its title to a string of your choice.
 +
 
 +
For instance, let's say the calendar is called "hsycocal" and the title of the created event is "go". During the specified time period the driver will set its datapoint "hsycocal" to the value "go".
 +
 
 +
When no event is scheduled for the current moment, the value of the datapoint will be set to an empty string; if there are overlapping events, the value will list all the titles separated by ';'.
  
 
== Datapoints ==
 
== Datapoints ==
Line 63: Line 117:
 
|offline
 
|offline
 
|R
 
|R
|HSYCO can't connect to the device
+
|HSYCO can't connect to the service
 +
 
 +
|-
 +
 
 +
|rowspan="2"|<cal_name>
 +
|<events_list>
 +
|R
 +
|list of ongoing events in the calendar with name <cal_name>. Events names are separated by ';'
 +
|-
 +
|<json_object>
 +
|W
 +
|add an event to the calendar with name <cal_name>. See below for value format
  
 
|-
 
|-
  
|<cal_name>
+
|<cal_name>.pre
 
|<events_list>
 
|<events_list>
 
|R
 
|R
|.......
+
|list of upcoming events in the calendar with name <cal_name>, with an advance specified by the "pre" option. Events names are separated by ';'. If the "pre" option is omitted these datapoints are not created
 +
 
 +
|-
 +
 
 +
|<cal_name>.json
 +
|<json_array>
 +
|R
 +
|array of JSON objects representing the ongoing events in the calendar with name <cal_name>. To enable this datapoint, option "jsonevents" must be set to true
 +
 
 +
|-
 +
 
 +
|<cal_name>.pre.json
 +
|<json_array>
 +
|R
 +
|array of JSON objects representing the upcoming events in the calendar with name <cal_name>, with an advance specified by the "pre" option. To enable this datapoint, options "pre" and "jsonevents" must be specified
  
 
|}
 
|}
 +
 +
=== Creating an event ===
 +
The value of the datapoint to add an event to a calendar corresponds to a JSON object with the fields <code>title</code>, <code>start</code> and <code>end</code>.
 +
 +
The values of the <code>start</code> and <code>end</code> fields use the format <code><nowiki><YYYY>-<MM>-<dd>T<HH>:<mm>:<ss>[+/-<HH>:<mm>]</nowiki></code>.
 +
 +
Example using default time zone:
 +
<pre>
 +
USER add : {
 +
ioSet('gcal.hsycocal', '{"title": "test", "start": "2018-07-23T16:00:00", "end": "2018-07-23T19:00:00"}');
 +
}
 +
</pre>
 +
 +
Example using explicit time zone:
 +
<pre>
 +
USER add : {
 +
ioSet('gcal.hsycocal', '{"title": "test", "start": "2018-07-23T16:00:00+01:00", "end": "2018-07-23T19:00:00+01:00"}');
 +
}
 +
</pre>
  
 
== Release Notes ==
 
== Release Notes ==
 +
=== 3.7.0 ===
 +
*added capability of creating events
 +
*added "<cal_name>.json" and "<cal_name>.pre.json" datapoints
 +
 +
=== 3.6.0 ===
 +
*the Google Calendar I/O Server is now "free". Using it doesn't decrease the number of available I/O servers
  
 
=== 3.5.0 ===
 
=== 3.5.0 ===

Latest revision as of 11:47, 27 February 2019

This driver allows for the use of Google Calendar as a scheduler.

HSYCO Configuration

Add a GOOGLECAL I/O Server in the I/O Servers section of the Settings and set its parameters:

Note that the GOOGLECAL I/O Server doesn't count in the I/O servers license total, so you don't need an extra I/O Server license to use GOOGLECAL with HSYCO.


High Availability

  • Shutdown when inactive: defaults to false.

Options

ID Default Values Description
pollinterval 10 n > 0 the data acquisition interval, in seconds
calendars <id_list> list of calendars IDs separated by ';' (see Setup for details). Omit this option to use the primary calendar
code <code> authorization code (see Setup for details)
pre n > 0 if this option is added, the datapoints "<cal_name>.pre" are generated to show the upcoming events with an advance of n minutes
jsonevents false true add JSON datapoints
false do not add JSON datapoints

Setup

Enable the Google Calendar API

  • Use this wizard to create or select a project in the Google Developers Console and automatically enable the API. Click the Go to credentials button to continue.
  • At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
  • Back on the Credentials tab, click the Add credentials button and select OAuth 2.0 client ID.
  • Select the application type Other and click the Create button.
  • Click OK to dismiss the resulting dialog.
  • Click the Download JSON button to the right of the client ID.
  • Move the downloaded file to HSYCO server, place it into a folder called "google-calendar" in the root and rename it "client_secret.json".

The "client_secret.json" can be reused for multiple I/O server instances, even on different HSYCO servers.

Create the calendar

  • Go to Google Calendar and create a Google account or use your personal one to login.
  • If you are going to use the primary calendar for this account you are done, go to the next section. If, on the other hand, you want to create a separate calendar for HSYCO (or more that one), continue here.
  • From the left column, click on the small option menu button on the right of My Calendars; select Create new calendar.
  • Enter a name, set the other settings as desired and click on Create calendar.
  • Find the created calendar from the list under My Calendars, select the option menu button on its right and select Calendar settings.
  • Go to the section Calendar Address and copy the displayed Calendar ID.
  • Go to the settings of the I/O Server and set the value of the "calendars" option to the copied calendar ID. If you want to use more that one calendar, repeat the above procedure to create another one and add its ID to the "calendars" option using ';' to separate the IDs.

Authorize access

The first time the driver is started it requires access permission to the calendar information of the selected Google account. This procedure is necessary for each I/O Server instance created.

Shortly after the driver is started for the first time, the value of the datapoint "auth" will be set to a long URL string. Copy that URL and paste it into a browser. Login with the selected Google account and click on Accept.

The next page will show a code. Go to the settings of the I/O Server and set the value of the "code" option to this code; save and wait for the server to restart.

Scheduling events

To trigger an event on HSYCO during a specific time just create an event in the calendar for the selected time period and set its title to a string of your choice.

For instance, let's say the calendar is called "hsycocal" and the title of the created event is "go". During the specified time period the driver will set its datapoint "hsycocal" to the value "go".

When no event is scheduled for the current moment, the value of the datapoint will be set to an empty string; if there are overlapping events, the value will list all the titles separated by ';'.

Datapoints

ID Value R/W Description
connection online R connection established
offline R HSYCO can't connect to the service
<cal_name> <events_list> R list of ongoing events in the calendar with name <cal_name>. Events names are separated by ';'
<json_object> W add an event to the calendar with name <cal_name>. See below for value format
<cal_name>.pre <events_list> R list of upcoming events in the calendar with name <cal_name>, with an advance specified by the "pre" option. Events names are separated by ';'. If the "pre" option is omitted these datapoints are not created
<cal_name>.json <json_array> R array of JSON objects representing the ongoing events in the calendar with name <cal_name>. To enable this datapoint, option "jsonevents" must be set to true
<cal_name>.pre.json <json_array> R array of JSON objects representing the upcoming events in the calendar with name <cal_name>, with an advance specified by the "pre" option. To enable this datapoint, options "pre" and "jsonevents" must be specified

Creating an event

The value of the datapoint to add an event to a calendar corresponds to a JSON object with the fields title, start and end.

The values of the start and end fields use the format <YYYY>-<MM>-<dd>T<HH>:<mm>:<ss>[+/-<HH>:<mm>].

Example using default time zone:

USER add : {
	ioSet('gcal.hsycocal', '{"title": "test", "start": "2018-07-23T16:00:00", "end": "2018-07-23T19:00:00"}');
}

Example using explicit time zone:

USER add : {
	ioSet('gcal.hsycocal', '{"title": "test", "start": "2018-07-23T16:00:00+01:00", "end": "2018-07-23T19:00:00+01:00"}');
}

Release Notes

3.7.0

  • added capability of creating events
  • added "<cal_name>.json" and "<cal_name>.pre.json" datapoints

3.6.0

  • the Google Calendar I/O Server is now "free". Using it doesn't decrease the number of available I/O servers

3.5.0

  • initial release


Google is a registered trademarks of Google Inc.