I was searching on here for a way to create a sensor that can check if I have the timesheet tracker running in Clockify so I can use it to flash a light on/off if I’ve forgotten to click the button to start my timesheets. I’ve paired it with an automation that checks if my work PC is on using ping.
Anyway, this is the sensor config I ended up with:
sensor:
- platform: rest
resource: https://api.clockify.me/api/v1/workspaces/{YourWorkspaceKey}/time-entries/status/in-progress
method: GET
verify_ssl: false
scan_interval: 60
timeout: 30
headers:
x-api-key: {YourAPIKey}
value_template: "{{ value_json.0.type == 'REGULAR' }}"
name: "Clockify Running"
The return json from clockify looks something like this, so you could prob tweak it if you need some more detail:
[{"id":"xxx","description":"Task name","tagIds":["xxx"],"userId":"xxx","billable":false,"taskId":"xxx","projectId":"xxx","workspaceId":"xxx","timeInterval":{"start":"2024-06-17T14:18:21Z","end":null,"duration":null},"customFieldValues":[],"type":"REGULAR","kioskId":null,"hourlyRate":{"amount":0,"currency":"USD"},"costRate":{"amount":0,"currency":"USD"},"isLocked":false}]