Pi-lluminate the room
This is an attempt at a Python script to make use of Pimoroni's Enviro pHAT to calculate the average light level (lux) in a room, and to trigger an action if the lux drops below a pre-determined threshold (in this case, send a webhook command to turn on some Philips Hue lights).
Enviro pHAT average lux calculation
I "borrowed" some of the code used in Pimoroni's BME680 Breakout Board to calculate the average lux level. The idea being that the Enviro pHAT captures the lux for 15 seconds, then calculates the average reading that is then used to trigger the action.
For simplicity, I'm using IFTTT's Maker channel to use webhooks. These webhooks link to an IFTTT applet that triggers a Philips Hue bulb at home based on the parameters passed.