Kotlin/coroutines patterns for driving rate-limited IoT actuators from real-time producers: debounce controller, target quantization, bottom-up progress-bar rendering.
73
68%
Does it follow best practices?
Impact
95%
1.63xAverage score across 3 eval scenarios
Passed
No known issues
A co-working space operator wants to automate ambient lighting based on how many people are currently in the room. A camera system already runs a people-counting model at 30 frames per second, producing a normalized occupancy confidence score between 0.0 and 1.0 for each frame. The lighting rig consists of two independent Govee cloud-connected LED bulbs: one in the main seating area ("alpha") and one near the entrance ("beta").
The operator has tried a naive approach — calling the Govee cloud API directly inside the frame-processing loop — but the system quickly triggers HTTP 429 rate-limit errors and the camera loop stutters badly. A previous attempt used a simple delay() between API calls, but this blocked the entire processing pipeline.
The requirements are:
Implement the occupancy-based dimmer in Kotlin. Produce the following files:
src/main/kotlin/OccupancyDimmer.kt — the complete implementation including the controller setup and main entry point that wires the camera feed (simulated as a Flow<Float>) to both bulbsbuild.gradle.kts — the Gradle build file with all required dependencies declaredThe main function should simulate a 10-second camera feed emitting random float occupancy values and drive both controllers, then cleanly shut down.