Files
charging_station/wiki/entities/wifi-relays.md
T
julian 3326c8d16c docs(wiki): discovery results, architecture, auth model, backend + relay pages
Ingests the 2026-07-09 live session (source page + raw GetConfiguration
dump): charger identified as SimpleCharge MultiSocketCharger, 60 kW DC
dual-standard (gun 1 EU/CCS, gun 2 GB/T); RFID and remote start/stop
verified; by-vehicle auth closed as not supported (three escalating tests
incl. MacEnabled=true after power-cycle); touchscreen-shows-VIN observation
with the DataTransferVendorId long-shot lead.

Adds/updates: architecture plan (FastAPI + PWA, phases 1-3 done), backend
entity, wifi-relays entity (Tuya local-control path + key extraction steps),
authorization concept (API user/scope model, per-gun cards), overview,
runbook, index, log.
2026-07-11 18:58:20 +02:00

2.2 KiB

type, updated, tags
type updated tags
entity 2026-07-11
hardware
relays
tuya

WiFi Relays (SmartLife / Tuya)

Several WiFi relays scattered around the property, currently driven by the SmartLife app (owner report, 2026-07-11). Scope expansion: the backend should control them too, so one self-hosted system runs both the anfu-charger and the relays.

What they are

SmartLife = Tuya's consumer app, so these are Tuya WiFi devices. The "discovered by Bluetooth at first" behavior the owner observed is Tuya's standard BLE-assisted pairing (the phone passes WiFi credentials over BLE once); after provisioning the relays live on WiFi and speak Tuya's local protocol on TCP 6668, which the tinytuya library drives directly — no Tuya cloud in the loop for day-to-day control. SmartLife keeps working in parallel; local and app control don't conflict.

Control path (implemented in backend/relays.py, ⚠️ awaiting keys)

Local control needs each device's id + local key, extracted once via Tuya's own API:

  1. Create a (free) account at iot.tuya.com → Cloud → create a project (data center matching the SmartLife account region).
  2. Link the SmartLife app account to the project (Devices → Link App Account → scan QR in SmartLife).
  3. From the repo root: venv\Scripts\python -m tinytuya wizard — enter the project's API id/secret; it dumps every paired device's id, key, ip, and protocol version.
  4. Copy each relay into backend/config.json → "relays" (shape in config.example.json). The Tuya cloud account is never needed again unless a device is re-paired (re-pairing regenerates the local key).

Recommended: DHCP reservations for the relays and pinned "ip" entries in the config — "ip": "auto" works via UDP broadcast discovery but is slower and only finds relays on the same L2 segment as the backend host (❓ verify which subnet the relays are on vs. the future always-on host, see network-topology).

API (see backend)

GET /api/relays?live=true (poll all), GET /api/relays/{name}, POST /api/relays/{name}/on|off|toggle. ⚠️ Untested against the physical relays until the keys are in the config.