GitHunt
CS

csells/SwitchBotFrame

๐Ÿ–ผ๏ธ SwitchBot AI Art Frame

Generate AI artwork with Google's Nano Banana Flash and display it on your SwitchBot AI Art Frame.

SwitchBot AI Art Frame

Features

  • AI Image Generation โ€” Describe what you want and pick an art style (cyberpunk, watercolor, fantasy, etc.). Powered by Google's Gemini image generation.
  • Frame Control โ€” Browse images on your frame with next/previous controls.
  • URL Upload โ€” Send any publicly-hosted image to your frame.
  • Auto-Discovery โ€” Finds your AI Art Frame automatically from your SwitchBot account.

Quick Start

# Clone
git clone https://github.com/csells/SwitchBotFrame.git
cd SwitchBotFrame

# Configure
cp .env.example .env
# Edit .env with your API keys (see below)

# Install & run
npm install
npm run dev

Open http://localhost:5173 in your browser.

Configuration

Copy .env.example to .env and fill in your values:

Variable Required Description
GEMINI_API_KEY โœ… Google AI API key for image generation. Get one at aistudio.google.com/apikey.
SWITCHBOT_TOKEN โœ… SwitchBot API token. See how to get credentials.
SWITCHBOT_SECRET โœ… SwitchBot API secret key. Found alongside the token.
IMGBB_API_KEY โœ… imgbb API key for hosting generated images. Get one at api.imgbb.com.
PORT โŒ API server port (default: 3001).

โš ๏ธ Privacy notice: Generated images are uploaded to imgbb.com and are publicly accessible. Do not generate anything private or sensitive.

Getting SwitchBot Credentials

  1. Open the SwitchBot mobile app
  2. Go to Profile โ†’ Preferences โ†’ App Version
  3. Tap the version number 10 times to unlock Developer Options
  4. Go back โ†’ Developer Options
  5. Copy your Token and Secret Key

Architecture

Browser (Vite :5173)  โ†’  API Server (Hono :3001)  โ†’  Google AI / SwitchBot APIs
       โ†‘                        โ†‘
   React + Tailwind       Reads .env credentials
  • frame.tsx โ€” React frontend with Tailwind CSS
  • api.ts โ€” API handler (image generation + SwitchBot commands)
  • server.ts โ€” Hono server with static file serving

In development, Vite proxies /api and /generated requests to the Hono backend.

Scripts

Command Description
npm run dev Start both Vite and API server with hot reload
npm run build Build the frontend for production
npm start Start the API server (serves built frontend from dist/)

Deploying

  1. Build: npm run build
  2. Deploy to any Node.js host (Fly.io, Railway, Render, etc.)
  3. Set env vars (GEMINI_API_KEY, SWITCHBOT_TOKEN, SWITCHBOT_SECRET, IMGBB_API_KEY)

License

MIT

Languages

TypeScript98.1%HTML1.4%JavaScript0.3%CSS0.1%

Contributors

Created March 6, 2026
Updated March 6, 2026
csells/SwitchBotFrame | GitHunt