I’ve always been bad at tracking my work hours. Not because the tools are hard to use (Clockify’s interface is fine), but because I’d forget to start the timer when I arrived and forget to stop it when I left. After a few weeks of reconstructing timesheets from memory on Friday afternoons, I decided to automate the whole thing.
I already had Home Assistant running at home for smart home automations, and it knows my location through the companion app on my phone. The idea was simple: when I arrive at the office, start a Clockify timer. When I leave, stop it. No manual intervention, no forgotten entries.
It’s been running for months now, and I haven’t manually touched my timesheet since.
The setup at a glance
The system has four components:
- Phone (Home Assistant companion app). Reports my GPS location to Home Assistant.
- Home Assistant zones. Geofences around my office locations. HA fires events when I enter or leave these zones.
- Home Assistant automations. React to zone events by calling the Clockify API via REST commands.
- Clockify API. Starts and stops time entries programmatically.
┌──────────────┐ (1) location ┌──────────────────┐
│ │ ────────────────► │ │
│ Phone │ │ Home Assistant │
│ (HA app) │ ◄──────────────── │ (automations) │
│ │ (4) notification│ │
└──────────────┘ └────────┬─────────┘
│
(2) zone enter/leave
│
▼
┌──────────────────┐
│ REST command │
│ integration │
└────────┬─────────┘
│
(3) API call
│
▼
┌──────────────────┐
│ Clockify API │
│ (start/stop) │
└──────────────────┘
Step 1: Define work zones
In Home Assistant, go to Settings → Areas & Zones and create a zone for each office location. You’ll need the GPS coordinates and a radius. I set mine to about 100 meters, tight enough to avoid false triggers from passing nearby, but loose enough to account for GPS drift.
If you work from multiple locations (like I do), create a zone for each one (e.g., zone.work1, zone.work2). The automations will trigger on any of them.
A tip on radius: start conservative (100–150m). If you find the automation isn’t triggering reliably, especially in dense urban areas or inside large buildings, increase the radius. GPS accuracy on phones varies, and you’d rather have a slightly early trigger than a missed one.
Step 2: Configure REST commands for Clockify
Add these REST commands to your configuration.yaml. They handle the API calls to start and stop Clockify time entries.
rest_command:
clockify_start_time_entry:
url: "https://api.clockify.me/api/v1/workspaces/YOUR_WORKSPACE_ID/time-entries"
method: POST
headers:
X-Api-Key: !secret clockify_api_key
Content-Type: "application/json"
payload: >
{
"start": "{{ start_time }}",
"billable": false,
"description": "{{ description }}",
"projectId": "{{ project_id }}"
}
clockify_stop_time_entry:
url: "https://api.clockify.me/api/v1/workspaces/YOUR_WORKSPACE_ID/user/YOUR_USER_ID/time-entries"
method: PATCH
headers:
X-Api-Key: !secret clockify_api_key
Content-Type: "application/json"
payload: >
{
"end": "{{ end_time }}"
}
Store your Clockify API key in secrets.yaml:
clockify_api_key: "your-api-key-here"
To get your workspace and user IDs, call the Clockify API:
# Get your user info (includes workspace memberships)
curl -s -H "X-Api-Key: YOUR_API_KEY" \
"https://api.clockify.me/api/v1/user" | jq '{id, name, activeWorkspace}'
Step 3: Create the automations
These automations tie it all together. I created them through the HA UI (Settings → Automations), but here’s the YAML for reference.
Start timer when entering a work zone
alias: Clockify - Start Timer at Work Zones
triggers:
- entity_id: person.david
zone: zone.work1
event: enter
trigger: zone
- entity_id: person.david
zone: zone.work2
event: enter
trigger: zone
actions:
- data:
start_time: "{{ now().isoformat() }}"
description: Work @ Office
project_id: 684055c531f323308c6d2783
action: rest_command.clockify_start_time_entry
- data:
title: "Clockify"
message: "Timer started, Work at Office"
action: notify.mobile_david
mode: single
Stop timer when leaving a work zone
alias: Clockify - Stop Timer Leaving Work Zones
triggers:
- entity_id: person.david
zone: zone.work1
event: leave
trigger: zone
- entity_id: person.david
zone: zone.work2
event: leave
trigger: zone
actions:
- data:
end_time: "{{ now().isoformat() }}"
action: rest_command.clockify_stop_time_entry
- data:
title: "Clockify"
message: "Timer stopped, left office"
action: notify.mobile_david
mode: single
The mode: single setting prevents duplicate triggers if the phone reports multiple location updates in quick succession (which happens more often than you’d think).
How it works in practice
My daily routine now looks like this:
- I go to work. My phone’s location updates periodically via the HA companion app.
- When I cross the geofence around the office, HA fires a zone enter event.
- The automation calls the Clockify API to start a time entry, and I get a notification confirming it.
- When I leave, the reverse happens: the timer stops, notification confirms.
I don’t touch my phone, I don’t open Clockify, I don’t think about it at all. At the end of the week, my timesheet is already filled in.
Edge cases and lessons learned
After running this for a while, I’ve encountered a few quirks:
- GPS drift at the office boundary. If your desk is near the edge of the zone radius, you might get phantom leave/enter events. Increasing the zone radius by 20–30 meters fixed this for me.
- Phone battery optimization. Android in particular can be aggressive about killing background apps. Make sure the HA companion app has unrestricted battery access, or location updates will stop.
- Lunch breaks. If you leave the office zone for lunch, the timer will stop and restart when you return. Depending on how your company tracks hours, this might be exactly what you want (it is for me) or it might require adjustment, like adding a condition to suppress triggers during a midday window.
- No internet at the exact moment. If the API call fails (Clockify is down, phone has no data), the time entry won’t be created. I haven’t lost entries in practice, but for bulletproof tracking you could add error handling, for example by queuing failed calls and retrying.
Extending the setup
This basic setup can be extended in several directions:
- Multiple projects. Use different automations for different zones, each mapped to a different Clockify project.
- Business hours condition. Add a time condition so the automation only fires between 7:00 and 19:00, preventing accidental triggers if you drive past the office on a weekend.
- Work from home tracking. Use a smart plug or presence sensor at your desk to detect when you’re working from home, and start a separate timer.
- Weekly summary notification. Create a HA automation that calls the Clockify reporting API on Friday afternoon and sends you a summary of your week’s hours.