CS2 Bomb Timer Story

💣 CS2 Bomb Timer

for the Ulanzi D200 StreamDeck

A Ulanzi Studio plugin that turns one D200 key into a Counter-Strike 2 C4 timer. When the bomb is planted the key starts at 40 and counts down inside a shrinking ring.

CS2 starts it automatically through Game State Integration (GSI).

Interactive — watch the countdown ring in action

Use ← → arrows or click the dots below to navigate

🎨 Key States

The colour and label change as time runs out, telling you at a glance whether a defuse is still possible.

Time LeftRingLabel
> 10 s● OrangeBOMB
6 – 10 s● RedKIT ONLY — only a kit defuse (5 s) can still make it
≤ 5 s● Red, flashingTOO LATE
Round ends● Green / Red burstDEFUSED / BOOM → then C4 / READY
Backend offline◌ Dashed greyOFFLINE

All Key States

All key states rendered on the D200

Pressing the key starts/stops a manual 40 s countdown (amber M badge). A real CS2 plant replaces it.

🏗️ Architecture

The data flows from Counter-Strike 2 through a lightweight Python server to the Ulanzi plugin and onto the physical key.

🎮 CS2 Game Client
──GSI POST──▶
🐍 bomb_timer.py 127.0.0.1:3000
◀──GET /state──
🔌 Ulanzi Plugin Polls ~12×/s
──▶
⌨️ D200 Key 144×144 canvas

How the Backend Works

  • CS2 reports round.bomb = planted / defused / exploded to players, but not the countdown itself
  • The backend notes the moment of the plant and counts 40 s from there
  • If CS2 sends a countdown (spectating / GOTV), the backend re-syncs to it
  • If the timer reaches 0 and no exploded event arrives within 2.5 s, the bomb is assumed to have exploded
  • When the next round starts, the state goes back to idle

How the Plugin Works

  • Polls every 80 ms (~12×/s). A request times out after 400 ms; new ones never overlap
  • Between polls it interpolates the time left from the last value received
  • Key image is only re-sent when the signature changes (number, phase, or flash frame)
  • A whole round takes about 45 image updates
  • If no poll succeeds for 1.5 s → OFFLINE. One dropped poll doesn't trigger it
  • Worker-based timers.js so the hidden WebView doesn't slow them down

💡 LED Strip Add-on

A WS2812B / NeoPixel strip that reacts to the bomb in real time, driven by an ESP32 or Arduino Nano over USB serial.

LED Effects

EventAnimation
Bomb beep🔴 Red flash — synced to the C4 beep cadence (accelerates as time runs out)
Armed glow🟠 Dim orange pulse between beeps
Defused🟢 Green sweep/chase across the strip
Exploded⚪ White flash → 🟠 expanding fireball → fade to dark
IdleLEDs off

Live LED Preview

How It Connects

🐍 bomb_timer.py/state
◀─ poll 10×/s ─
🔗 led_bridge.pymodels C4 beeps
── USB serial ──▶
⚡ ESP32 / NanoFastLED firmware
──▶
💡 WS2812BLED strip

Full details: parts list, wiring diagrams, WLED alternative → LED_SETUP.md

📂 Project Structure

Click folders to explore the tree.

com.ulanzi.cs2bombtimer.ulanziPlugin/
manifest.json — plugin + action metadata
en.json — English strings
plugin/
app.html — main service entry point
app.js — websocket events, polling, key instances
actions/
bombLogic.js — pure state machine (Node-testable)
bombRenderer.js — canvas drawing: ring, number, label
property-inspector/timer/
inspector.html — settings panel UI
inspector.js — settings sync & status
libs/
Ulanzi common-html SDK (Apache-2.0)
assets/icons/
icon.png, actionIcon.png, categoryIcon.png, ready.png
backend/
bomb_timer.py — GSI listener + /state JSON
cs2/
gamestate_integration_bomb.cfg
tools/
mock_gsi.py — fake CS2 round
preview.html — all key states in a browser
led_controller/
led_controller.ino — ESP32/Nano firmware (FastLED)
led_bridge.py — polls /state, drives strip
tests/
test_bomb_timer.py — 16 Python tests
bombLogic.test.js — 15 Node tests
test_led_bridge.py — 8 bridge tests
README.md
LED_SETUP.md — LED hardware guide

🛠️ Setup

1

CS2 GSI Config

Copy gamestate_integration_bomb.cfg into your CS2 cfg folder:

Windows: C:\Program Files (x86)\Steam\steamapps\common\
         Counter-Strike Global Offensive\game\csgo\cfg\

Restart CS2 — it only reads GSI files at startup. The file name must start with gamestate_integration_.

2

Backend

Python 3.8+. No packages needed.

python backend/bomb_timer.py            # basic
python backend/bomb_timer.py --voice    # + spoken callouts
OptionDefaultDescription
--port3000GSI POST + GET /state
--tokenCS2BOMBTIMERMust match .cfg; "" disables
--bomb-time40C4 fuse length (seconds)
--voiceoffpyttsx3 / macOS say / Win SAPI
3

Plugin

  1. Quit Ulanzi Studio completely
  2. Copy the whole com.ulanzi.cs2bombtimer.ulanziPlugin folder to:
    %APPDATA%\Ulanzi\UlanziDeck\Plugins\
  3. Start Ulanzi Studio. Drag CS2 Bomb Timer → Bomb Timer onto a key.
  4. The key shows C4 / READY. If it shows OFFLINE, check the backend.

Requires Ulanzi Studio 2.1.4+

🧪 Testing Without the Game

Mock GSI

python backend/bomb_timer.py
python tools/mock_gsi.py                                # plant → BOOM at 0
python tools/mock_gsi.py --outcome defused --defuse-at 7
curl -X POST http://127.0.0.1:3000/manual/start         # backend-side 40 s countdown
curl -X POST http://127.0.0.1:3000/reset

Browser Preview

Open tools/preview.html — its lower half polls /state the same way the plugin does.

Unit Tests

python -m unittest discover -s tests      # 24 Python tests
node --test tests/bombLogic.test.js       # 15 plugin logic tests

Test Coverage

16
Backend
(Python)
15
Plugin Logic
(Node.js)
8
LED Bridge
(Python)

📡 /state JSON Contract

Click any field to see its description.

"status""planted" idle | planted | defused | exploded
"time_remaining"23.418 Seconds (float) while planted, otherwise null
"seconds"24 ceil(time_remaining) — what the key shows
"phase""bomb" bomb | kit_only | too_late while planted, otherwise = status
"bomb_time"40 Total fuse time in seconds
"source""gsi" gsi | manual | null — where the countdown came from
"status_age"16.58 Seconds since status last changed — prevents stale DEFUSED/BOOM on startup
"inferred"false true = "exploded" assumed (no GSI event 2.5 s after reaching 0)
"gsi_connected"true A GSI packet arrived in the last 30 s
"map""de_mirage" Current map name from CS2
"version""1.0.0" Backend version string

Compatibility

The plugin only needs status and time_remaining. It also accepts state, remaining, time_left, or countdown — so an existing script with different field names usually still works.

⚠️ CORS: Your backend must send Access-Control-Allow-Origin: * on /state. Without it the Ulanzi Studio WebView blocks requests and the key shows OFFLINE.

✅ Test Status & License

What Has Been Tested

✅ 16 backend tests pass ✅ 15 plugin logic tests pass ✅ 8 LED bridge tests pass ✅ Official UlanziDeck Simulator ✅ CORS headers verified

Simulator coverage: main service connects, add draws C4/READY, mock GSI round transitions through all phases, key press toggles manual countdown, killing backend shows OFFLINE, settings sync works.

What Has NOT Been Tested

⚠️ Real D200 hardware ⚠️ Real Ulanzi Studio app ⚠️ Live CS2 match

Things to check on hardware:

  • Plugin loads from the plugins folder
  • Key image is sharp and correctly scaled (144×144)
  • Manual press works (run event)
  • Countdown starts promptly on real plant

License

ComponentLicense
Plugin codeMIT
Ulanzi SDK (libs/)Apache-2.0