Upgrade your humble letterbox with push notifications
FORGE
Next, click back to go to the APIs & Services
dashboard and click the Credentials item on the left-
hand menu. Here, click the ‘Create credentials’ button
and select ‘Service account key’. On the next screen,
‘New service account’ will be selected; give it a name
such as ‘postman-log’. Under ‘role’ select Project,
then Owner, leave the key type as JSON, and finally
click Create.
This will create and download a credentials file
to your computer. Save this to the Pi user’s home
directory as service_file.json, or if you are doing this
from another computer, use something like WinSCP to
copy this JSON file to the Pi.
Now that your app on the Google Cloud Platform
has the ability to work with Sheets in your Drive, it
needs to be granted specific permission to access
the Letterbox Activations spreadsheet. Open up the
JSON credentials file and look for the line which starts
‘client_email’; after that will be a long email address.
Copy the email address (without the quotes), return
to your Google Sheet and click the SHARE button in
the top-right of the browser window. Paste the email
address from before into the People field, ensure ‘Can
edit’ is selected and press the Send button. Press Yes
to any ‘Are you sure?’ style warnings – this enables
the app we’ve just created to make changes to the
spreadsheet, which is what we want.
Next, use PuTTY to connect to your Pi from another
computer on your network, using the IP address we
determined earlier, which will usually be something
similar to 192.168.0.xxx.
The project uses the pygsheets library to make
working with Google Sheets easier. Install pygsheets
with the following command:
Left
The notification, as
it appears on your
phone each time
the letterbox flap
is opened
You can test it out by
manually adding a new row
to the spreadsheet; wait
around a minute and a push
notification should pop up
on your phone
”
”
Above
The applet you create on IFTTT monitors your Google Sheet for
new rows being added, and sends a push notification to your
phone when it spots that the post has arrived
Below
Install the IFTTT app
on your smartphone,
and log in with the
same account in
order to receive the
push notifications