Per Wramdemark Curious and passionate Java developer

Turning off the Christmas lights from a Kobo e-reader

Every December the same thing happens. My wife is in bed, reading on her Kobo, and says:

“Can you turn off the Christmas lights outside?”

Usually I’m the one who’s already half asleep. So this year I decided to solve the problem properly. If she’s holding an e-reader anyway, why can’t the e-reader turn off the lights?

🎄 The idea

We already run Home Assistant for most things in the house, including the Christmas tree and the outdoor Christmas lights. Both of our Kobos have NickelMenu installed, which lets you add your own items to the Kobo menu and run shell commands from them.

So the plan was simple:

  1. Add menu items on the Kobo: Julgran På/Av (Christmas tree on/off) and Julute På/Av (outdoor lights on/off).
  2. Let each button call Home Assistant over the local Wi-Fi.
  3. While I’m at it, add a Temperatur button that shows the temperature in every room. Nice to know before getting out from under the covers.

Here’s how all the pieces fit together. Home Assistant runs on a Raspberry Pi with a ConBee Zigbee USB stick. The Christmas tree is on an IKEA TRETAKT Zigbee plug, the outdoor lights are on two Tuya Wi-Fi plugs, and the temperatures come from eleven Zigbee sensors around the house.

Architecture: Kobo e-readers with NickelMenu call Home Assistant on a Raspberry Pi, which controls Zigbee and Tuya devices

💡 Controlling the lights

On the Home Assistant side there is a webhook automation. The Kobo calls a URL with the entity and the state it wants, and the automation turns it on or off. It only accepts calls from the local network, and only for entities on an allow list, so the Kobo can’t control anything else in the house.

triggers:
  - trigger: webhook
    webhook_id: <secret-id>
    allowed_methods: [POST, GET]
    local_only: true
variables:
  allowed:
    - switch.julgran
    - light.julbelysning_utomhus
  entity: "{{ trigger.query.entity | default('') }}"
  state: "{{ trigger.query.state | default('toggle') }}"
conditions:
  - "{{ entity in allowed }}"
  - "{{ state in ['on', 'off', 'toggle'] }}"
actions:
  - action: >-
      {{ 'homeassistant.toggle' if state == 'toggle'
         else 'homeassistant.turn_' ~ state }}
    target:
      entity_id: "{{ entity }}"

On the Kobo, a small script calls the webhook with BusyBox wget, and a NickelMenu file adds the buttons. Each button first asks the Kobo to connect to Wi-Fi, then runs the script:

menu_item :main :Julute Av :nickel_wifi :autoconnect
  chain_success :cmd_output :8000:sh /mnt/onboard/.adds/ha/ha.sh light.julbelysning_utomhus off

One tap, and the lights outside go dark. Nobody has to get up.

🌡️ Temperatures on the Kobo

The temperature button works the other way around. Instead of the Kobo asking Home Assistant for every sensor, Home Assistant writes a small text file every five minutes into its www folder, which it serves at /local/. The Kobo just downloads the file and shows it in a popup.

The automation picks up every temperature sensor, labels it with its room, and adds a timestamp at the bottom so you can see how fresh the numbers are:

Arbetsrum: 20.8°C
Garage: 11.2°C
Kök: 23.7°C
Sovrum: 21.1°C
Vardagsrum: 23.6°C
...

Uppdaterad: 2026-12-05 14:10

🐛 The bug that took the longest

The first version of the shell_command looked perfectly reasonable:

kobo_temps: "printf '%s\\n' \"{{ text }}\" > /config/www/kobo_temps.txt"

It ran without errors, but the file never showed up and the URL returned 404. It turns out that when a shell_command contains a template, Home Assistant runs it without a shell, for safety. Without a shell, > isn’t a redirect, so printf simply printed > and the file path as extra text.

The fix is to start the shell yourself and pass the text in as an argument:

kobo_temps: >-
  /bin/sh -c 'mkdir -p /config/www && printf "%s\n" "$1" > /config/www/kobo_temps.txt' kobo '{{ text }}'

A bonus is that the text is passed as $1, so nothing in it gets executed by the shell.

Two other small gotchas:

  • NickelMenu’s cmd_output timeout has to be under 10 seconds, so the script retries for about 8 seconds while Wi-Fi connects.
  • The Kobo’s BusyBox wget is very limited. It can’t send POST requests and has no SSL support at all, so HTTPS is out. That’s why the webhook accepts GET with the entity and state in the query string, and why everything runs over plain http:// on the local network.

🤖 Built together with Claude

I did most of this together with Claude Code. It talked to Home Assistant through the API to find the 404 bug, rewrote the temperature automation to use room names instead of “Temperatur Temperature” eleven times, and wrote the NickelMenu files directly to the Kobo over USB. When my wife’s Kobo was plugged in, it copied the same setup to hers.

✅ The result

Now the conversation goes like this:

“Can you turn off the Christmas lights outside?”

“There’s a button for that on your Kobo.”

She taps Julute Av, and the lights go out. Problem solved. 🎄

🔗 Open source projects used