Light Bright
We don’t need to turn the light on and unnecessarily waste electricity if there’s enough natural daylight in the room already. To test for that condition, we’ll poll the SensorHub’s onboard light sensor. The light sensor will help determine if additional room lighting is necessary. The onboard SensorHub light sensor detects the amount of light energy present in units of lux.[44]
For this project, we’ll turn on the Hue smart bulb when motion is detected as long as the amount of available light detected in the room is less than 25 lux, which is roughly equivalent to the ambient light diffused in a slightly darkened room. Let’s write a quick light-sensor test script to detect the light illumination value and react accordingly:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access