| |

I Made Home Assistant Run My Christmas Countdown

Every night until Christmas, the big frame on my table gets one more ornament on its tree, and the small frame next to it gets a brand-new piece of art with the days left until Christmas. I don’t touch either of them. Home Assistant does it at five past midnight.

TL;DR: Yes, Home Assistant can run a Christmas countdown on SwitchBot AI Art Frames for the whole month without you touching it. A nightly automation sends the day’s advent tree to one frame and has Gemini paint a new countdown picture for the other. A small Python script deletes the oldest image on the frame first, so the original frame’s 10-picture limit never gets in the way. All the files are on GitHub, setup takes six steps, and the Gemini images cost about four cents each.

SwitchBot sent me the original frames last year and the new AI Art Frame 2 a few days before this video. Nobody paid for this post or the video.

What you’re building

Last year I did this by hand. Every Sunday night I’d generate seven images and upload them to the frames one at a time. This year I set it up once and let it run for the season.

  • The big frame gets an advent tree with 24 spots. One new ornament gets added every night. All 25 pages (day-01 through day-25) are made ahead of time and live in a folder in Home Assistant.
  • The small frame doesn’t get anything made ahead. Every night Home Assistant asks Gemini for a brand-new picture, the script puts the countdown on it, and it goes to the frame.

Both frames use flat, bold art on purpose. The panel only has six colors, and on the original frames anything soft or photo-real tended to come out speckled. That has improved a lot with firmware updates over the past year, but flat art still looks the best.

You’re not limited to Christmas, either. The same setup can rotate any set of pictures all year (more on that at the end).

The 10-picture catch, and how SwitchBot fixed it

There was one catch, and it almost killed the whole idea. The original (Gen 1) AI Art Frame only holds 10 pictures. Upload number eleven just fails, and Home Assistant only calls it an “unknown error.” I had to dig into the logs to find the real cause: the frame was full.

Ten pictures is fine for a slideshow. A countdown needs 25. The SwitchBot app can delete images, even when you’re away from home, but the public API couldn’t, so there was no way to automate it.

I asked my contact at SwitchBot for a delete command, fully expecting to hear “it’s on the roadmap.” Three days later they’d added it. The API command is deleteImage. You tell it to delete the oldest, newest or a random image, and it never deletes the picture that’s on the screen. SwitchBot’s docs only list it for the Frame 2, but I tested it on the original frame and it works.

Every night the script gets the new picture ready first, then deletes the oldest one, then uploads the new one. That order matters: if anything goes wrong with the new picture, nothing gets deleted, so you never lose a picture without a new one ready to replace it.

How it works

  1. Every night at 12:05 AM, from December 1 to 25, an automation in Home Assistant runs two scripts.
  2. The first picks today’s tree image out of a folder and sends it to the big frame.
  3. The second asks Gemini for a new picture and hands it to a small Python script.
  4. The Python script crops the picture to fit the frame, adds the countdown text, deletes the oldest image on the frame and uploads the new one straight to SwitchBot’s API.
  5. If anything fails, Home Assistant sends you a notification.

This doesn’t use the built-in SwitchBot Cloud integration in Home Assistant. Right now that integration doesn’t support the delete command or the Frame 2, so the script talks to SwitchBot’s API directly. The image goes up as part of the request itself, so there’s no public link and nothing on your network is exposed to the internet. It does go through SwitchBot’s cloud, though, so if your internet is down at midnight, that night’s image gets skipped.

What you’ll need

  • Home Assistant, with a way to edit files in /config (Studio Code Server, Samba or similar).
  • Your frames set up in the SwitchBot app and connected to Wi-Fi, so they can reach SwitchBot’s cloud.
  • An AI image generation integration in Home Assistant. I use Google Gemini.
  • The files from the This Smart House SwitchBot-Frame repo on GitHub.

Setup in six steps

Step 1: Get your SwitchBot token and secret

In the SwitchBot app, go to your profile, then Preferences, About, and Developer Options. Tap to apply for developer keys, and both keys will show up. Treat them like passwords, and add them to secrets.yaml in your config folder:

switchbot_token: "your-token"
switchbot_secret: "your-secret"

Step 2: Download the files

Go to the GitHub repo, click the green Code button, choose Download ZIP and unzip it. I keep the files on GitHub instead of attaching them here so I can fix things in one place if anything changes.

Full disclosure: I wrote this code with Claude’s help, and I tested every piece of it on all three of my frames before publishing it.

  • Drag the whole scripts folder into /config. That gives you /config/scripts/switchbot_frame.py and the caption font in /config/scripts/fonts/.
  • Put switchbot_frame.yaml in /config/packages/. (switchbot_frame_gallery.yaml is optional; see the end of this post.)

Packages let one YAML file bring in automations, scripts and everything else together. If you’ve never used them, add this to configuration.yaml. The packages line has to sit under homeassistant:, or Home Assistant will complain that it can’t find an integration called “packages”:

homeassistant:
  packages: !include_dir_named packages

Step 3: Add your frames’ device IDs

In the SwitchBot app, open the frame’s settings, then Device Info. There are a few IDs listed; the one you want is the BLE MAC, without the colons. For example, B0:E9:FE:12:34:56 becomes B0E9FE123456.

In switchbot_frame.yaml, replace REPLACE_WITH_BIG_FRAME_ID with the frame that shows the tree and REPLACE_WITH_SMALL_FRAME_ID with the frame that shows the AI countdown. The package is built for two frames. If you only have one, you can merge the settings from one script into the other, including the image size.

Step 4: Add the tree images and the blank canvas

You can use my tree pack from the GitHub page, or open my Canva design and make your own version. I used Claude to generate a lot of the ornament art from detailed instructions, then added the day numbers and tweaked some of the ornaments myself.

  • Put the 25 tree images (day-01.png to day-25.png) in /config/countdown/tree/. It’s about 68 MB, so the upload takes a couple of minutes.
  • Put the blank portrait_canvas_3x5.png in /media/countdown/. If you can’t reach the media folder from Studio Code Server, create the folder from the terminal (cd /media then mkdir countdown), then upload the image from Media → My media → countdown → Manage → Add media.

That blank image is a trick. Gemini tends to copy the shape of whatever you attach, so a tall, empty canvas gets you a tall picture back.

Step 5: Set up Gemini

This is the step that took me the longest. Image generation doesn’t work on Gemini’s free tier; it just comes back with a quota error. In Google AI Studio I made a separate project, turned on billing and created an API key just for images. That way my other Gemini automations stay on the free tier.

  1. Copy the new key (treat it like a password).
  2. In Home Assistant, go to Settings → Devices & services → Add integration, search for Google Gemini, paste the key and submit.
  3. Open the integration’s AI Task settings and copy the AI Task entity ID.
  4. In switchbot_frame.yaml, replace ai_task.REPLACE_WITH_YOUR_AI_TASK_ENTITY with it.

Step 6: Restart and test

Restart Home Assistant so it picks up the new files. You’ll see two new automations, Art Frame: Christmas countdown and Art Frame: daily gallery. Because they come from a package, the UI says they can’t be edited there. You can move them into your own automations.yaml if you want to edit them from the UI.

To test without waiting for midnight, open the script Art Frame: generate today’s AI countdown for the small frame and click Run script, or run it from Developer Tools:

action: script.art_frame_ai_countdown

Within a few seconds the frame should start updating, as long as it’s online. The trace shows exactly what happened. The image in Home Assistant’s Media (AI generated images) won’t have the caption; the script adds that on its way to the frame, so check the frame or the SwitchBot app to see the finished version. On Christmas Day the caption changes to “Merry Christmas.”

To test the tree on a specific day:

action: script.art_frame_tree_today
data:
  day: 1

Starting late? The scripts use today’s date, so if you set this up on December 5, you get the day-5 tree. There’s nothing to catch up.

Does it actually run itself?

I ran the whole chain on both of my original frames through the last week of November, plus a few test scripts that push a specific day, and everything worked, including on the Frame 2. Since December 1 the 12:05 AM automation has been running on its own.

  • Home Assistant side: fast. The small frame gets its picture about two seconds after Gemini finishes; the big tree takes about three.
  • The frame itself is the slow part. E Ink builds the picture one color at a time, and the big frame takes about 30 seconds. At five past midnight nobody’s watching, so it only matters if you run it during the day.
  • The 10-picture limit never came up, because every run clears the oldest image first.
  • Cost: my seven test images cost 27 cents, about four cents each, so the whole month is under a dollar. If you’d rather skip AI, make the images ahead of time (in Canva, for example) and load them from a folder instead.

The part that took the most tuning was the layout. Gemini kept drawing borders and leaving the bottom of the picture blank, and my first countdown captions ran right off the edge of the frame. The current prompt asks for a full, edge-to-edge picture, and the script sizes the text to fit. If Gemini still gives you a strange picture, it’s only up for one night, or you can run the script again to get a new one for the same day.

What about the AI Art Frame 2?

The Frame 2 runs the same countdown with the same script. Home Assistant’s SwitchBot integration doesn’t know about the Frame 2 yet, but that doesn’t matter here, because the script talks to SwitchBot’s API directly.

  • Design: no more white mat around the picture. The Frame 2 runs edge to edge in a walnut-style frame.
  • Screen: both generations use the same E Ink Spectra 6 panel, which mixes six colors of ink. Side by side, they take about the same time to refresh.
  • Storage: the original holds 10 pictures. SwitchBot says the Frame 2 holds around 5,000 in its built-in memory. The script still deletes the oldest image every night so the same setup works on both; you can remove that step on a Frame 2 if you like.
  • Battery: SwitchBot rates the Frame 2 at up to about three years, even with a daily change. The 7.1-inch has a 5,000 mAh battery, and the 13.3-inch and 31.5-inch have 20,000 mAh. The original 13.3-inch has 2,000 mAh, so that’s ten times the battery.
  • Extras: an accelerometer so it always orients pictures correctly, a button on the back that changes the picture (to a painting from SwitchBot’s collection or one stored on the frame), and a knock-three-times gesture that runs a separate command. With SwitchBot’s AI Studio subscription you can even say what you want and have it generate art right from the frame.

The Frame 2 starts at $169.99 for the 7.1-inch, and the 13.3-inch I have is about $299.99 (prices at the time of writing). SwitchBot’s AI art subscription is around $4 a month, but you don’t need it for anything in this post. If you already own an original frame, the delete command means you don’t need to upgrade to do any of this.

Not just for Christmas

So this doesn’t turn into a once-a-year project, the GitHub repo includes a second package, switchbot_frame_gallery.yaml, that rotates a folder of your own pictures. Drop photos or artwork in /media/frame_gallery/, and every morning it puts a new one on the frame, in order or at random. It skips December 1 through 25, so it won’t fight the countdown, and you can leave both installed all year. Delete the countdown package if you don’t need it.

On photos: on the original frames they still come out a little oversaturated, but they look a lot better on the Frame 2. Most photos I tried straight off my phone looked good. Flat, bold art still works best.

On battery: SwitchBot rates the original at up to two years with one change a week. I haven’t charged either of mine in over a year and they’re both sitting around 50%, but I only changed them a few times all year. Changing the picture is what uses the power, so a daily change will drain them a lot faster. Home Assistant shows each frame’s battery level, so you can set up a notification for when it gets low. I’ll post where mine end up in the video’s pinned comment after December.

Verdict

Can Home Assistant run a Christmas countdown for the whole month without you touching it? Yes. Once it’s set up, the frames take care of themselves until Christmas, for about a dollar of Gemini images.

  • It’s for you if you already run Home Assistant and have one of these frames. Plan on an afternoon of setup.
  • Skip it if you don’t use Home Assistant. The SwitchBot app can still rotate pictures on a schedule; you’ll just be loading them in batches, the way I did last year.

Thanks to SwitchBot for sending the frames and for turning around the API request so quickly. If you want the outside of your house running on its own too, here’s how I control my Govee lights from Home Assistant, with themes AI designed for me. And if you build your own version of this, I’d like to see it in the video’s comments.

Similar Posts

Leave a Reply

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