Server webhook online menyimpan trigger ke queue. Trigger bisa diambil oleh app lokal atau langsung oleh NodeMCU WiFi version.
Browser / sistem online -> /fire -> queue server -> /poll -> relay ON
Jika app lokal dan NodeMCU sama-sama polling machine ID yang sama, queue akan diambil oleh yang polling duluan. Pilih salah satu mode polling.
| Variable | Contoh | Keterangan |
|---|---|---|
WEBHOOK_KEY | secret123 | Key untuk authorize endpoint /fire, /webhook, /poll, /status. Set di environment hosting/server. |
DEFAULT_MACHINE | default | Machine ID default kalau request tidak mengirim machineId. |
PORT | 3000 | Port server, biasanya otomatis dari hosting. |
Query : ?key=secret123
JSON body : {"key":"secret123"}
Form body : key=secret123
Header : x-webhook-key: secret123
Bearer : Authorization: Bearer secret123
| Field | Isi |
|---|---|
| Server URL | https://domain-kamu tanpa slash akhir juga boleh. |
| Webhook Key | Sama dengan WEBHOOK_KEY server. |
| Machine ID | Contoh default, harus sama dengan URL trigger. |
| Enable online polling | Centang jika app lokal yang akan polling server. Jangan centang jika NodeMCU yang polling langsung. |
Klik Save Online Webhook. App akan mengirim config ke NodeMCU lewat USB serial.
Jika tidak lewat app, kirim command ini dari Serial Monitor:
WIFI:nama_wifi,password WEBHOOK:https://domain-kamu KEY:secret123 MACHINE:default W
Setelah sukses, Serial Monitor akan menampilkan:
WiFi Connected! HTTP Server started! Online Webhook: https://domain-kamu Online Machine: default
https://domain-kamu/fire?key=secret123&machineId=default&command=F
POST https://domain-kamu/fire
Content-Type: application/json
{"key":"secret123","machineId":"default","command":"F"}
GET https://domain-kamu/webhook?key=secret123&machineId=default&command=F
POST https://domain-kamu/webhook
Content-Type: application/json
{"key":"secret123","machineId":"default","command":"F"}
POST https://domain-kamu/webhook Content-Type: application/x-www-form-urlencoded key=secret123&machineId=default&command=F
Response sukses:
{"ok":true,"queued":true,"machineId":"default","job":{"id":"...","command":"F","createdAt":"..."}}
Dipakai app lokal atau NodeMCU untuk mengambil queue.
https://domain-kamu/poll?key=secret123&machineId=default
Jika ada trigger:
{"ok":true,"machineId":"default","fire":true,"job":{"id":"...","command":"F","createdAt":"..."}}
Jika kosong:
{"ok":true,"machineId":"default","fire":false,"job":null}
Buka dashboard:
https://domain-kamu/
Isi field Key di dashboard agar bisa melihat event lengkap dan test Queue Fire.
| Gejala | Cek |
|---|---|
unauthorized | Pastikan key di URL/app/NodeMCU sama dengan WEBHOOK_KEY. |
| Queue masuk tapi relay tidak hidup | Pastikan app lokal atau NodeMCU sedang polling machine ID yang sama. |
NodeMCU print WEBHOOK_ERROR_... | Cek URL server, koneksi internet WiFi, dan apakah server online aktif. |
| Dashboard pending terus bertambah | Tidak ada client yang polling, atau machineId tidak sama. |