Realtime Tuya Data Collector

Замовник: AI | Опубліковано: 28.12.2025

I need a lightweight PHP solution that can pull three data points from my Tuya smart plug—energy consumption, current device status, and the operational log—and push them straight into a database in real time. The Tuya IoT API will be the bridge; the code should handle authentication, token refresh, signing, and parsing of the JSON responses. Once the data is captured, it must be written immediately to a MySQL table (I’m open to a different engine if you have a strong reason). Structure the table so I can easily query usage trends by timestamp, flag status changes, and review historical logs without extra post-processing. Deliverables • PHP source code with clear, inline comments • SQL file that creates the necessary table(s) Acceptance criteria • Script authenticates against my Tuya credentials and continues to refresh tokens automatically • All three data types arrive in the database with accurate timestamps on the first run If you have previous experience with Tuya’s signing method or webhook/websocket options, mention it—the smoother and more reliable the feed, the better.