February 2022
Intermediate to advanced
182 pages
4h 25m
English
Combine the code we used to toggle the Hue smart plug on and off with the external temperature test script. Doing so will allow us to turn the fan on if the temperature exceeds 79 degrees, and turn it off if the temperature drops below 80 degrees.
We also need to reduce the sampling rate to every two minutes (120 seconds) instead of every second. This will provide ample duration for the smart plug to turn on and off the fan. Otherwise, we’ll be constantly turning the fan on and off as the temperature fluctuates between a single threshold degree:
| | from phue import Bridge |
| | import smbus |
| | import time |
| | |
| | huebridge = Bridge('YOUR_HUE_BRIDGE_IP_GOES_HERE') |
| | |
| | DEVICE_BUS = 1 |
| | DEVICE_ADDR = 0x17 |
| | |
| | TEMP_REG ... |
Read now
Unlock full access