Connectors · Home Assistant

Tap a tag, run a Home Assistant automation

Turn on a light, start a scene or send a notification when a genuine tag is tapped. No Home Assistant login or token: Knura can only start the automations you point it at.

Alpha. Don't use this for locks, garage doors or alarms: a tap proves the tag is genuine, not who tapped it. Prefer plain text? The same guide is in the repository.

Before you start

  • Knura works with your phone. Follow Get started until tapping a tag shows "Tap verified" on your phone.
  • Home Assistant is running on your home network (Home Assistant OS, Container or a virtual machine), version 2024.10 or newer.
  • knurd is v0.2.0-alpha or newer. That's the first release with the Home Assistant connector. On v0.1.0-alpha? Download the new zips from Releases, unzip them next to the old ones and point your shortcuts at the new folders. Your settings, keys and tags carry over.

Keep running knurd and knurctl from your settings folder, where knurd.properties is.

1. Find Home Assistant's address

knurgN needs Home Assistant's IP address, not homeassistant.local. Find it under Settings → System → Network, or on the Home Assistant OS console ("IPv4 addresses"). It looks like 192.168.1.50.

For the port, look at the address you open Home Assistant with: if it ends in :8123, keep it; if there's no port, leave it off (newer Home Assistant OS answers on port 80). Check from the computer that runs knurd. It should print 200:

Terminal
curl -s -o /dev/null -w '%{http_code}\n' http://192.168.1.50:8123/   # or http://192.168.1.50/
Give Home Assistant a fixed address (a DHCP reservation in your router, or Settings → System → Network → IPv4 → Static), or knurgN loses it when it changes.
Running Home Assistant in VirtualBox?

VirtualBox's default network (NAT) hides the virtual machine from your computer. Shut the VM down, open Settings → Network → Adapter 1, set Attached to to Bridged Adapter and pick your computer's network card. Start it again; the console shows the new address.

If ping works but curl says "Connection refused", Home Assistant is still installing (the console says "Home Assistant Core: landingpage"). The first start can take 20 minutes.

2. Make a webhook id

The webhook id works like a password: anyone who has it can start the automation. Make a long random one, and keep it out of chats, screenshots and Git:

Terminal
openssl rand -hex 24

3. Add the automation

In Home Assistant: Settings → Automations & scenes → Create automation → Create new automation, then ⋮ → Edit in YAML. Replace everything with this, put in your webhook id, and save:

automation.yaml
alias: Knura desk-tag tap
description: Runs when the desk-tag knot is tapped (sent by Knura)
mode: single
triggers:
  - trigger: webhook
    webhook_id: PASTE_YOUR_WEBHOOK_ID_HERE
    allowed_methods:
      - POST
    local_only: true
conditions:
  # Only this tag, and only taps from the last minute.
  - condition: template
    value_template: >
      {{ trigger.json.data.knot == 'desk-tag'
         and (now() - as_datetime(trigger.json.data.tappedAt)).total_seconds() | abs < 60 }}
actions:
  - action: persistent_notification.create
    data:
      title: Knura
      message: "{{ trigger.json.data.knot }} was tapped (tap {{ trigger.json.data.counter }})"

desk-tag is the name you give the tag in the next step. The notification is a safe first test that changes nothing in your home. Keep local_only: true, so Home Assistant ignores the webhook if it comes from the internet.

4. Tell knurgN about Home Assistant

In your settings folder, read the tag's UID with the tag on the reader:

Terminal
knurctl info          # UID: 14 characters, like 04406B02936980

Create knurgn.properties with your UID in both knot lines and your address from step 1:

knurgn.properties
knot.04406B02936980.name=desk-tag
knot.04406B02936980.actions=living-room
homeassistant.living-room.url=http://192.168.1.50:8123
secrets.file=knurgn-secrets.properties

living-room is just a name for this connection. Already have a knurgn.properties? Add the homeassistant. line and add living-room to your knot's actions, like actions=test-hook,living-room.

Save the webhook id next to it (the line starts with the connection name and =), and switch actions on if you haven't yet:

Terminal
(umask 077; echo 'living-room=PASTE_YOUR_WEBHOOK_ID_HERE' >> knurgn-secrets.properties)
grep -q '^actions.file' knurd.properties || echo 'actions.file=knurgn.properties' >> knurd.properties

5. Tap

Restart knurd (Ctrl+C, then knurd). It prints knurgN: 1 knot(s) with actions. Tap the tag with your phone:

knurd
knurgN: 1 knot(s) with actions, from knurgn.properties
tap 04406B02936980:7 knot=desk-tag action=living-room: delivered after 1 attempt(s) (HTTP 200)
  • Your phone shows Tap verified.
  • Home Assistant shows a notification under the bell in the sidebar: "desk-tag was tapped".

6. Make it do something

Edit the automation and replace its actions: part, for example to toggle a light:

automation.yaml
actions:
  - action: light.toggle
    target:
      entity_id: light.living_room

Scenes, scripts and media players work the same way. For more tags, give each its own knot.<UID>.name and either its own automation and webhook id, or one automation that checks trigger.json.data.knot. Each tap also carries uid, counter, tappedAt, id and action.

Troubleshooting

What you seeWhat to do
knurd: no secret for homeassistant living-roomknurgn-secrets.properties has no living-room=... line.
knurd: has a line that isn't <connector id>=<secret>The id was pasted without living-room= in front.
knurd: webhook id ... must be 32 to 128 lettersMake one with openssl rand -hex 24.
knurd: must use https://, except for ... a private network addressUse the IP address, not homeassistant.local.
knurd: a tag UID is 14 hex digitsPut the real UID from knurctl info in knurgn.properties.
knurd says delivered, nothing happensHome Assistant answers OK even for a wrong id, so nobody can guess ids. Check the id matches in both places and the knot name matches the automation. Home Assistant's log mentions "unregistered webhook" for a wrong id.
knurd: expired (ConnectException)knurd can't reach Home Assistant. Check the address and port with the curl in step 1.
Phone: "unable to connect"The tag's link isn't your public address. If knurctl info shows http://127.0.0.1, set public.url, restart knurd and run knurctl provision --from knura.

How it stays safe

  • Only real, first-time taps reach Home Assistant. knurd checks every tap against the tag's keys and drops copied or reused links. The link can't choose the action; knurgN picks it by the tag's verified UID.
  • No login token. knurgN holds only the webhook id, which starts the automations listening on it and nothing else.
  • The id stays secret. It lives in a file only you can read, is never logged, and must be at least 32 random characters.
  • Plain http only on your own network, to a private IP address written as numbers. Anything else needs https, and redirects are never followed.
  • On time or not at all. Failed deliveries are retried for up to 30 seconds, then dropped rather than run late, and the automation itself refuses taps older than a minute.
  • No sensitive actions yet. Locks, garage doors and alarms wait for approved-phone confirmation (see the roadmap).