GCal-Search

The Unofficial SmartThings Blog
Jump to: navigation, search


Ever use your SmartThing setup as an alarm clock? It's so much harder to hit snooze if your bedroom light is on! But because of random days off or late start days you might have to keep modifying the routine. Thus GCal-Search is born! Using your Google Calendar, you can place events on it that SmartThings routines can deal with via virtual switches and/or contact sensors.

The app works by creating sub-apps that have a virtual device with the contact and switch capabilities. This will allow you to select a single calendar per sub-app and also create a search string so that you can have it only look at events that match instead of all events.

Summary

GCalIcon.png

Category: My Apps

Author: Mike Nestor

ST Community handle: https://community.smartthings.com/users/mnestor/activity

Code contributions: Michael Struck

Documentation contributions: Michael Struck

Latest Version

The latest version of each of the applications listed in this document are as follows (as of 4/11/16):

   GCal-Search (Parent):
   Version: 20160302.1
   https://github.com/mnestor/GCal-Search/blob/master/smartapps/mnestor/gcal-search.src/gcal-search.groovy
   GCal-Search Trigger (Child):
   Version: 20160411.1
   https://github.com/mnestor/GCal-Search/blob/master/smartapps/mnestor/gcal-search-trigger.src/gcal-search-trigger.groovy
   GCal Event Sensor (Device):
   Version: 20160411.1
   https://github.com/mnestor/GCal-Search/blob/master/devicetypes/mnestor/gcal-event-sensor.src/gcal-event-sensor.groovy

Requirements

The following are the basic requirements to use GCal-Search:

  • A mobile device running the SmartThings mobile application
  • A Google Calendar you wish to trigger from
  • Activation of the Google Calendar API through a Google Project

Installation

1.Create a Google Project - https://console.developers.google.com ◦Give it any name

2.Install the 2 SmartApps "GCal Search" and "GCal Search Trigger"

GCal Search-Parent Code Installation

The code for the main parent app is found on the GitHub site:

   https://github.com/mnestor/GCal-Search/blob/master/smartapps/mnestor/gcal-search.src/gcal-search.groovy
  • While on the GitHub site, find the Raw button and click it. This will bring up a non-formatted page with just the code present. Select all of the code (typically CTRL+A) and copy It (typically CTRL+C).

Loginscreen.jpg

  • Once you are logged in, find the My SmartApps link on the top of the page. Clicking My SmartApps will allow you to produce a new SmartApp.

MySmartApps.png

  • Find the button on this page labeled +New SmartApp and click it.

+NewSmartApp.png

  • Since you already have the code in your computer’s clipboard, find the tab along the top section called From Code. In the area provided, paste (typically CTRL+V) the code you copied from GitHub. Click Create in the bottom left corner of the page.

NewSmartAppCreate.png

  • This will bring up another page, with the code now formatted within the IDE. If the code was copied correctly, there are no other steps except to save and publish the code. In the upper right corner of the page, find and click Save. Now, click Publish (For Me), and you should receive a confirmation that the code has been published successfully.

SavePublish.png

3. Install and Publish the GCal Event Sensor Device Type

Just as with the code for the SmartApps, be sure to click the Raw link, and then select all of the code (typically CTRL+A), and then copy it (typically CTRL+C) to your computer’s clipboard. Then, go to the SmartThings IDE at http://ide.smartthings.com. Log into the site and click the link at the top labeled My Device Types.

MyDeviceTypes.png

This will present you with a list of custom device types that you may have within your account. If you do not yet have an GCal Event Sensor listed, click the link +New Device Type in the upper right-hand corner of the screen.

+newDevice.png

There will be three tabs at the top; these represent the different ways to add a device. Choose From Code and you will be presented with an empty area where the code you copied earlier can be placed. In the open area in the middle paste (typically CTRL+V) this code.

From here, simply click Save and then click Publish (For Me), exactly as you did when creating the SmartApps.

DeviceSavePublish.png

Open the ST app on your phone and install the "GCal Search" app. This will walk you through connecting to Google and selecting a calendar and search terms. You can create multiple connections, the app will create Contact Sensors that are Open when the event starts and close when the event ends.

Advanced Installation

For advanced users who have their SmartThings IDE integrated with GitHub, the installation and maintaining of code becomes very simple. This manual will not go into detail about setting up your IDE with GitHub; those instructions can be found on the SmartThing web site [[1]]

Once you have integration, the for pieces of code you might need will be available to you to download and keep in sync with the latest versions.

  • First, find the Settings button at the top of your SmartThings IDE page (this will only appear after you integrate with GitHub)

IdeSettings.jpg

  • Clicking this button will open the GitHub Repository Integration page. To find the GCal-Search code, enter the information as you see it below:

Owner: MichaelStruck

Name: GCal-Search

Branch: master

  • Close the GitHub Repository Integration page
  • Next, click the Update from Repo button at the upper-right corner of the IDE
  • On the right-hand column, scroll down to click the apps you want to install. This will typically be:
   Search(parent app):  smartapps/mnestor/gcal-search.src/gcal-search.groovy 
   Trigger (Child app): smartapps/mnestor/gcal-search-trigger.src/gcal-search-trigger.groovy 
  • Click the Execute Update in the bottom-right corner of the screen. When done syncing, the new apps should now appear in your IDE. If they ever change color, that indicates a new version is available.

This process can also be done for the switch sensor My Device Types page, looking for the code:

   Event Sensor: smartapps/mnestor/devicetypes/mnestor/gcal-event-sensor.src/gcal-event-sensor.groovy 

MyDeviceTypes.png

Tips and Tricks

Troubleshooting