Guide | Gadgets | 13 min read

Make your BTClock light up for every zap and every Lightning Piggy deposit

October 2026By Mario

Home / Gadgets

When I get a zap on Nostr, my BTClock flashes purple and orange.
When someone puts sats in the Lightning Piggy, it turns pink and orange and shows the amount on the screen.
The rest of the day it glows green or red, depending on what the price does.
Meanwhile my phone pings and the speaker in the kitchen says who sent the sats.

I haven't seen it anywhere else, so I'm writing down how you can build this Lightning Piggy Home Assistant connection yourself. Even if you're not a programmer.

If you're a bit technical, this is the structure you'll want to see first:

Diagram: a Nostr zap, a Lightning Piggy deposit and the bitcoin price flow through a script, LNbits and a price sensor to Home Assistant, which drives the BTClock, the phone and the speaker

What it does

BTClock showing +21 on the screen and purple light on the wall after a Nostr zap

This happens The BTClock Your phone The speaker
Someone zaps you on Nostr Flashes purple and orange 10 times, 20 seconds purple and orange, amount on the screen Notification with amount and sender "You got a zap of 21 sats"
Someone puts sats in the Lightning Piggy Flashes pink and orange 10 times, 20 seconds pink and orange, amount on the screen Notification with amount "1000 sats were added to the piggy bank"
The rest of the time Euro on the left, dollar on the right: green when the price is higher than yesterday, red when it's lower. The bigger the move, the deeper the color

Then the clock shows the price and goes back to switching every minute between block height, price, fees and the rest.
The clock lights up at night too. The speaker stays quiet between midnight and six in the morning.

What you need

  • A BTClock, the e-paper bitcoin clock with seven small screens and four LEDs.
  • A Lightning Piggy, a piggy bank that shows the balance of a Lightning wallet. Great for kids.
  • Home Assistant, the free software that runs your home. It runs on a mini PC, a Raspberry Pi or a ready-made box.
  • An LNbits wallet for the piggy. If you want to run it yourself, you can do that on a Start9 Server One.
  • A Nostr account with a Lightning address in your profile, for the zaps.

Optional: a NerdQaxe++. The BTClock then also shows your hashrate and your best difficulty.

BTClock showing the hashrate of a NerdQAxe++, next to a Lightning Piggy

How the Lightning Piggy Home Assistant connection works

The idea is simple. Home Assistant sits in the middle.

  1. When a payment comes in, LNbits (piggy) or a small script (Nostr) sends a signal to Home Assistant.
  2. Home Assistant sends a notification to your phone and lets the speaker talk.
  3. Home Assistant tells the BTClock which color to show and which amount to put on the screen.

Home Assistant talks to the BTClock through the integration from its maker. Only for the fast flashing do you use the clock's API directly.

Built by the community

I could never have made this on my own. Everything it runs on was built by people who share their work.

  • BTClock: the firmware is public on git.btclock.dev. That let me see exactly what the clock does, and that's how I found out a color set through the API works at night too.
  • Lightning Piggy: open source, made to teach kids to save with real sats.
  • LNbits, Home Assistant and phoenixd (the Lightning node behind LNbits): all open source. And Nostr is an open protocol. Nobody is in charge of it.

That's why this was possible. Someone builds something and shares it, and someone else builds on top of it.

Are you building this yourself, or making it better? Share it, mention the makers and zap them a few sats. That's how this community keeps growing.

Step 1: put the BTClock on firmware v4

The latest firmware is on git.btclock.dev. You need two files that match your clock: the firmware and the web interface. For the Rev B with the 2.13 inch screen, those are btclock_rev_b_ota.bin and storage_8mb.bin.

Upload them in the clock's web interface under Firmware update. First the firmware, then the web interface. The clock restarts by itself.

Then look up your clock's IP address (it's in the web interface under System info). You'll need it later.

The BTClock web interface: screens, currency, screen cycle and settings

The web interface shows right away how much the clock can do: more than ten screens, from block height and price to the halving, fees, supply and the hashrate of your miner. You choose which ones are on, in which currency, and how long each screen stays.

Two things to know:

  • If you see "Lost connection" after updating, your browser is showing the old page from its cache. Press Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows).
  • "Time per screen" is in minutes, not seconds.

Step 2: let Home Assistant talk to the clock

The maker of the BTClock also built an integration for Home Assistant. With it, the clock shows up as a device in Home Assistant, with switches, a screen selector and firmware updates. You can then simply control it from the app too.

You install it through HACS, the store for extra integrations:

  1. Open HACS, go to the menu at the top right and choose Custom repositories. Add https://github.com/dsbaars/homeassistant-btclock with the type Integration.
  2. Search for BTClock Integration, download it and restart Home Assistant.
  3. Go to Settings β†’ Devices & services. The clock is usually already listed under Discovered. If not, choose Add integration, BTClock, and enter the IP address.
  4. Name the device BTClock. Then the names in the code below will match.
  5. For the update mode, choose polling, every 15 seconds.

Why polling? The live stream is the default, and that's what I started with too. But after a restart of the clock, Home Assistant kept waiting on the old connection. The values stayed old, without any error message. With polling it's fine again within 15 seconds.

One thing stays manual: fast flashing in your own colors. The integration has a light per LED, but four separate commands per flash are too slow for that. So put this at the bottom of your configuration.yaml (with the File editor add-on) and replace the IP address with that of your clock:

rest_command:
  btclock_leds:
    url: "http://192.168.1.50/api/lights/set"
    method: POST
    content_type: "application/json"
    payload: "{{ kleuren }}"

Restart Home Assistant.

Then create a script (Settings β†’ Automations & scenes β†’ Scripts β†’ New script β†’ YAML mode) and paste this in. In the last LED step, change the four colors to the ones your clock normally has:

alias: BTClock signaal
mode: queued
fields:
  kleur:
    default: "#FF1493"
  kleur2:
    default: "#F7931A"
  knipper:
    default: 10
  houd:
    default: 20
  bedrag:
    default: 0
sequence:
  - if: "{{ bedrag | int(0) > 0 }}"
    then:
      - action: switch.turn_off
        target:
          entity_id: switch.btclock_screen_timer
      - action: btclock.show_custom
        data:
          device_id: "{{ device_id('switch.btclock_screen_timer') }}"
          screens: "{% set b = bedrag | int(0) %}{% set t = ('+' ~ ((b / 1000000) | round(1)) ~ 'M') if b >= 1000000 else ('+' ~ b) %}{{ t | list | to_json }}"
  - repeat:
      count: "{{ knipper }}"
      sequence:
        - action: rest_command.btclock_leds
          data:
            kleuren: "{{ ([{'hex': kleur}] * 4) | to_json }}"
        - delay:
            milliseconds: 400
        - action: rest_command.btclock_leds
          data:
            kleuren: "{{ ([{'hex': kleur2}] * 4) | to_json }}"
        - delay:
            milliseconds: 400
  - action: rest_command.btclock_leds
    data:
      kleuren: "{{ [{'hex': kleur}, {'hex': kleur2}, {'hex': kleur}, {'hex': kleur2}] | to_json }}"
  - delay:
      seconds: "{{ houd }}"
  - action: rest_command.btclock_leds
    data:
      kleuren: >
        {% set ns = namespace(k=[]) %}
        {% for s in ['sensor.bitcoin_24u_verandering', 'sensor.bitcoin_24u_verandering_usd'] %}
        {% set c = '#00C853' if states(s) | float(0) >= 0 else '#FF1A1A' %}
        {% set ns.k = ns.k + [{'hex': c}, {'hex': c}] %}
        {% endfor %}
        {{ ns.k | to_json }}
  - if: "{{ bedrag | int(0) > 0 }}"
    then:
      - action: select.select_option
        target:
          entity_id: select.btclock_screen
        data:
          option: Ticker
      - action: switch.turn_on
        target:
          entity_id: switch.btclock_screen_timer

Test it right away: click Run on the script. Your clock should flash pink and orange 10 times. If you pass an amount, as happens later with a payment, it shows on the screen and the clock then jumps to the price screen (Ticker). After that the cycle runs again.

The last LED step sets the clock to green or red. For that you need the price sensor from step 5. If you skip it, replace that line with your own fixed colors.

Waarom btclock.show_custom and not the more logical btclock.show_text? Home Assistant turns the text +21 into the number 21, and then your plus is gone. With a list of separate characters it stays.

Why the colors through the API and not through the clock's settings? The BTClock has a "do not disturb" mode for the night. It blocks the regular flash effects, but not a color you set through the API. So it also lights up at three in the morning when sats come in.

Already built this with the old rest_commands? That keeps working. You can simply add the integration next to it.

Step 3: connect the Lightning Piggy

The Lightning Piggy runs on an LNbits wallet. In LNbits you create a pay link with the Pay Links extension. It has a Webhook URLfield: on every payment, LNbits sends a signal there.

In Home Assistant, create a new automation with a Webhooktrigger. Home Assistant then gives you an address, and you paste that into LNbits under Webhook URL.

These are the actions of the automation (YAML mode):

- variables:
    sats: "{{ ((trigger.json.amount | default(0)) | int / 1000) | round | int }}"
- action: notify.mobile_app_jouw_telefoon
  data:
    title: Spaarpot
    message: "Er zijn {{ sats }} sats in de spaarpot gestort!"
- action: script.turn_on
  target:
    entity_id: script.btclock_signaal
  data:
    variables:
      kleur: "#FF1493"
      kleur2: "#F7931A"
      bedrag: "{{ sats }}"

Want the speaker too? Add a tts.speak action with the same sentence, optionally with a time condition before it.

Step 4: connect your Nostr zaps

First the most important part: put a Lightning address in your Nostr profile. In Primal you do that under Edit profile. Without that address, nobody can zap you. I forgot this myself, and spent an evening figuring out why nothing came in.

Then you let a small script listen in on Nostr, on a computer that is always on. A Raspberry Pi is enough. When the script sees a zap for your account, it sends a signal to a second webhook in Home Assistant. That automation does the same as the piggy one, but calls the script with kleur: "#8E30EB" (purple) and kleur2: "#F7931A" (orange).

The nice part: this works with any wallet. Your zaps keep arriving where they arrive now.

You can easily have an AI write a script like that, see the prompt at the bottom.

Step 5: green or red with the price

Also put this at the bottom of your configuration.yaml. Home Assistant then fetches how much the price changed in 24 hours, in euros and in dollars, every 5 minutes:

rest:
  - resource: "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=eur,usd&include_24hr_change=true"
    scan_interval: 300
    sensor:
      - name: "Bitcoin 24u verandering"
        unique_id: bitcoin_24u_verandering
        unit_of_measurement: "%"
        value_template: "{{ value_json.bitcoin.eur_24h_change | round(2) }}"
      - name: "Bitcoin 24u verandering USD"
        unique_id: bitcoin_24u_verandering_usd
        unit_of_measurement: "%"
        value_template: "{{ value_json.bitcoin.usd_24h_change | round(2) }}"

Then create an automation that sets the LEDs on every change. The two left LEDs follow the euro, the two right ones the dollar. That way you see at a glance whether bitcoin is rising in both currencies, or in just one. I use four shades per side: under 1%, 1 to 5%, 5 to 10% and above, deeper green or red each time:

triggers:
  - trigger: state
    entity_id:
      - sensor.bitcoin_24u_verandering
      - sensor.bitcoin_24u_verandering_usd
  - trigger: time_pattern
    minutes: "/15"
  - trigger: template
    value_template: "{{ states('sensor.btclock_uptime') | int(999999) < 120 }}"
    for:
      seconds: 5
conditions:
  - condition: state
    entity_id: script.btclock_signaal
    state: "off"
actions:
  - action: rest_command.btclock_leds
    data:
      kleuren: >
        {% set ns = namespace(k=[]) %}
        {% for s in ['sensor.bitcoin_24u_verandering', 'sensor.bitcoin_24u_verandering_usd'] %}
        {% set p = states(s) | float(0) %}{% set a = p | abs %}
        {% if p >= 0 %}{% set c = '#B9F6CA' if a < 1 else ('#4CE07A' if a < 5 else ('#00B33C' if a < 10 else '#00661F')) %}
        {% else %}{% set c = '#FFB3B3' if a < 1 else ('#FF5C5C' if a < 5 else ('#E00000' if a < 10 else '#7A0000')) %}{% endif %}
        {% set ns.k = ns.k + [{'hex': c}, {'hex': c}] %}
        {% endfor %}
        {{ ns.k | to_json }}

The trigger on sensor.btclock_uptime is there for after a restart. The LEDs then get their color back right away, instead of at the next 15-minute round.

Want to know when the clock drops out too? With the integration, that takes one automation:

alias: BTClock melding bij storing
triggers:
  - trigger: template
    id: klok
    value_template: "{{ now() - states.sensor.btclock_uptime.last_updated > timedelta(minutes=10) }}"
  - trigger: state
    id: koersfeed
    entity_id: binary_sensor.btclock_price_feed
    to: "off"
    for:
      minutes: 10
actions:
  - action: notify.mobile_app_jouw_telefoon
    data:
      title: BTClock
      message: "{% if trigger.id == 'klok' %}De klok geeft al 10 minuten niets door.{% else %}De koersfeed is al 10 minuten weg.{% endif %}"

Step 6: test

Send yourself a few sats through the Lightning Piggy and have someone zap one of your notes. If something goes wrong, look in Home Assistant at the automation under Traces. There you can see step by step what happened.

Handy: put the script on your dashboard as a card. That gives you a test button right away, in the app too.

Try it yourself

Send a few sats to:

zap@piggy.bitcoinstuffstore.com

Then my clock flashes pink and I hear in the kitchen that sats came in. You can add a short message, I'll read it on my phone. Every sat goes into the piggy bank.

FAQ

Do I need to know how to code?
No. You copy a few blocks of text into Home Assistant and change the IP address and your colors. For the Nostr script you use the prompt below.

Does this work at night too?
The clock does, even with "do not disturb" on. You can keep the speaker quiet with a time condition.

Can I choose other colors?
Yes. Any hex color works. You can also change how many times it flashes and how long the color stays in the automation.

Do I need a NerdQAxe++?
No, it's optional. If you have one, the BTClock also shows your hashrate.

Why does the screen show the amount and not the balance?
The amount comes with every payment. The balance is in your wallet. The BTClock can show a wallet's balance through Nostr Wallet Connect (the NWC Balance screen). Connect the piggy's wallet there and you'll see the balance too.

Can I have an AI build this for me?
Yes. Paste the prompt below into Claude or another AI assistant that can work in your terminal. Fill in the four details at the top first.

I want my BTClock (firmware v4) to light up when I receive sats. Help me build this step by step in Home Assistant. Explain each step simply and ask me to fill in passwords and keys myself.

My details:
- IP address of my BTClock: [fill in]
- Address of my Home Assistant: [fill in]
- My Nostr npub: [fill in]
- My Lightning Piggy runs on LNbits at: [fill in]

What I want:
1. Install the HACS integration dsbaars/homeassistant-btclock and add my clock as device "BTClock", with polling every 15 seconds. Also a rest_command in configuration.yaml for /api/lights/set.
2. A script "BTClock signaal" with the fields kleur, knipper, houd and bedrag: first turn off the screen cycle with switch.btclock_screen_timer and show the amount with btclock.show_custom (show_text turns +21 into the number 21), then flash 10 times in the color, hold for 20 seconds, then restore my own LED colors, set select.btclock_screen to Ticker and turn the screen cycle back on.
3. An automation with a webhook trigger for the pay link of my Lightning Piggy in LNbits: a notification on my phone and the script in pink (#FF1493) with the amount in sats (amount in the webhook is in millisats).
4. A small Python script that runs as a service on an always-on computer, listens on Nostr relays for zap receipts (kind 9735) for my npub, takes the amount from the bolt11 and calls a second webhook in Home Assistant. That automation calls the script in purple (#8E30EB).
5. Test each step before moving on, and tell me what I should see on the clock.

Leave a Comment

Your email address will not be published. Required fields are marked *

This website uses cookies

This site uses cookies to work properly and to analyze your visit. You choose what you allow. For more information, see our Privacy Policy and Cookie Policy. Privacy Policy Cookie Policy