-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration
In earlier versions of this project, all configuration settings for the project were defined as constants at the top of the remind.py
file. What this meant to users was that if I released an update to the project source, any setting changes you made would be overwritten by the software update. That's not nice, is it?
For this version, I extracted all of the user-settable settings from the remind.py
file (and added a few new ones) to the project's config.json
file. That file doesn't exist right now because to include it in the project would simply create the same overwriting issue described in the previous paragraph. Instead, I included a files called config.rename
that contains all the settings; to use it, you must use that file as a starting point for your settings for this project. You could rename the file to the required file name, but then you'd lose the original settings to use as a reference later. Instead, lets make a copy of the source file, then modify the copy. There's two ways to do this, you can use the graphical File Manger or commands typed in a terminal window.
To use the File Manager Open the Raspbian File Manager application (it's the one that looks like a folder) in the menu bar at the top-left corner of the screen. Navigate to the pi-remind-hd-notify
folder then right click on the config.rename
file and select Copy. Next, right-click on an open space in the same folder and select Paste. The File Manager application will warn you that there is already a file with the same name in this location, in the dialog that appears (shown below), simply rename the file to config.json
and click the Rename button to complete the copy.
The other option is to open a terminal window, navigate to the pi-remind-hd-notify
folder, and execute the following command:
cp config.rename config.json
With either approach, validate that you now have a file in the pi-remind-hd-notify
folder called config.json
. When you open the file, it will look something like this:
{
"access_token": "YOUR_PARTICLE_ACCESS_TOKEN",
"busy_only": false,
"device_id": "YOUR_PARTICLE_DEVICE_ID",
"debug_mode": false,
"display_meeting_summary": true,
"ignore_in_summary": [],
"reminder_only": false,
"use_reboot_counter": true,
"reboot_counter_limit": 10,
"use_remote_notify": true,
"use_working_hours": true,
"work_start": "8:00",
"work_end": "17:30"
}
You can leave the file as is if you want, I tried to preload it with the most common options.
The remaining sections describe each of the configuration options in detail; the following list provides links to each section:
access_token
busy_only
device_id
debug_mode
-
display_meeting_summary
, ignore_in_summary
reminder_only
use_reboot_counter
reboot_counter_limit
use_remote_notify
use_working_hours
work_start
work_end
The configuration settings described in this section control how Pi Remind interacts with your calendar and how it displays calendar information on the Pi Remind display.
Google Calendar supports two appointment status states: Busy or Free. If you only want to be notified of appointments that you've marked as Busy, set the value for busy_only
to true
:
"busy_only": true,
If you have appointments you've marked as Free but you want reminded of them, set busy_status
to false
.
"busy_only": false,
How I use this: If I know I'm not planning on attending a meeting, I decline the meeting so it doesn't even show up on my calendar. If I plan on attending the meeting, I Accept it and leave the status as Busy. For meetings I'm not sure I'm attending, I'll set the meeting status to Free then disable busy_status
(set it to false
) so Pi Remind notifies me of all appointments.
Note: Pi Remind automatically ignores all day meetings, so it only sees meetings that have start and end times.
This setting controls whether Pi Remind displays the upcoming meeting summaries on the display during a notification. By default, Pi Remind displays the subject of every appointment when reminding you:
"display_meeting_summary": true,
If you have confidential appointments and don't want nearby eyes seeing who you're meeting next, or what you're meeting about, disable the feature using the following:
"display_meeting_summary": false,
With this configuration, Pi Remind will use the LEDs to flash a reminder for upcoming appointments, but won't display meeting subjects.
If you're like me, you block time off on your calendar for focus time. There are also plugins for Google Calendar that automatically create events you may not want to be reminded about. With those scenarios in mind, I added the ignore_in_summary
configuration option. It's an array you'll populate with string values you want Pi Remind to look for in your calendar entries. If it finds any of them, it will skip the event (from a notification standpoint).
Note: Pi Remind does a lower case comparison of these values against your calendar entry summaries (converting the event summary to lower case). You must only populate the
ignore_in_summary
array with lower case values, otherwise you'll never get a match.
Here's a sample entry from my configuration:
"ignore_in_summary": ["[block]", "(via clockwise)", "[wife]", "[son]", "[daughter]"],
Let me walk you through the options:
- For my calendar, I add [block] to all the events that are just blocked to hide the time from others.
- My manager uses Clockwise to move appointments around to open spots. One of the features of Clockwise is that you can use it to block time to give you a certain amount of focus time every week. Clockwise adds
(via clockwise)
to every blocked slot, so adding this to the array is an easy way to tell Pi Remind to ignore those events. - I often have appointments on my calendar for events for other members of my family. If I'm not going to attend the event, I add those bracketed entries
"[wife]", "[son]", "[daughter]"
to the entries (based on which person it is). No, I don't usewife
to refer to my Wife, I use her real name in the entries, but I didn't want you to know her name.
Another way some people manage their calendars is to set reminders for appointments they want to attend, and no reminder for unimportant or tentative meetings. By default, Pi Remind notifies you of all appointments through this configuration setting:
"reminder_only": false,
If you want to be reminded only for appointments that have a reminder set, configure Pi Remind using the following:
"reminder_only": true,
Note: Pi Remind ignores the reminder time, so no matter when you have a reminder set, Pi Remind will notify you of upcoming appointments starting 10 minutes before the scheduled start. Fixing this is planned for some future release of Pi Remind.
The biggest change for this version of the Pi Remind project comes from enabling support for the Remote Notify device from Fumbly Stuff.
The microcontroller in Remote Notify is a Particle Photon, an Arduino-compatible device that includes a cloud service that enables applications like the Pi Remind to remotely execute code on the device. In this case, that code sets the color for an illuminated LED on the device - Red for busy, Yellow for Tentative, and Green for free.
The settings described in this section describe how to configure Pi Remind to work with the device.
{
"use_remote_notify": true,
"access_token": "",
"device_id": "",
"use_working_hours": true,
"work_start": "8:00",
"work_end": "17:30"
}
By default, Pi Remind disables support for Remote Notify using the following setting:
"use_remote_notify": false,
When you have a Remote Notify device configured and operational on your local Wi-Fi network, enable it in Pi Remind using the following setting:
"use_remote_notify": true,
Pi Remind requires a couple of settings in order to be able to communicate with the Particle Cloud service: access_token
and device_id
. Enabling Remote Notify support doesn't complete the configuration.
The Particle Cloud uses an Access Token to grant access to REST API calls; this is described in detail in Authentication. So, with that in mind, you'll need to provide Pi Remind with an access token for your particle account:
"access_token": "",
You used to be able to obtain the access token from the Particle developer portal, but that option no longer appears. I think perhaps its because you can now have multiple access tokens, which didn't use to be the case. Where you used to be able to access the Access Token now has the following text:
To create an access token for use with the Particle API, install the Particle CLI and use the token create command.
Follow those instructions to obtain an access token and add it to the configuration file, replacing YOUR-PARTICLE-ACCESS-TOKEN
below with your account's Access Token.
"access_token": "YOUR-PARTICLE-ACCESS-TOKEN",
The Particle Cloud interacts with a specific device using its device ID. When an app makes a call to the API, it passes in the device ID for the target device and the method name to execute on the device. For that reason, Pi Remind needs the device ID for the Particle device running the Remote Notify.
To obtain the device ID, login to the Particle Console, select the devices tab, and copy the device ID from the page. An example device is shown in the following figure. Populate the device_id
configuration value with the copied value as shown in the following example:
"device_id": "YOUR-PARTICLE-DEVICE-ID",
Note: Your Device ID won't be a readable string, I just replaced my device ID with the string so you could see what it looked like.
Note: Working Hours is an experimental feature (which means I've not completed coding it yet). It doesn't work, so don't try it. Actually, it does work - you can enable it and when it's enabled the LED on the Remote Notify device will turn off instead of turning Green when there's no active appointment. What doesn't work is checking the current appointment against working hours
To keep the Remote Notify LED from staying on all day, I added a working hours option which, when enabled, turns the LED off during non-working hours. However, if you have an appointment during non-working hours, the LED will turn on (Red or Yellow) depending on your meeting status.
To enable working hours, set the value to true
as shown below:
"use_working_hours": true,
To disable it, set the value to false
as shown below.
"use_working_hours": false,
This feature works with the work_start
and work_end
configuration settings described below. If you enable working hours, you must populate those configuration variables with your work start and work end times.
When you enable working hours, you must also tell Pi Remind when work hours begin using the work_start
configuration value:
"work_start": "8:00",
work_start
uses the hour:minute
format in military (sometimes called European) time. The example above shows a start time of 8:00 AM. If your work hours started at 1:00 PM, then you'd use the following
"work_start": "13:00",
When you enable working hours, you must also tell Pi Remind when work hours end using the work_end
configuration value:
"work_end": "17:30",
work_end
uses the hour:minute
format in military (sometimes called European) time. The example above shows a end time of 5:30 PM
With computer software and hardware, things don't always go as planned. To help you (and me) troubleshoot problems with the application, I added some additional configuration settings.
Enabling debug mode turns on additional output from the application. Most any time the application does anything or makes a decision, I've added code to write information about the event to the console but only when debug mode is enabled.
To enable debug mode, use the following:
"debug_mode": true,
And, unsurprisingly, to disable debug mode, use the following:
"debug_mode": false,
You can turn this on and let it run all the time if you want, it doesn't impact performance much.
One of the side benefits of enabling this is that the Google Calendar Python libraries use the same logging module, so when you enable debug mode, you'll see additional output from the Google Calendar libraries as well.
My house has inconsistent power, so from time to time we have a little power hiccup and the Raspberry Pi loses it's network connection. It should reconnect when everything returns to normal, but that doesn't always happen. To help me (and you) in these situations, I added a counter you can use to force the Pi device to reboot itself after a while. Let me show you how it works.
First, enable the reboot counter by setting the following configuration option:
"use_reboot_counter": true,
With that setting in place, any time the application fails to connect to the Google Calendar, it increments an internal counter. Once that counter reaches a limit (defined in reboot_counter_limit
described below), the device reboots and hopefully reconnects to the network.
To disable the reboot counter, use:
"use_reboot_counter": false,
The reboot counter limit tells the Pi Remind application how many times to retry the Google Calendar connection before rebooting the device. The limit is set to 10 by default as shown below:
"reboot_counter_limit": 10,
With this in place, the device will try 10 times to connect to Google Calendar before rebooting. You can increase or decrease that limit as needed for your environment, but 10 seems like a good number to me.
Pi Remind checks a user's Google Calendar every minute, so a reboot counter limit of 10 means the device will attempt to reconnect for 10 minutes before rebooting the Raspberry Pi.
If you find this code useful, and feel like thanking me for providing it, please consider making a purchase from my Amazon Wish List. You can find information on many different topics on my personal blog. Learn about all of my publications at John Wargo Books.