Make Your Home Smart with Google Assistant -Raspberry Pi Home Automation


The Basic Idea of this project is testing the integration of services that can be done through IFTTT and Adafruit as hardware like raspberry pi providing greater support.

source code and remaining are too easy to follow up.

Relay control with Adafruit Library through Google Assistant

# Import Adafruit IO MQTT client.
from Adafruit_IO import MQTTClient

# Import requests library used for making HTTP calls to the dashboard server.
import requests


# Set to your Adafruit IO key & username below.
ADAFRUIT_IO_KEY      = ' '   
ADAFRUIT_IO_USERNAME = ' '



def connected(client):
    print("Connected...Waiting for Commands")
    client.subscribe('relay')
 
def disconnected(client):
    print("DisConnected")
    sys.exit(1)

def message(client, feed_id, status):

    if feed_id == 'relay':

         if status=='1':
            print("Relay ON")
         else:
            print("Relay OFF")


client = MQTTClient(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)


client.on_connect    = connected
client.on_disconnect = disconnected
client.on_message    = message

# Connect to the Adafruit IO server.
client.connect()

client.loop_blocking()



Post a Comment

0 Comments