Ejemplo n.º 1
0
def all_off(username, key):
    aio = Client(username, key)

    feeds_key = ["yatak-odasi-isik1", "yatak-odasi-isik2", "yatak-odasi-isik3"]
    data = Data(value="OFF")

    for feed_key in feeds_key:
        aio.create_data(feed_key, data)

    return ("All the lights in the bedroom turned off")
Ejemplo n.º 2
0
def home(request):
    aio = Client('sem6', 'aio_tkWz44qALyafHtu6EWTLfQNgSf0y')
    slot1_available = strftime(
        aio.receive('entryslot1').created_at) < strftime(
            aio.receive('exitslot1').created_at)
    slot2_available = strftime(
        aio.receive('entryslot2').created_at) < strftime(
            aio.receive('exitslot2').created_at)
    slot3_available = strftime(
        aio.receive('entryslot3').created_at) < strftime(
            aio.receive('exitslot3').created_at)
    arr = [slot1_available, slot2_available, slot3_available]
    available_spaces = arr.count(True)

    if request.method == 'POST':
        form = PostForm(request.POST)
        if form.is_valid():
            d = request.POST.copy()
            d1 = [d.get('hour'), d.get('minutes'), d.get('slot')]
            if arr[int(d.get('slot')) - 1]:
                s = str(d.get('slot')) + ',' + str(d.get('hour')) + ':' + str(
                    d.get('minutes'))
                data = Data(value=s)
                aio.create_data('reservation', data)
                s1 = "successful"
                form.save(commit=True)  #
            else:
                s1 = "unsuccessful"
        else:
            s1 = "unsuccessful"  # return redirect('home')
        return HttpResponse(
            render(
                request, 'reservation/home.html', {
                    'form': form,
                    's1': slot1_available,
                    's2': slot2_available,
                    's3': slot3_available,
                    'available': available_spaces,
                    's': s1
                }))
        # return redirect('home',{})
    else:
        form = PostForm()
        return render(
            request, 'reservation/home.html', {
                'form': form,
                's1': slot1_available,
                's2': slot2_available,
                's3': slot3_available,
                'available': available_spaces
            })
Ejemplo n.º 3
0
def on(bot,update):
    chat_id=update.message.chat_id
    bot.send_photo(chat_id,photo='https://cdn1.vectorstock.com/i/1000x1000/59/15/bulb-light-icon-line-lamp-on-symbol-vector-21085915.jpg')
    bot.send_message(chat_id,text='bulb turned on')
    aio = Client(x,y)
    value=Data(value=1)
    value_send=aio.create_data('lightningbot',value)
Ejemplo n.º 4
0
def on(bot, update):
    chat_id = update.message.chat_id
    bot.send_photo(chat_id,
                   photo='https://img.icons8.com/plasticine/2x/light-on.png')
    bot.send_message(chat_id, text='led is on')
    aio = Client(x, y)
    value = Data(value=1)
    value_send = aio.create_data('bot', value)
Ejemplo n.º 5
0
def off(bot, update):
    chat_id = update.message.chat_id
    bot.send_photo(chat_id,
                   photo='https://pngimg.com/uploads/bulb/bulb_PNG1241.png')
    bot.send_message(chat_id, text='led is off')
    aio = Client(x, y)
    value = Data(value=0)
    value_send = aio.create_data('bot', value)
def turnon(bot, update):
    chat_id = update.message.chat_id
    bot.send_photo(
        chat_id,
        photo=
        'https://www.christmaslightsetc.com/p/G40-E12-Clear-Globe-Replacement-Lamps--18769.htm#'
    )
    bot.send_message(chat_id, text="the BULB is ON")
    aio = Client(a, b)
    value = Data(value=1)
    value_send = aio.create_data('botpubgbot', value)
def turnoff(bot, update):
    chat_id = update.message.chat_id
    bot.send_photo(
        chat_id,
        photo=
        'https://www.batteriesplus.com/content/images/product/large/443078.jpg'
    )
    bot.send_message(chat_id, text="The BULB is OFF")
    aio = Client(a, b)
    value = Data(value=0)
    value_send = aio.create_data('botpubgbot', value)
import os
x = os.getenv('x')  #ADAFRUIT_IO_USERNAME
y = os.getenv('y')   #ADAFRUIT_IO_KEY

from Adafruit_IO import Client, Feed
aio = Client(x,y)

# create a feed 
feed = Feed(name='wbot')#Feed name is given
result = aio.create_feed(feed)
result

from Adafruit_IO import Data # data is actually a method from adafruit library
#sending the value to a feed
value = Data(value=0)
data_send = aio.create_data('wbot', value)

pip install twilio
import os
from twilio.rest import Client 

account_sid = os.getenv('account_sid')
auth_token = os.getenv('auth_token')
client = Client(account_sid, auth_token)

from_whastapp_number = 'whatsapp:+14155238886'
to_whastapp_number = 'whatsapp:+919325583070'

message = client.messages \
    .create(
         media_url=['https://i.pinimg.com/originals/98/26/86/982686f070e5c77b64a71f83a96b7167.jpg'],
Ejemplo n.º 9
0
y = "aio_fjQf44u5CtSBWTdNGxlbboYJz5oQ"  #ADAFRUIT_IO_KEY

from Adafruit_IO import Client, Feed
aio = Client(x,y)

# Create a feed
new = Feed(name='telebot')  # Feed name is given

result = aio.create_feed(new)

result

from Adafruit_IO import Data
# Sending a value to a feed
value = Data(value=0)
value_send = aio.create_data('telebot',value)

!pip install from telegram.ext import Updater,CommandHandler
import requests  # Getting the data from the cloud


def get_url():
    contents = requests.get('https://random.dog/woof.json').json()
    url = contents['url']
    return url

def on(bot,update):
    url = get_url()
    chat_id = update.message.chat_id
    txt = 'ligth turned on'
    pic = 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Green_sphere.svg/1024px-Green_sphere.svg.png'
Ejemplo n.º 10
0
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'
f = open(device_file, 'r')
lines = f.readlines()
f.close()
while lines[0].strip()[-3:] != 'YES':
    time.sleep(0.2)
    lines = read_temp_raw()
equals_pos = lines[1].find('t=')
if equals_pos != -1:
    temp_string = lines[1][equals_pos + 2:]
    temp_c = float(temp_string) / 1000.0
    temp_f = temp_c * 9.0 / 5.0 + 32.0

#Send data to Adafruit.IO

#CHANGE THESE THREE VARIABLES
ADAFRUIT_IO_USERNAME = "******"
ADAFRUIT_IO_KEY = "YOUR_ADAFRUIT_IO_KEY_HERE"
ADAFRUIT_FEED = "YOUR_ADAFRUIT_FEED_HERE"

aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

#If you want to use Celcius, uncomment the below line and comment out the line with temp_f
#data = Data(value=temp_c)
data = Data(value=temp_f)

#Sends the data to Adafruit.IO
aio.create_data(ADAFRUIT_FEED, data)
while (1):

    rec = aio.receive('')
    data = rec.value

    if data == '0':
        continue

    if data == '1':

        toaster.show_toast('Shell & Bash\n',
                           "SHUTTING DOWN YOUR PC......",
                           icon_path="SB.ico")
        data = Data(value='0')
        aio.create_data('Control', data)
        os.system("SHUTDOWN -s ")
        continue

    if data == '2':
        toaster.show_toast('Shell & Bash\n',
                           "RESTARTING YOUR PC.....",
                           icon_path="SB.ico")
        data = Data(value='0')
        aio.create_data('Control', data)
        os.system("SHUTDOWN -r")
        continue

    if (data[:6] == "a new "):
        st = str(data[6:])
        toaster.show_toast('Shell & Bash\n',
Ejemplo n.º 12
0
import serial
import time
from Adafruit_IO import Client, Feed, Data
aio = Client('roshea', '5a036c274def42da94fb866f11030bea')
ser = serial.Serial('/dev//ttyUSB0', 9600)
counter = 0

feed1 = Feed(name='heartrate')
feed2 = Feed(name='incident')
feed3 = Feed(name='incidentlocation')
incidentlocationdata = Data(value=1)

while True:
    incidentdata = Data(value=0)
    data = Data(value=int(ser.readline()))
    print(data.value)
    if data == 2000:
        counter += 1
        incidentdata = Data(value=counter)
        incidentlocationdata = Data(value=0)
    else:
        time.sleep(1.5)
        aio.create_data('heartrate', data)

    time.sleep(1.5)
    aio.create_data('incident', incidentdata)
    time.sleep(1.5)
    aio.create_data('incidentlocation', incidentlocationdata)
    time.sleep(1.5)
Ejemplo n.º 13
0
!pip install adafruit-io
x = "sanebabul"
y = "aio_PUCY37NBlc3tXkahYTh0bx9k9PBL"
from Adafruit_IO import Client, Feed
aio = Client(x,y)
# Create a feed
new = Feed(name='bottele')  # Feed name is given
result = aio.create_feed(new)
result
from Adafruit_IO import Data
# Sending a value to a feed
value = Data(value=0)
value_send = aio.create_data('bottele',value)
!pip install python-telegram-bot
from telegram.ext import Updater,CommandHandler
import requests  # Getting the data from the cloud


def get_url():
    contents = requests.get('https://random.dog/woof.json').json()
    url = contents['url']
    return url

def on(bot,update):
    url = get_url()
    chat_id = update.message.chat_id
    txt = 'ligth turned on'
    pic = 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Green_sphere.svg/1024px-Green_sphere.svg.png'
    bot.send_message(chat_id, txt)
    bot.send_photo(chat_id, pic)
    from Adafruit_IO import Data
Ejemplo n.º 14
0
}, {
    "name": 'bk-iot-soil',
    "payload": {
        "id": "2",
        "name": "SOIL",
        "data": 0,
        "unit": ''
    }
}, {
    "name": 'bk-iot-temp-humid',
    "payload": {
        "id": "3",
        "name": "TEMP-HUMID",
        "data": '0-0',
        "unit": ''
    }
}]
while True:
    value = random.randint(0, 200)
    random_feed = feeds[random.randint(0, 2)]
    if (random_feed['name'] == 'bk-iot-temp-humid'):
        random_feed['payload']['data'] = str(random.randint(
            20, 40)) + '-' + str(value)
    else:
        random_feed['payload']['data'] = value
    print('Pushing data')
    print(random_feed)
    data = Data(value=json.dumps(random_feed['payload']))
    client.create_data(random_feed['name'], data)
    time.sleep(1)
Ejemplo n.º 15
0
#Be sure to create a file called credentials.py with variables for the Adafruit feed key and a feed name to use
import credentials
from Adafruit_IO import Client, Feed, Data

print "Using AIO key " + credentials.aio_key + " to write data to feed " + credentials.feed_name
aio = Client(credentials.aio_key)

while True:
    try:
        in_data = raw_input("Enter data to feed to Adafruit or quit: ")
        if in_data == "quit":
            break
        data = Data(value=int(in_data))
        print "Writing " + in_data + " to feed"
        aio.create_data(credentials.feed_name, data)
    except:
        print "caught exception"

print "Quitting"
!pip install adafruit-io

x = "shrishailhiremath" #ADAFRUIT_IO_USERNAME
y = "aio_nzuT74irMCZHKyc7LpaNzX5986lQ" #ADAFRUIT_IO_KEY
from Adafruit_IO import Client, Feed
aio = Client(x,y)

#create a new feed
new = Feed(name='telegrambot2') #feed name is given
result = aio.create_feed(new)
result
from Adafruit_IO import Data
#sending a value to afeed
value =Data(value=0)
value_send = aio.create_data('telegrambot2',value)

!pip install python-telegram-bot

from telegram.ext import Updater,CommandHandler
import requests  # Getting the data from the cloud

def get_url():
    contents = requests.get('https://random.dog/woof.json').json()
    url = contents['url']
    return url

def on(bot,update):
    url = get_url()
    chat_id = update.message.chat_id
    txt = 'light turned on'
    pic = 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Green_sphere.svg/1024px-Green_sphere.svg.png'
Ejemplo n.º 17
0
!pip install adafruit-io
x = "krishnareddy"
y = "aio_qdqe14zU0bg30PE5Rs3Ta5jk0ts4"
from Adafruit_IO import Client, Feed
aio = Client(x,y)
# Create a feed
new = Feed(name='bot312')  # Feed name is given
result = aio.create_feed(new)
result
from Adafruit_IO import Data
# Sending a value to a feed
value = Data(value=0)
value_send = aio.create_data('bot312',value)
!pip install python-telegram-bot
from telegram.ext import Updater,CommandHandler
import requests  # Getting the data from the cloud


def get_url():
    contents = requests.get('https://random.dog/woof.json').json()
    url = contents['url']
    return url

def on(bot,update):
    url = get_url()
    chat_id = update.message.chat_id
    txt = 'ligth is turning on'
    pic = 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Green_sphere.svg/1024px-Green_sphere.svg.png'
    bot.send_message(chat_id, txt)
    bot.send_photo(chat_id, pic)
    from Adafruit_IO import Data