rahul tikkavarapu
Created April 4, 2020 © GPL3+

Philips Smart bulb auto ON/OFF with IFTTT and Bolt Iot

Control your Philips wiz smart bulbs according to the outside light with a Bolt IoT module and an IFTTT applet.

IntermediateFull instructions provided2 hours1
Philips Smart bulb auto ON/OFF with IFTTT and Bolt Iot

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Philips hue Philips smart LED bulb
×1

Software apps and online services

Maker service
IFTTT Maker service
Bolt Cloud
Bolt IoT Bolt Cloud

Story

Read more

Schematics

hardware connection

Connect one end of the LDR sensor to A0 port of the Bolt module, and the other end to the 3.3v port. Take a 10k ohm resistor () and connect one end to A0 port and the other to gnd port. Take care that the 3.3v and god wires do not touch, otherwise it may fry the board.

Code

light_control.py

Python
This is the main code.
import conf, json, time, requests
from boltiot import Bolt

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)

bulb=0

def trigger_on_webhook():
    URL = paste the ON URL here # REPLACE WITH CORRECT URL
    response = requests.request("GET", URL)

def trigger_off_webhook():
    URL = paste the OFF URL here # REPLACE WITH CORRECT URL
    response = requests.request("GET", URL)

while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retrieving the data.")
        print("This is the error:"+data['value'])
        time.sleep(10)
        continue

    print ("This is the value "+data['value'])
    sensor_value=0
    try:
        sensor_value = int(data['value'])
    except e:
        print("There was an error while parsing the response: ",e)
        continue

   

    try:
        if sensor_value < 290 and bulb==0 :  # Light will turn ON
            print ("Turning ON bulb.")
            trigger_on_webhook()
            bulb=1
            print("This is the response ",response)
        elif sensor_value > 500 and bulb==1 : # Light will turn OFF
            print ("Turning OFF bulb.”)
            trigger_off_webhook()
            bulb=0
            print("This is the response ",response)
    except Exception as e:
        print ("Error",e)
    time.sleep(10)

conf.py

Python
This is the configuration code to store API Key and device ID of the Bolt module.
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device' 

Credits

rahul tikkavarapu

rahul tikkavarapu

0 projects • 0 followers

Comments