critter-bridge — cloud IoT for standalone boards
critter-bridge is a small companion app that runs on a PC, Raspberry Pi or any always-on device on your LAN. It polls state from your Firefly boards and pushes it to free cloud IoT services (ThingSpeak first; Adafruit IO, InfluxDB Cloud and others on the roadmap) and to Telegram — things an ESP8266 cannot do reliably on its own. It also accepts board-originated Telegram pushes from newer firmware, so a rule can deliver an alert immediately instead of waiting for the next poll.
Who needs it
- ESP8266 users who want remote visibility (ThingSpeak charts, Telegram alerts) without Home Assistant.
- ESP32 users who prefer a centralised setup: secrets live on the bridge, not on the board.
If you already run Home Assistant, you don't need the bridge — keep using HA's MQTT integration. If you have a single ESP32 board and no always-on device, use ESP32 direct cloud mode instead.
How it works
- Polling (pull). The bridge polls each board's existing
/api/dashboardendpoint every 15–30 s for ThingSpeak and bridge-side rules. - Board push (optional). Newer critterOS firmware posts Telegram triggers to
POST /api/telegram/send. The endpoint queues the message and returns202immediately; a background worker calls Telegram. The board finds the bridge through the Logger server name (logger_host, or legacyserver_name) on port8787, so there is no separate bridge-host setting. - ThingSpeak (first backend). Forwards panel values to a ThingSpeak channel (one board = one channel by default, so multiple boards never contend for the free-tier ~15 s update cadence).
- Rules → Telegram. Panel-state conditions (threshold, hysteresis, per-rule cooldown) trigger Telegram messages. Bridge rules skip
telegrampanels because the board handles those triggers itself. - Local web UI on port 8787 for board registry, ThingSpeak field mapping, rules, settings and an event log.
Telegram setup
Enter the bot token and a default chat id in the bridge's Settings card. The test button and board-originated pushes both use that chat unless the sender supplies an explicit chat_id.
POST /api/telegram/send
Content-Type: application/json
{“text”:“pressure is high”,“device”:“firefly”,“panel”:“tg1”}
Requires a configured telegram_token and either telegram_chat_id or a chat_id in the request. Returns 202 {"ok":true,"queued":true} on success, 400 for missing configuration, or 503 if the queue is full.
IR decode
The bridge also hosts a small IR decoder so boards keep no protocol library and low RAM. Firefly's ir_remote input panel captures raw IR; the board then asks the bridge for a slot-ready code.
GET /api/ir/decode?raw=RAW:38000,9000,4500,... (also POST JSON {"raw": ...}; CORS *)
→ {"ok":true, "code":"NEC:8F701FE:32", "protocol":"NEC", "hz":38000}- Prefers full protocol decoding with
mode2_decode(from IRremoteESP8266; bundled attools/mode2_decode, built bytools/build_mode2_decode.sh, also searched intools/and PATH); falls back to lightweight Python decoders for NEC and ELECTRA_AC. codeis slot-ready for a Firefly IR panel:NEC:<hex>:<bits>,ELECTRA:<hex>, orRAW:38000,…. Other protocols are reported inprotocolbut returned slot-ready asRAW; unknown → raw unchanged;ok:falseon empty/short capture.- Board integration (automatic): a Firefly board calls this when its logger host (
logger_host, or legacyserver_name) is this bridge, port 8787, via itsGET /api/ir/decode?id=…endpoint. The board uses the bridge'scodeonly whenokandprotocol != RAW, otherwise returns the raw capture; unreachable bridge → raw. - The capture → slot workflow: add an
ir_remoteinput, press any key, fetchGET /api/ir/raw/GET /api/ir/decodeon the board, paste the slot-ready code into one of anir_txIR panel's 4 slots, then triggersend1…send4from a rule. See the board API reference.
Quick start
git clone https://github.com/mfacen/critter-bridge
cd critter-bridge
./run.sh # creates the Python venv on first run
# open http://localhost:8787Requirements: Python 3.9+. The app creates config.json on first run; boards are auto-discovered from their UDP beacon, so you rarely need to type an IP.
Design notes
- Trusted LAN. Traffic between the bridge and boards is plaintext HTTP, matching critterOS's hobbyist stance. Do not expose the board or the bridge beyond your LAN.
- Polling wakes the OLED.
/api/dashboardcounts as a viewer in critterOS, so a polled board keeps its display awake. - Secrets stay on the bridge. In bridge mode, ThingSpeak keys and Telegram tokens never reach a board. ESP32 direct mode is the exception: that board stores its own ThingSpeak/Telegram credentials.
Source
critter-bridge is a separate repository: github.com/mfacen/critter-bridge.