Switchboard
Tuya Smart API integration for custom hardware control — cloud commands mapped to local relays, sensors, and operator workflows.
Problem
Off-the-shelf smart plugs rarely match custom hardware timelines. Switchboard experiments with Tuya Smart API bridges so bespoke firmware can subscribe to cloud commands while exposing local sensor state back to automations.
What it covers
- Tuya device registration and command dispatch wrappers
- Mapping cloud DP IDs to local GPIO/actuator handlers
- Heartbeat and state publish loop for automations
- Embedded hooks for custom sensor ingestion
type DeviceHandler = (value: unknown) => Promise<void>;
const dpHandlers: Record<string, DeviceHandler> = {
switch_1: async (on) => relay.set(Boolean(on)),
temp_current: async (c) => telemetry.publish('temp', Number(c)),
};
export async function onDpUpdate(id: string, value: unknown) {
await dpHandlers[id]?.(value);
}