-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Google Calendar Scheduler
The Google Calendar Scheduler allows you to control items in openHAB at scheduled times in the future. It will send commands to items or update the state of items when defined on one of your Google Calendars, using the instructions below.
An additional persistence service, the Google Calendar Presence Simulator, writes item state changes as events on the calendar that will occur again some days in the future, to simulate your activity at home (such as turning lights on and off) when on vacation.
When creating or modifying an event on the calendar, its title can be anything, and its event description must contain the instructions in the following format:
start {
send|update <item> <state>
}
end {
send|update <item> <state>
}
or just
send|update <item> <state>
The commands in the start
section will be executed at the event start time and the end
section at the event end time. If these sections are not present, the commands will be executed at the event start time.
As a result, your lines in a calendar event might look like this:
start {
send Light_Garden ON
send Pump_Garden ON
}
end {
send Light_Garden OFF
send Pump_Garden OFF
}
or just
send Light_Garden ON
send Pump_Garden ON
If the event description is entirely blank, then the event's start and end times are used to exclude that time period from processing.
⚠️ The calendar must not contain any events that do not conform to the above description, including public holidays, birthdays, any all-day events at all, personal calendar entries, etc. It is recommended that you create a Google Calendar that is dedicated to the use of the Google Calendar Scheduler service. Alternatively, careful use of thefilter
configuration parameter can be used to select only a subset of matching events on the calendar.
Before you can integrate the openHAB Google Calendar Scheduler with your Google Calendar you must have a Google API Console project.
- Login to https://console.developers.google.com
- From the project drop-down, select an existing project , or create a new one by selecting Create a new project.
- In the sidebar under "API Manager", select Credentials, then select the OAuth consent screen tab.
- Choose an Email Address, specify a Product Name, and press Save.
- In the Credentials tab, select the Create credentials drop-down list, and choose OAuth client ID.
- Under Application type, select Other.
- Put Name and press the Create button.
- Copy client id and client secret
gcal.cfg (openHAB 2+)
############################### GCal configuration ################################
#
# Before using GCal, you need to have a Google API
# Console project. The Wiki describes in detail the steps necessary to set
# up your Google API Console project, as well as how to obtain the credentials
# necessary to complete the information in this file. Once the project is created,
# and you've completed the steps described in the Wiki, you need to copy
# the "Client ID" and "Client secret" from the Credentials page on
# console.developers.google.com
#
#
# Copied from the "Client ID" field on the Credentials page. (required)
#client_id=
# Copied from the "Client secret" field on the Credentials page (required)
#client_secret=
# This is the name you gave to your Google Calendar, or the word 'primary' if you
# want to use your default Google calendar. GCal will download calendar events
# from this calendar (required)
#calendar_name=
# The filter criteria by which calendar events are searched. The Google Calendar
# API will do a text search to find calendar events that match the supplied terms.
# All calendar event fields are searched, except for extended properties (optional)
#filter=
# Refresh interval (in milliseconds) is the frequency with which the
# Google calendar will be checked for calendar events (optional, defaults
# to 900000 [15 minutes], requires restart)
#refresh=
openhab.cfg fragment (openHAB 1.x):
####################### Google Calendar (GCal) configuration ##########################
#
# Before using GCal, you need to have a Google API
# Console project. The Wiki describes in detail the steps necessary to set
# up your Google API Console project, as well as how to obtain the credentials
# necessary to complete the information in this file. Once the project is created,
# and you've completed the steps described in the Wiki, you need to copy
# the "Client ID" and "Client secret" from the Credentials page on
# console.developers.google.com
#
# Copied from the "Client ID" field on the Credentials page (required)
#gcal:client_id=
# Copied from the "Client secret" field on the Credentials page (required)
#gcal:client_secret=
# This is the name you gave to your Google Calendar, or the word 'primary' (without
# quotes) if you want to use your default Google calendar. GCal will download
# calendar events from this calendar (required)
#gcal:calendar_name=
# The filter criteria by which calendar events are searched. The Google Calendar
# API will do a text search to find calendar events that match the supplied terms.
# All calendar event fields are searched, except for extended properties (optional)
#gcal:filter=
# Refresh interval (in milliseconds) is the frequency with which the
# Google calendar will be checked for calendar events (optional, defaults
# to 900000 [15 minutes])
#gcal:refresh=
After first start, you need to authorize openHAB to allow use your calendar. Follow openHAB log for instructions. At the openhab>
prompt, enter log:tail
(openHAB 2+), or at the shell prompt enter tail -f /path/to/your/openhab.log
.
[INFO ] [g.internal.GCalEventDownloader] -################################################################################################
[INFO ] [g.internal.GCalEventDownloader] - # Google-Integration: U S E R I N T E R A C T I O N R E Q U I R E D !!
[INFO ] [g.internal.GCalEventDownloader] - # 1. Open URL 'https://www.google.com/device'
[INFO ] [g.internal.GCalEventDownloader] - # 2. Type provided code ZPWT-UVXXS
[INFO ] [g.internal.GCalEventDownloader] - # 3. Grant openHAB access to your Google calendar
[INFO ] [g.internal.GCalEventDownloader] - # 4. openHAB will automatically detect the permissions and complete the authentication process
[INFO ] [g.internal.GCalEventDownloader] - # NOTE: You will only have 1800 mins before openHAB gives up waiting for the access!!!
[INFO ] [g.internal.GCalEventDownloader] -################################################################################################
The Google Calendar Presence Simulator is an openHAB Persistence service can be used to realize a simple but effective presence simulation feature (thanks Ralf for providing the concept). Every single change of an item that belongs to a certain group is posted as new calendar entry in the future. By default each entry is posted with an offset of 14 days (If you'd like to change the offset please change the parameter gcal-persistence:offset
in your openhab.cfg
or offset
in your gcal-persistence.cfg
in openHAB 2+). Each calendar entry looks like the following:
- title:
[PresenceSimulation] <itemname>
- content:
send <itemname> <value>
To make use of the Presence Simulation you have to walk through these configuration steps:
- make sure that you are using the 1.9.0-SNAPSHOT or later versions of the
org.openhab.io.gcal
andorg.openhab.persistence.gcal
bundles. - configure the gcal-persistence bundle by adding the appropriate configuration in your
openhab.cfg
. All entries start withgcal-persistence
. You must add only calendar_name. If you want to use your primary calendar just use the keywordprimary
. All other credentials are shared from Google Calendar Scheduler configuration. - make sure your items file contains items that belong to the group
G_PresenceSimulation
- if you would like to change the group name, change it ingcal.persist
. - make sure your items file contains an item called
PresenceSimulation
. If you would like to change the group name please change the parametergcal-persistence:executescript
in youropenhab.cfg
(openHAB 1.x) orexecutescript
in yourgcal-persistence.cfg
file (openHAB 2+). - make sure the referenced Google Calendar is writeable by the given user at google.com.
Note: you also need to configure the Google Calendar Scheduler to be able to read the entries from the calendar and act on them.
To activate the Presence Simulation simply set PresenceSimulation
to ON
and the already downloaded events are being executed. Items in your smart home will then behave like they did 14 days earlier.
A sample gcal.persist
file looks like this:
Strategies {
default = everyChange
}
Items {
G_PresenceSimulation* : strategy = everyChange
}
To solve any issues with any service bundle, increase the logging. For gcal, add these lines to your 'logback.xml' (openHAB 1.x):
<logger name="org.openhab.persistence.gcal" level="TRACE" />
<logger name="org.openhab.io.gcal" level="TRACE" />
Under openHAB 2+, at the openhab>
prompt you can enter:
log:set TRACE org.openhab.persistence.gcal
log:set TRACE org.openhab.io.gcal
You can later return them to DEFAULT
level.
-
"GCal PresenceSimulation Service isn't initialized properly! No entries will be uploaded to your Google Calendar"
The persistence configuration is not correct; check that the client_id and client_secret are correct in the gcal configuration. Configuration entries must be prefixed by
gcal-persistence:
. -
"creating a new calendar entry throws an exception: Forbidden"
This can have several causes:
-
The client_id/client_secret might not be correct
-
The calendar name is not correct.
-
If your not using your own calendar, make sure the sharing settings are correct and the user has sufficient rights to create calendar entries.
-
ℹ Please find all documentation for openHAB 2 under http://docs.openhab.org.
The wiki pages here contain (outdated) documentation for the older openHAB 1.x version. Please be aware that a lot of core details changed with openHAB 2.0 and this wiki as well as all tutorials found for openHAB 1.x might be misleading. Check http://docs.openhab.org for more details and consult the community forum for all remaining questions.
- Classic UI
- iOS Client
- Android Client
- Windows Phone Client
- GreenT UI
- CometVisu
- Kodi
- Chrome Extension
- Alfred Workflow
- Cosm Persistence
- db4o Persistence
- Amazon DynamoDB Persistence
- Exec Persistence
- Google Calendar Presence Simulator
- InfluxDB Persistence
- JDBC Persistence
- JPA Persistence
- Logging Persistence
- mapdb Persistence
- MongoDB Persistence
- MQTT Persistence
- my.openHAB Persistence
- MySQL Persistence
- rrd4j Persistence
- Sen.Se Persistence
- SiteWhere Persistence
- AKM868 Binding
- AlarmDecoder Binding
- Anel Binding
- Arduino SmartHome Souliss Binding
- Asterisk Binding
- Astro Binding
- Autelis Pool Control Binding
- BenQ Projector Binding
- Bluetooth Binding
- Bticino Binding
- CalDAV Binding
- Chamberlain MyQ Binding
- Comfo Air Binding
- Config Admin Binding
- CUL Transport
- CUL Intertechno Binding
- CUPS Binding
- DAIKIN Binding
- Davis Binding
- DD-WRT Binding
- Denon Binding
- digitalSTROM Binding
- DIY on XBee Binding
- DMX512 Binding
- DSC Alarm Binding
- DSMR Binding
- eBUS Binding
- Ecobee Binding
- EDS OWSever Binding
- eKey Binding
- Energenie Binding
- EnOcean Binding
- Enphase Energy Binding
- Epson Projector Binding
- Exec Binding
- Expire Binding
- Fatek PLC Binding
- Freebox Binding
- Freeswitch Binding
- Frontier Silicon Radio Binding
- Fritz AHA Binding
- Fritz!Box Binding
- FritzBox-TR064-Binding
- FS20 Binding
- Garadget Binding
- Global Caché IR Binding
- GPIO Binding
- HAI/Leviton OmniLink Binding
- HDAnywhere Binding
- Heatmiser Binding
- Homematic / Homegear Binding
- Horizon Mediabox Binding
- HTTP Binding
- IEC 62056-21 Binding
- IHC / ELKO Binding
- ImperiHome Binding
- Insteon Hub Binding
- Insteon PLM Binding
- IPX800 Binding
- IRtrans Binding
- jointSPACE-Binding
- KM200 Binding
- KNX Binding
- Koubachi Binding
- LCN Binding
- LightwaveRF Binding
- Leviton/HAI Omnilink Binding
- Lg TV Binding
- Logitech Harmony Hub
- MailControl Binding
- MAX!Cube-Binding
- MAX! CUL Binding
- MCP23017 I/O Expander Binding
- MCP3424 ADC Binding
- MiLight Binding
- MiOS Binding
- Mochad X10 Binding
- Modbus Binding
- MPD Binding
- MQTT Binding
- MQTTitude binding
- MystromEcoPower Binding
- Neohub Binding
- Nest Binding
- Netatmo Binding
- Network Health Binding
- Network UPS Tools Binding
- Nibe Heatpump Binding
- Nikobus Binding
- Novelan/Luxtronic Heatpump Binding
- NTP Binding
- One-Wire Binding
- Onkyo AV Receiver Binding
- Open Energy Monitor Binding
- OpenPaths presence detection binding
- OpenSprinkler Binding
- OSGi Configuration Admin Binding
- Panasonic TV Binding
- panStamp Binding
- Philips Hue Binding
- Picnet Binding
- Piface Binding
- PiXtend Binding
- pilight Binding
- Pioneer-AVR-Binding
- Plex Binding
- Plugwise Binding
- PLCBus Binding
- PowerDog Local API Binding
- Powermax alarm Binding
- Primare Binding
- Pulseaudio Binding
- Raspberry Pi RC Switch Binding
- RFXCOM Binding
- RWE Smarthome Binding
- Sager WeatherCaster Binding
- Samsung AC Binding
- Samsung TV Binding
- Serial Binding
- Sallegra Binding
- Satel Alarm Binding
- Siemens Logo! Binding
- SimpleBinary Binding
- Sinthesi Sapp Binding
- Smarthomatic Binding
- Snmp Binding
- Somfy URTSI II Binding
- Sonance Binding
- Sonos Binding
- Souliss Binding
- Squeezebox Binding
- Stiebel Eltron Heatpump
- Swegon ventilation Binding
- System Info Binding
- TA CMI Binding
- TCP/UDP Binding
- Tellstick Binding
- TinkerForge Binding
- Tivo Binding
- UCProjects.eu Relay Board Binding
- UPB Binding
- VDR Binding
- Velleman-K8055-Binding
- Wago Binding
- Wake-on-LAN Binding
- Waterkotte EcoTouch Heatpump Binding
- Weather Binding
- Wemo Binding
- Withings Binding
- XBMC Binding
- xPL Binding
- Yamahareceiver Binding
- Zibase Binding
- Z-Wave Binding
- Asterisk
- DoorBird
- FIND
- Foscam IP Cameras
- LG Hombot
- Worx Landroid
- Heatmiser PRT Thermostat
- Google Calendar
- Linux Media Players
- Osram Lightify
- Rainforest EAGLE Energy Access Gateway
- Roku Integration
- ROS Robot Operating System
- Slack
- Telldus Tellstick
- Zoneminder
- Wink Hub (rooted)
- Wink Monitoring
- openHAB Cloud Connector
- Google Calendar Scheduler
- Transformations
- XSLT
- JSON
- REST-API
- Security
- Service Discovery
- Voice Control
- BritishGasHive-Using-Ruby
- Dropbox Bundle
A good source of inspiration and tips from users gathered over the years. Be aware that things may have changed since they were written and some examples might not work correctly.
Please update the wiki if you do come across any out of date information.
- Rollershutter Bindings
- Squeezebox
- WAC Binding
- WebSolarLog
- Alarm Clock
- Convert Fahrenheit to Celsius
- The mother of all lighting rules
- Reusable Rules via Functions
- Combining different Items
- Items, Rules and more Examples of a SmartHome
- Google Map
- Controlling openHAB with Android
- Usecase examples
- B-Control Manager
- Spell checking for foreign languages
- Flic via Tasker
- Chromecast via castnow
- Speedtest.net integration