Skip to content

Quick start

In this guide you run Hour Advantage on your own machine. You see a real event in a few minutes. You need no clock hardware, because curl plays the part of a ZKTeco clock.

Hour Advantage fits several business models. You can run your own company’s time and attendance. You can run a multi-tenant service for your customers. You can look after clocks as a dealer. Or you can build one engine into your own platform. Business models shows how each one fits.

You need:

  • The Hour Advantage programs and the official package bundles. Both come with the Hour Advantage distribution.
  • Docker, for a throwaway Postgres database.
  • curl. On Windows, use curl.exe. It comes with Windows 10 and later.

Ports 8080, 9090 and 55432 on 127.0.0.1 must be free.

The Hour Advantage distribution gives you:

The programsThree programs for your platform. hourd is the server. hourctl is the command line client. It also builds and tests packages on your machine. houradm handles installation and maintenance. This guide uses hourd and hourctl. Put them on your PATH.
The official package bundlesOne .tar.gz file for each package, ready to push. You use them in step 4.
The houradvantage container imageThe same three programs, running as a non-root user, with the official package bundles inside. Deploy shows how to run it.

The sources of the example packages are in the public repository hour-advantage-examples. Packages explains how to build bundles from them.

Check the programs:

Terminal window
hourd --version

Start a throwaway Postgres 17 database named houradvantage-quickstart. It listens on port 55432 of loopback only:

Terminal window
docker run -d --name houradvantage-quickstart -e POSTGRES_USER=houradvantage -e POSTGRES_PASSWORD=houradvantage -e POSTGRES_DB=houradvantage -p 127.0.0.1:55432:5432 postgres:17-alpine -c tcp_keepalives_idle=10 -c tcp_keepalives_interval=5 -c tcp_keepalives_count=3 -c tcp_user_timeout=30s

The three -c settings are limits the gateway asks of its database. The gateway refuses to start without them. See Operations, Database role settings.

In a terminal of its own:

Terminal window
# PowerShell
$env:HOURADVANTAGE_DATABASE_URL = "postgres://houradvantage:[email protected]:55432/houradvantage"
hourd run
Terminal window
# bash
export HOURADVANTAGE_DATABASE_URL=postgres://houradvantage:houradvantage@127.0.0.1:55432/houradvantage
hourd run

The gateway waits for Postgres to accept connections. Then it creates its tables and opens the admin API on 127.0.0.1:9090. An admin API on loopback needs no login. So hourctl on this machine reaches it with no settings. Leave the gateway running.

The log warns that HOURADVANTAGE_SECRET_KEY is not set. That is fine for this guide, because it keeps no secret. But the gateway refuses to store your first secret until the key is set. A secret can be a delivery key, a sink’s secret for Time and Attendance, or a broker password. When you go on, make a key first with houradm gen-secret-key. Give it to hourd run as HOURADVANTAGE_SECRET_KEY. See secrets at rest.

In a second terminal, check it:

Terminal window
hourctl status
gateway running at http://127.0.0.1:9090, version 0.1.0, instance <host>
listeners 0 (0 running, 0 stopped, 0 failed)
endpoints 0 (0 stopped)
devices 0 (0 allowed, 0 pending, 0 blocked)
sinks 0 (0 events waiting, 0 failing)

A fresh database has no packages. Push the official bundles and activate them. Run this in the folder that holds the distribution’s bundles, the .tar.gz files:

Terminal window
# PowerShell
hourctl pkg push --activate (Get-ChildItem *.tar.gz).FullName
hourctl pkg list
Terminal window
# bash
hourctl pkg push --activate *.tar.gz
hourctl pkg list

You can use bundles built from the example packages instead. Build them in a checkout of hour-advantage-examples. Building runs each package’s scenarios. Then push them:

Terminal window
# PowerShell
hourctl pkg build . -o dist
hourctl pkg push --activate (Get-ChildItem dist\*.tar.gz).FullName
Terminal window
# bash
hourctl pkg build . -o dist
hourctl pkg push --activate dist/*.tar.gz

hourctl pkg list shows each package line and the revision that runs. One of them is [email protected]. Packages covers bundles, revisions and lines.

Save this as quickstart.toml:

[[listener]]
id = "devices"
type = "http"
listen = "127.0.0.1:8080"
[[endpoint]]
id = "office"
listener = "devices"
path = "/office"
package = "[email protected]"
new_devices = "allow"
options = { timezone = "America/Chicago" }

The listener takes HTTP on 127.0.0.1:8080. The endpoint office serves every request under /office. It uses the ZK PUSH 3.4 package and the America/Chicago time zone. It lets in any device that calls, because of new_devices = "allow". Outside a trial, use "hold". See devices. Apply it:

Terminal window
hourctl apply quickstart.toml
listener devices: created
endpoint office: created
warning: port 8080 is one no listener of this setup used before: a load balancer or a published port that clocks reach it by needs it too (docker compose: a haproxy.cfg frontend and a ports: line; Kubernetes: the devices Service; `hourctl export lb` prints them). Another tenant's listener cannot share the port
applied on 1/1 instances (config version 13)

The warning is for deployments behind a load balancer or published ports. You have none here. The config version is your gateway’s own count of changes, so your number differs.

In a third terminal, follow the events as the gateway stores them:

Terminal window
hourctl events --follow

Now a ZK clock with serial number TEST0001 calls in. Each request below is what a real clock sends to a server set to 127.0.0.1, port 8080, path /office.

Terminal window
# PowerShell
# First contact: the clock asks for its options.
curl.exe -s "http://127.0.0.1:8080/office/iclock/cdata?SN=TEST0001&options=all&pushver=3.4.0"
# Heartbeat: "anything for me?"
curl.exe -s "http://127.0.0.1:8080/office/iclock/getrequest?SN=TEST0001"
# A punch: user 1001 checks in by fingerprint.
curl.exe -s --data-binary "1001`t2026-10-01 08:00:00`t0`t1`t0`t0`t0`n" "http://127.0.0.1:8080/office/iclock/cdata?SN=TEST0001&table=ATTLOG&Stamp=2026-10-01T08:00:00"
Terminal window
# bash
# First contact: the clock asks for its options.
curl -s "http://127.0.0.1:8080/office/iclock/cdata?SN=TEST0001&options=all&pushver=3.4.0"
# Heartbeat: "anything for me?"
curl -s "http://127.0.0.1:8080/office/iclock/getrequest?SN=TEST0001"
# A punch: user 1001 checks in by fingerprint.
printf '1001\t2026-10-01 08:00:00\t0\t1\t0\t0\t0\n' | curl -s --data-binary @- "http://127.0.0.1:8080/office/iclock/cdata?SN=TEST0001&table=ATTLOG&Stamp=2026-10-01T08:00:00"

The first answer is the clock’s settings: GET OPTION FROM: TEST0001, TimeZone=-05:00, the upload stamps, and more. The heartbeat and the punch are each answered OK. The gateway stored the punch before it told the clock so.

The device registered itself. List devices:

Terminal window
hourctl devices
ENDPOINT DEVICE STATUS KEY PRESENTED LAST SEEN REMOTE IP MESSAGES ERRORS LABELS
office TEST0001 allowed none none 2026-10-04T18:00:26.747Z 127.0.0.1 3 0 -

The events terminal shows three events:

  • A device.new event.
  • A device.joined event. The clock was let in, so it joined its tenant and its endpoint’s group.
  • The punch.

Each line shows the event’s sequence number, when it was stored, its type, the endpoint and device, and its data. hourctl events lists them again. They come after the package.updated events, ids 1 to 7, that pushing the bundles’ policy packages made:

8 2026-10-04T18:00:26.702959Z device.new office/TEST0001 {"device_id":1,"key_presented":"none","remote_ip":"127.0.0.1","status":"allowed"}
9 2026-10-04T18:00:26.703114Z device.joined office/TEST0001 {"device_id":1,"group":"office"}
10 2026-10-04T18:00:26.752848Z punch office/TEST0001 {"dst_ambiguous":false,"local_time":"2026-10-01 08:00:00","state_name":"check_in","time":"2026-10-01T08:00:00-05:00","time_zone":"America/Chicago","user_id":"1001", ... ,"verify_name":"fingerprint", ...}

The punch uses neutral terms: user_id, time, state_name and verify_name. What the clock said in its own terms is under vendor.zk. Events describes every field.

Ask the clock to report what it is. Use the standard action get_info:

Terminal window
hourctl action office TEST0001 get_info
action #1 get_info for office/TEST0001: queued (commands #1136802001)

The command waits until the clock next calls in. Send another heartbeat, the same getrequest as in step 6. This time the answer is the command, with its id:

C:1136802001:INFO

A real clock carries out the command and posts the result. Play that part too. Use the id from your own answer in place of 1136802001:

Terminal window
# PowerShell
curl.exe -s --data-binary "ID=1136802001&Return=0&CMD=INFO`n~DeviceName=Demo Clock`nFWVersion=Ver 1.0.0`nUserCount=1`n" "http://127.0.0.1:8080/office/iclock/devicecmd?SN=TEST0001"
Terminal window
# bash
printf 'ID=1136802001&Return=0&CMD=INFO\n~DeviceName=Demo Clock\nFWVersion=Ver 1.0.0\nUserCount=1\n' | curl -s --data-binary @- "http://127.0.0.1:8080/office/iclock/devicecmd?SN=TEST0001"

The answer is OK. The action is done. The events terminal shows a command.result event and an action.result event. The device’s record holds what the clock reported:

Terminal window
hourctl actions office TEST0001
hourctl device show office TEST0001
ID ACTION STATUS STEPS LANE CREATED
1 get_info done 1 interactive 2026-10-04T18:00:29.971Z

device show lists the reported values on its info line:

info firmware=Ver 1.0.0, model=Demo Clock, push_version=3.4.0, user_count=1

Stop the gateway with Ctrl-C in its terminal. Then remove the database:

Terminal window
docker rm -f houradvantage-quickstart
DeployRun Hour Advantage as a container, as a Docker Compose cluster, on Kubernetes, or as a service.
NetworkingListeners, endpoints, ports and the load balancer in front.
DevicesLetting devices in, keys, and new_devices = "hold".
PackagesBuilding, pushing and activating packages; ZKTeco PUSH for ZK clocks.
ActionsEvery standard action, and how actions reach devices.
JobsOne action over many devices, in waves.
Sync groupsKeeping people, access and punches the same on clocks of any vendor.
Admin APIThe HTTP API hourctl uses.
Command lineEvery hourd, hourctl and houradm command.