With soccer games to coach, kid's appointments, and the new house, I wanted an app to show me how many hours I was putting in at work. IFTTT let me add a notification to my calendar every time I entered or exited a circle around my work location on a map. ThingSpeak, Webhooks from IFTTT, and MATLAB let me calculate the hours and visualize the totals.
Outline1. Create two ThingSpeak channels: one to log requests, and one to store the times.
2. Use IFTTT: Set the IFTTT Location applet to trigger Webhooks.
3. Create an analysis in ThingSpeak to calculate times and write them to the channel.
Create the WorkTime Logger1. Set up a MathWorks account. Then sign in to ThingSpeak with your MathWorks credentials. Create two new channels; I called mine "Worktime Notifications" and "WorkTime."
2. For the WorkTime Notifications channel, select the API Keys tab, and record your 16-digit Read API Key and the Write API Key. Then, record the Write API Key for the second channel.
3. Go to IFTTT. Create an account if you need one. Select New Applet, and then click the word "This." Type "location" in the search bar and select the Location app.
3. Choose "Enter or Exit an Area". Define your geographic area and select "Create Trigger".
4. Click the word "That" and type Webhooks in the search bar. Select the Webhooks app.
5. Set your Webhooks settings. The URL is the write data API request for ThingSpeak. It has the form "https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXXX" Be sure to put your Write API key from the Woktime Notifications channel. Choose POST as the Method, and "applicaiton/x-www-form-urlencoded". In the body, write "field1=" and then select Add Ingredient. Choose "EnteredOrExited". Click the Create Action button to complete the applet.
6. Each time you enter or exit the area, IFTTT writes "Entered" or "Exited" to your ThingSpeak Worktime Notifications channel. The ThingSpeak plots on your channel view do not show character data. Use the Data Export button to see the data.
7. In ThingSpeak, set up the computation. Select Apps > MATLAB Analysis. Paste the code in the window and select Save. Be sure the use the Read API Key from the Worktime Notifications channel, and the Write API Key from the Worktime channel. If you enter or exit the area multiple times in a day, the code adds up each segment.
7. Set a TimeControl to call the code daily and perform the calculation. Select Apps > TimeControl. Set the TimeControl Frequency to Recurring and Recurrence to Week. Choose your workdays and choose a time after you have left work. I chose 11:55 PM.
8. Wait a few days, do some useful work, and eventually, you will see a plot like the one below in the second channel.
Comments