TingPush Camera AI

Integration docs

Peripherals — opening barriers, roller doors, sirens and lights from a TingPush camera

Bản tiếng Việt

A TingPush camera can drive external equipment: barrier gates, roller doors, magnetic locks, sirens, lights, LED signs…

  • The camera acts on its own when it reads a plate or raises an AI event — e.g. a car on the allow list reaches the gate and the barrier opens. Rules run on the camera itself, so the gate still opens when the Internet is down.
  • Remote control through the TingPush server: the Mở barie (Open barrier) button in the app, the web viewer and the Windows software, or your parking software calling the API.

Every open / close is logged by the camera with who did it and why (an event of type io) — see Sự kiện AI (AI events) in the app / web.

The TingPush apps are in Vietnamese; screen labels are quoted as they appear, with a translation in parentheses.


1. Wiring devices to the camera

Each camera has up to 8 devices (outputs); each one uses one of 3 connection types:

Connection Use it when You need
On-board relay (GPIO) The barrier / roller door has an open push-button input (dry contact) near the camera An opto-isolated 3.3 V relay module, a signal wire from a GPIO pin on the camera board
RS485 / serial port A barrier controller, relay board or LED sign takes commands over RS485 / RS232 A UART on the board (/dev/ttyS…) + an RS485 transceiver (auto-direction type), or a USB-RS485 adapter
Network relay (URL) The device is far from the camera, or you already use a WiFi / LAN relay A network relay with an HTTP API: Shelly, Sonoff (Tasmota), USR-IO, a home-made ESP32, a barrier controller with an API… on the camera's local network

On-board relay (GPIO)

 Camera board             Relay module (opto)                 Barrier controller
 ────────────             ───────────────────                 ──────────────────
 3.3 V  ─────────────────  VCC
 GND    ─────────────────  GND
 GPIO   ─────────────────  IN            COM ────────────────  OPEN / push-button (common)
                                         NO  ────────────────  OPEN / push-button
  • Never wire a GPIO pin straight to a motor, a solenoid or a 12/24 V supply — the pin only handles 3.3 V and a few mA.
  • The GPIO number is the Linux number: on Rockchip chips, pin GPIOx_yz = x × 32 + (y: A=0, B=1, C=2, D=3) × 8 + z. E.g. GPIO3_A1 = 3×32 + 0×8 + 1 = 97. Free pins on the camera board are listed in the board maker's pinout.
  • Mức bật (Active level): choose Mức cao (High) for a high-triggered relay module, Mức thấp (Low) for a low-triggered one.
  • A barrier usually only needs a pulse (like pressing the open button on its remote): set Thời gian mở (Open time) to 300–1000 ms.

RS485 / serial port

  • Pick the port (e.g. /dev/ttyS1) and speed (usually 9600), then enter the open command and (optionally) the close command as hex, e.g. the common LCUS relay board: channel 1 on A0 01 01 A2, off A0 01 00 A1.
  • The bytes are defined by the device maker — see your barrier controller / relay board manual. For Modbus RTU relay boards, enter the whole frame (including the CRC).
  • 8N1, no handshake. Use an auto-direction RS485 transceiver.

Network relay (call a URL)

The camera calls the URL on its own local network (not through the server). Examples:

Device Open / on URL Off URL
Shelly Gen1 http://192.168.1.50/relay/0?turn=on http://192.168.1.50/relay/0?turn=off
Shelly Gen2+ http://192.168.1.50/rpc/Switch.Set?id=0&on=true …&on=false
Tasmota http://192.168.1.51/cm?cmnd=Power%20On …Power%20Off
Shelly with auto-off timer http://192.168.1.50/relay/0?turn=on&timer=1 (leave empty)
  • Method GET / POST / PUT; POST / PUT send the Nội dung (Body), e.g. JSON.
  • The Header xác thực (Auth header, e.g. Authorization: Basic dXNlcjpwYXNz) is stored on the camera and is never returned by the app / API (it only shows "Đã đặt", Set).
  • HTTP 2xx counts as success; any other status or a connection failure is logged as an error (shown next to the device name).

Open (pulse) vs On / Off

  • Open time > 0 (barriers, door locks): Mở (Open) = switch on, then switch off automatically after that many milliseconds.
  • Open time = 0 (lights, sirens): Bật / Tắt (On / Off) stay as they are until the next command.

2. Setup

The camera owner configures it in any of these places (one shared configuration, stored on the camera in /userdata/lpr/io.conf):

  • TingPush Camera app → Cài đặt camera (Camera settings) → Thiết bị ngoại vi (Peripherals)
  • Web https://webrtc.tingpush.com → Camera của tôi (My cameras) → Thiết bị (Devices) button
  • Windows software → Cài đặt camera → Ngoại vi tab
  • The camera's own config page (http://<camera IP>/) → Ngoại vi tab (works without Internet)

After adding a device, press Mở thử (Test open) to check the wiring before creating rules.

3. Automatic rules

Up to 16 rules per camera: when <event> then <device> <open / on / off>.

Event When
Biển trong danh sách cho vào (plate_allow) The camera confirms a plate that is on the allow list and still valid
Biển không trong danh sách (plate_deny) The camera has a list but the plate is not on it (e.g. turn on an amber light / alert the guard)
Đọc được biển bất kỳ (plate_any) Every confirmed plate (open parking that only logs)
Xâm nhập vùng cấm (intrusion) A person / vehicle enters a restricted zone (AI feature)
Quá đông (occupancy) The number of people / vehicles inside exceeds the limit
Người quen / người lạ (face_known / face_unknown) Face recognition
Chấm công thành công (attend_ok) Face time attendance — unlock a door / turnstile for employees (Face time attendance — a TingPush camera as a time clock)
AI tùy chỉnh (custom:<id>) A custom AI model detection (installed on the camera config page)
  • Giờ chạy (Active hours): empty = all day; e.g. 06:00-22:00 or several ranges 06:00-11:30,13:00-22:00; ranges may cross midnight (20:00-02:00).
  • Không lặp lại (Don't repeat, seconds): after a rule fires it waits that long before firing again (e.g. 30 s for a siren).
  • One event can trigger several rules (e.g. open the barrier and switch on a light).

Example — apartment gate: Allowed plate → Entry barrier → Open; Plate not on the list → Amber light → Open (5000 ms pulse); the guard sees the light, checks the car and presses Mở barie in the app.

4. Allow list (vehicles let in)

Lists live on the TingPush server, up to 50 lists × 20,000 vehicles per account:

  • App → Cài đặt camera → Danh sách xe cho vào (Allow list); web → Danh sách xe (Vehicle lists); Windows software → Danh sách xe.
  • Each list is assigned to one or more cameras (only cameras you own). A camera uses all lists assigned to it, merged.
  • Each vehicle: plate, owner name / note, valid from – valid through (empty = no limit). Once expired, the camera refuses it automatically — no need to delete.
  • A plate ending in * is a pattern: 51F* = every plate starting with 51F (company or official vehicles…).
  • Bulk import from Excel / CSV: one line per vehicle plate, name, from date, to date, note (dates dd/MM/yyyy; comma, semicolon or tab; a header line is skipped). Tick Thay toàn bộ (Replace all) to mirror a whole list from another system.

The camera keeps a copy: when a list changes (after ~2 s), when the camera reconnects, and on a 10-minute sweep, the server tells the camera to download the new version (SHA-256 checked). The camera stores it in /userdata/lpr/allow.db and looks plates up locally, so the barrier still opens for listed vehicles without Internet. The status "Camera đang giữ N xe — bản mới nhất" (Camera holds N vehicles — latest version) shows on the Peripherals and Vehicle lists pages, with Gửi lại xuống camera (Resend to camera) and Thử 1 biển số (Test a plate).

Plates the camera sends (to TingPush or to your own API) carry "allowed": true|false and "allow_name" when the camera has a list.

5. Remote open — control permission

Who May open the barrier / switch devices
Camera owner Always
Users shared as "Chỉ xem" (View only) Only when the owner ticks Được mở barie (May open barrier) — when sharing, or later in the shared-users list
API keys Only keys created with Điều khiển thiết bị & sửa danh sách xe (Control devices & edit vehicle lists)

The open button appears in: the app's live view (a large button under the video, floating over the video in full screen), the web camera grid (bottom-left of each tile), the Windows software (right-click a tile → Mở barie / thiết bị, and the toolbar of the single-camera window). The command goes app → server → the connection the camera keeps open to the server, usually in under a second; the camera must be online.

6. API for parking software

Use an API key as in TingPush public API — fetching stored plate data (X-Api-Key: tp_…, plan with API access). Calls that change something (opening, editing lists) need a key with Điều khiển thiết bị & sửa danh sách xe — read-only keys get 403.

`GET /api/v1/cameras/

{ "data": [ { "index": 0, "name": "Barie cổng vào", "type": "gpio", "pulse_ms": 500,
              "state": { "on": false, "last": 1792170903, "last_by": "API: Phần mềm bãi xe", "error": "" } } ] }

`POST /api/v1/cameras/

curl -X POST -H "X-Api-Key: tp_xxx" -H "Content-Type: application/json" \
     -d '{"action":"pulse"}' https://apiwebrtc.tingpush.com/api/v1/cameras/LPR-9MHK902C8J5Z/outputs/0/trigger

action: pulse (open — default), on, off. Returns {"ok":true,"message":"Mở Barie cổng vào — API: Phần mềm bãi xe"}. Errors: 403 (read-only key / no control permission on the camera), 404 (no such camera), 503 (camera offline or the device reported an error — message says why).

Vehicle lists

Call
GET /api/v1/platelists lists: id, name, count, cameras (id, name, synced)
GET /api/v1/platelists/{id}/entries?q=&offset=&limit= vehicles in a list (up to 1000 per call)
POST /api/v1/platelists/{id}/entries add / update one vehicle (by plate)
DELETE /api/v1/platelists/{id}/entries/{plate} remove one vehicle (any spelling: 51G-123.45, 51G12345)
POST /api/v1/platelists/{id}/import merge / replace a whole list from CSV
# monthly pass valid through 31/10/2026 (valid_to is the exclusive end)
curl -X POST -H "X-Api-Key: tp_xxx" -H "Content-Type: application/json" \
     -d '{"plate":"51G-123.45","name":"Nguyễn Văn A","valid_to":"2026-11-01T00:00:00+07:00"}' \
     https://apiwebrtc.tingpush.com/api/v1/platelists/3/entries

# mirror the whole list from your pass-management system (nightly)
curl -X POST -H "X-Api-Key: tp_xxx" -H "Content-Type: application/json" \
     -d '{"text":"51G12345,Nguyễn Văn A,01/10/2026,31/10/2026\n30A99999,Director car","replace":true}' \
     https://apiwebrtc.tingpush.com/api/v1/platelists/3/import

One vehicle: {"id","plate","plate_display","name","note","valid_from","valid_to","active"} — active = currently valid. Import returns {"added","updated","removed","errors":[…]} (first 20 errors; bad lines are skipped).

Open / close history

GET /api/v1/events?type=io — one record per open / close (automatic or manual):

{ "type": "io", "summary": "Mở Barie cổng vào — biển 51G-123.45 trong danh sách: Nguyễn Văn A",
  "data": { "output": 0, "output_name": "Barie cổng vào", "action": "pulse", "trigger": "plate_allow",
            "by": "biển 51G-123.45 trong danh sách: Nguyễn Văn A", "plate": "51G12345", "ok": true } }

trigger = the rule's event, or manual for a button press / API call (by = the person's name plus (app / web), or API: <key name>). Errors: "ok": false, "error": "…". io events do not count against the plan's AI event quota. In the app / web / Windows software: Sự kiện AI (AI events), filter type Thiết bị ngoại vi (Peripherals).

7. FAQ

What if the Internet goes down? Rules and the allow list live on the camera → listed vehicles still get in. Only remote opening (app / web / API) needs Internet.

What if the camera loses power? The barrier follows its own controller; after a reboot the camera does not switch anything on by itself (only rules / commands do). Keep a manual open button for the guard.

A plate misread by one character doesn't open? Correct — the camera only opens for an exact match. Raise Số lần đọc đúng để gửi (Matching reads before sending) in the plate-reading settings to cut misreads, or use a * pattern for a group of vehicles.

Will it open twice if a car waits at the gate? The camera doesn't resend the same plate within Chống gửi lặp (Duplicate suppression, 60 s by default); each rule also has its own Không lặp lại.