Skip to content

Log your attendance at Personio with a simple python script and get a Slack confirmation.

Notifications You must be signed in to change notification settings

RindusIoTJam/personio-timelogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Personio-timelogger

This tool lets you automatically log working time to your personio Attendance table and getting a feedback by Slack when the entry to the Attendance table has been successfully posted. It consists in two parts, the client and the server.

The client

Written in Python3. It does a login into the Personio site and post the autogenerated working time values.

Requirements

  • Python3

Configuration

A config.py file needs to be created out from config_sample.py file with your own credentials and configuration. Example configuration:

#Personio credentials
EMAIL = '[email protected]'
PASSWORD = 'myStrong!Password'
PROFILE_ID = '0000000' # This can be found in your personio profile URL

#Slack credentials
SLACK_MESSAGE = False
SLACK_SECRET = 'aaaaaaa'
SLACK_BOT_URL = 'URL-TO-BOT'

#App configuration
STARTING_HOUR = "08:00" # Hour you usually start working in the morning
BREAK_HOUR = "13:00"  # Hour you usually take your lunch break
WORKING_HOURS = 9  # Including break time
BREAK_TIME_MINUTES = 30

#Personio credentials EMAIL = '[email protected]' PASSWORD = r'myStrong!Password' PROFILE_ID = '0000000' # This can be found in your personio profile URL

Change the access right to that file to user-read-only:

chmod 400 config.py

The generated time will always be less than the WORKING_HOURS in order not to exceed the maximum allowed by the law as it will be treated as overtime work

Usage

$ path/to/personio-timelogger.py 2019-06-07

Recomendation

A cron job can be created to run this automatically every working day (from Monday to Friday). For example, the following cron entry will be triggered at 17:00 every working day

0 17 * * 1-5 ~/bin/personio-timelogger.py $(date +%Y-%m-%d) >/dev/null 2>&1

You will probably need to scape the % character this way:

0 17 * * 1-5 ~/bin/personio-timelogger.py $(date +\%Y-\%m-\%d) >/dev/null 2>&1

If you use a Mac, Cron is deprecated in MacOS. Instead it uses LaunchAgents. To configure a launchAgent follow the following guide:

  1. Create a file called runner.sh beside client/personio-timelogger.py
  2. Put this inside the file, with this repository path in your machine and save it
#!/bin/bash
/ABSOLUTE-PATH-TO-THIS-REPO/client/personio-timelogger.py $(date "+%Y-%m-%d")
  1. Give it execution permission chmod +x runner.sh
  2. Go to: ~/Library/LaunchAgents
  3. Create a .plist, ie de.personio.cron.plist file in there with this content. You can modify to your liking in terms of hours. Save the file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>de.personio.cron</string>
    <key>Program</key>
    <string>/bin/sh</string>
    <key>ProgramArguments</key>
    <array>
        <string>-c</string>
        <string>/ABSOLUTE-PATH-TO-THIS-REPO/client/runner.sh</string>
    </array>
    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>17</integer>
            <key>Minute</key>
            <integer>45</integer>
            <key>Weekday</key>
            <integer>1</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>17</integer>
            <key>Minute</key>
            <integer>55</integer>
            <key>Weekday</key>
            <integer>2</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>17</integer>
            <key>Minute</key>
            <integer>38</integer>
            <key>Weekday</key>
            <integer>3</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>17</integer>
            <key>Minute</key>
            <integer>43</integer>
            <key>Weekday</key>
            <integer>4</integer>
        </dict>
        <dict>
            <key>Hour</key>
            <integer>17</integer>
            <key>Minute</key>
            <integer>47</integer>
            <key>Weekday</key>
            <integer>5</integer>
        </dict>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
           <key>PATH</key>
           <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
    </dict>
</dict>
</plist>
  1. Run launchctl load de.personio.cron.plist
Next Steps
  • Improve the times of the week

The Server

Written in Javascript. It is a bot for slack which will handle the feedback from the client and will inform the user which information has been posted to personio when the client runs.

Requirements

  • NodeJS
  • npm (or yarn)

Configuration

  1. Run $ npm i
  2. Create .env file with the following content
// Server Config
PORT=3000
// Found under Basic Information in Slack
SLACK_CLIENT_ID=
SLACK_CLIENT_SECRET=
SLACK_VERIFICATION_TOKEN=
// Found under OAuth & Permissions in Slack (the bot token)
SLACK_AUTH_TOKEN=xoxb-...
  1. Run the server $ node server.js

The Slack Bot

The bot will personally send you feedback when a new post to personio has been successfully done. You need to register into the bot to be able to receive incoming messages from it. Follow the following instructions:

  1. Open Rindus Slack
  2. Go to slackbot conversation below Direct messages
  3. Run /timelogger
  4. You will receive a secret key from the bot. This secret key is the one you have to store in the client config.py file as SLACK_SECRET

About

Log your attendance at Personio with a simple python script and get a Slack confirmation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •