当前位置: 首页>>代码示例>>Python>>正文


Python Client.receive方法代码示例

本文整理汇总了Python中Adafruit_IO.Client.receive方法的典型用法代码示例。如果您正苦于以下问题:Python Client.receive方法的具体用法?Python Client.receive怎么用?Python Client.receive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_IO.Client的用法示例。


在下文中一共展示了Client.receive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Client

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
#
import time
from Adafruit_IO import Client, Data
aio = Client('1326749aacca46de9b9b34c6a105cb92')


# Print out the feed names:
feeds = aio.feeds()
for f in feeds:
    print('Feed: {0}'.format(f.name))


# Print out the feed metadata.
feed = aio.feeds('StatusColor')
print(feed)

print '/n/n'
    

sc = aio.receive('StatusColor')
print sc
print sc.value

aio.send('StatusColor', '#ff0000')
time.sleep(2)
aio.send('StatusColor', '#ff8800')
time.sleep(2)
aio.send('StatusColor', '#ffff00')
time.sleep(2)
aio.send('StatusColor', '#00ff00')
开发者ID:niclasw63,项目名称:IoT,代码行数:32,代码来源:Adafrutt_io_001.py

示例2: open

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
# Modified by Nick Farrow
#
# Original File from
# https://github.com/adafruit/io-client-python/blob/master/examples/simple.py
# Original Author: Tony DiCola

#read key from file
f = open('key.cfg','r')
string = ""
while 1:
    line = f.readline()
    if not line:break
    string += line
f.close()

# Import Adafruit IO REST client.
from Adafruit_IO import Client

# Set to your Adafruit IO key.
ADAFRUIT_IO_KEY = string
# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_KEY)

# Read the most recent value feeds from Red, Blue & Green.
data = aio.receive('Red')
print('Red: {0}'.format(data.value))
data = aio.receive('Blue')
print('Blue: {0}'.format(data.value))
data = aio.receive('Green')
print('Green: {0}'.format(data.value))
开发者ID:VeggieVampire,项目名称:AdaFruitIO,代码行数:32,代码来源:ReadAdaFruitIO.py

示例3: Client

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
aio = Client('7e01e8b5e56360efc48a27682324fc353e18d14f')

last = 0
inputNum = 20
outputNum = 21
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(outputNum,GPIO.OUT)
GPIO.setup(inputNum,GPIO.IN)


while True:
  if (time.time() - last) >= 7:
    # Retrieve the most recent value from BlockHeat01
    data = aio.receive('blockheat01')
    print('Received Value: {0}'.format(data.value))
    if data.value == "1":
      print('data = 1')
      GPIO.output(outputNum,GPIO.HIGH)
    else:
      print('data = 0')
      GPIO.output(outputNum,GPIO.LOW)
    state = GPIO.input(inputNum)
    if (state):
      print('Doorstate = 1')
      aio.send('doorstate',1)
    else:
      print('Doorstate = 0')
      aio.send('doorstate',0)
    last = time.time()
开发者ID:robingreig,项目名称:raspi-git,代码行数:32,代码来源:Relay21Output03.py

示例4: level

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
# We dont' have a GPS hooked up, but let's fake it for the example/test:
# (replace this data with values from a GPS hardware module)
value = 0
lat = 40.726190
lon = -74.005334
ele = 6 # elevation above sea level (meters)


while True:
    print('\nSending Values to location feed...\n')
    print('\tValue: ', value)
    print('\tLat: ', lat)
    print('\tLon: ', lon)
    print('\tEle: ', ele)
    # Send location data to Adafruit IO
    metadata = { 'lat':lat, 'lon':lon, 'ele':ele, 'created_at':time.asctime(time.gmtime()) }
    aio.send_data(location.key,value,metadata)
    # shift all values (for test/demo purposes)
    value += 1
    lat -= 0.01
    lon += -0.02
    ele += 1

    # Read the location data back from IO
    print('\nData Received by Adafruit IO Feed:\n')
    data = aio.receive(location.key)
    print('\tValue: {0}\n\tLat: {1}\n\tLon: {2}\n\tEle: {3}'
          .format(data.value, data.lat, data.lon, data.ele))
    # wait loop_delay seconds to avoid api throttle
    time.sleep(loop_delay)
开发者ID:adafruit,项目名称:io-client-python,代码行数:32,代码来源:location.py

示例5: Client

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
# Set to your Adafruit IO username.
# (go to https://accounts.adafruit.com to find your username)
ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

try: # if we have a 'digital' feed
    digital = aio.feeds('digital')
except RequestError: # create a digital feed
    feed = Feed(name="digital")
    digital = aio.create_feed(feed)

# led set up
led = digitalio.DigitalInOut(board.D5)
led.direction = digitalio.Direction.OUTPUT


while True:
    data = aio.receive(digital.key)
    if int(data.value) == 1:
        print('received <- ON\n')
    elif int(data.value) == 0:
        print('received <- OFF\n')

    # set the LED to the feed value
    led.value = int(data.value)
    # timeout so we dont flood adafruit-io with requests
    time.sleep(0.5)
开发者ID:adafruit,项目名称:io-client-python,代码行数:31,代码来源:digital_out.py

示例6: read_CurrentBasementTemp

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
  time.sleep(1)

  # Read the Current Basement Temperature
  def read_CurrentBasementTemp():
    f = open("/home/robin/CurrentBasementTemp", "r")
    line1 = f.readlines()
    f.close
    line2 = line1[0]
    BasementTemp = float(line2)
    return BasementTemp

  BasementTempRound = (round(read_CurrentBasementTemp(),2))

  if DEBUG > 0:
    print "Basement Temp File reads: ", read_CurrentBasementTemp()
    print "Basement Temp Rounded: ", BasementTempRound

  # Send the value 100 to a feed called 'Foo'.
  #aio.send('basement-temp', 19.8)
  aio.send('basement-temp', BasementTempRound)

  # Retrieve the most recent value from the feed 'Foo'.
  # Access the value by reading the `value` property on the returned Data object.
  # Note that all values retrieved from IO are strings so you might need to convert
  # them to an int or numeric type if you expect a number.
  data = aio.receive('basement-temp')
  if DEBUG > 0:
    print('Received value: {0}'.format(data.value))
  sys.exit()

开发者ID:robingreig,项目名称:raspi-git,代码行数:31,代码来源:BasementTempAio.py

示例7: read_CurrentMapleHouseTemp

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
  time.sleep(1)

  # Read the Current Garage Temperature
  def read_CurrentMapleHouseTemp():
    f = open("/home/robin/MapleHouseTemp.txt", "r")
    line1 = f.readlines()
    f.close
    line2 = line1[5]
    MapleHouseTemp = float(line2)
    return MapleHouseTemp

  MapleHouseTempRound = (round(read_CurrentMapleHouseTemp(),2))

  if DEBUG > 0:
    print "Maple House Temp File reads: ", read_CurrentMapleHouseTemp()
    print "Maple House Temp Rounded: ", MapleHouseTempRound

  # Send the value 100 to a feed called 'Foo'.
  #aio.send('basement-temp', 19.8)
  aio.send('maplehouse-temp', MapleHouseTempRound)

  # Retrieve the most recent value from the feed 'Foo'.
  # Access the value by reading the `value` property on the returned Data object.
  # Note that all values retrieved from IO are strings so you might need to convert
  # them to an int or numeric type if you expect a number.
  data = aio.receive('maplehouse-temp')
  if DEBUG > 0:
    print('Received value: {0}'.format(data.value))
  sys.exit()

开发者ID:robingreig,项目名称:raspi-git,代码行数:31,代码来源:MapleHouseTempAio.py

示例8: Client

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
# Set to your Adafruit IO username.
# (go to https://accounts.adafruit.com to find your username)
ADAFRUIT_IO_USERNAME = 've6rbn'

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

try: # if we have a 'digital' feed
    digital = aio.feeds('MasterBath')
except RequestError: # create a digital feed
    feed = Feed(name="MasterBath")
    digital = aio.create_feed(feed)

# led set up
#led = digitalio.DigitalInOut(board.D5)
#led.direction = digitalio.Direction.OUTPUT


while True:
#    data = aio.receive(digital.key)
    data = aio.receive(digital.Default)
    if int(data.value) == 1:
        print('received <- ON\n')
    elif int(data.value) == 0:
        print('received <- OFF\n')

    # set the LED to the feed value
#    led.value = int(data.value)
    # timeout so we dont flood adafruit-io with requests
    time.sleep(1)
开发者ID:robingreig,项目名称:raspi-git,代码行数:32,代码来源:digital_out.py

示例9: read_CurrentOutsideTemp

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
  time.sleep(1)

  # Read the Current Garage Temperature
  def read_CurrentOutsideTemp():
    f = open("/home/robin/CurrentOutsideTemp", "r")
    line1 = f.readlines()
    f.close
    line2 = line1[0]
    OutsideTemp = float(line2)
    return OutsideTemp

  OutsideTempRound = (round(read_CurrentOutsideTemp(),2))

  if DEBUG > 0:
    print "Outside Temp File reads: ", read_CurrentOutsideTemp()
    print "Outside Temp Rounded: ", OutsideTempRound

  # Send the value 100 to a feed called 'Foo'.
  #aio.send('basement-temp', 19.8)
  aio.send('outside-temp', OutsideTempRound)

  # Retrieve the most recent value from the feed 'Foo'.
  # Access the value by reading the `value` property on the returned Data object.
  # Note that all values retrieved from IO are strings so you might need to convert
  # them to an int or numeric type if you expect a number.
  data = aio.receive('outside-temp')
  if DEBUG > 0:
    print('Received value: {0}'.format(data.value))
  sys.exit()

开发者ID:robingreig,项目名称:raspi-git,代码行数:31,代码来源:OutsideTempAio.py

示例10: Client

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
# Author: Tony DiCola

# Import Adafruit IO REST client.
from Adafruit_IO import Client

# Set to your Adafruit IO key.
ADAFRUIT_IO_KEY = 'YOUR ADAFRUIT IO KEY'

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_KEY)

# Send a value to the feed 'Test'.  This will create the feed if it doesn't
# exist already.
aio.send('Test', 42)

# Send a string value 'bar' to the feed 'Foo', again creating it if it doesn't 
# exist already.
aio.send('Foo', 'bar')

# Now read the most recent value from the feed 'Test'.  Notice that it comes
# back as a string and should be converted to an int if performing calculations
# on it.
data = aio.receive('Test')
print('Retrieved value from Test has attributes: {0}'.format(data))
print('Latest value from Test: {0}'.format(data.value))

# Finally read the most revent value from feed 'Foo'.
data = aio.receive('Foo')
print('Retrieved value from Test has attributes: {0}'.format(data))
print('Latest value from Test: {0}'.format(data.value))
开发者ID:Mecabot,项目名称:io-client-python,代码行数:32,代码来源:simple.py

示例11: print

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
int_val = 3
long_val = 0x80000000
double_val = 3.1415926535897932
float_val = +1E6


"""
Let's send some values to our feed
and properly receive them
"""
print("Sending to Adafruit IO...")

# Char
print('\tSending Character: ', char_val)
aio.send(type.key, char_val)
data = aio.receive(type.key).value
print('\t\tReceived Character: ', str(data))

# String
print('\n\tSending String: ', string_val)
aio.send(type.key, string_val)
data = aio.receive(type.key).value
print('\t\tReceived String: ', str(data))

# Boolean
print('\n\tSending Bool: ', bool_val)
aio.send(type.key, bool_val)
data = aio.receive(type.key).value
print('\t\tReceived Bool: ', bool(data))

# Integer
开发者ID:adafruit,项目名称:io-client-python,代码行数:33,代码来源:type-conversion.py

示例12: Client

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
# Set to your Adafruit IO key.
ADAFRUIT_IO_KEY = '8a32de2fc1854d8ca4af204696e5dd24'

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_KEY)

# Now read the most recent value from the feed 'Test'.  Notice that it comes
# back as a string and should be converted to an int if performing calculations
# on it.

#data = aio.receive('relay')
#print('>>>> value attributes: {0}'.format(data))
#print('<<<< value: {0}'.format(data.value))


while True:
    print 'ready...'
    if relay.isOn():
        print 'relay is on'
        aio.send('clientstatus', 1)
    elif relay.isOff():
        print 'relay is off'
        aio.send('clientstatus', 0)
    data = aio.receive('relay')
    if str(data.value) == 'ON':
        relay.on()
    elif str(data.value) == 'OFF':
        relay.off()
    time.sleep(1)
开发者ID:lesparza90,项目名称:TheIoTLearningInitiative,代码行数:31,代码来源:relay.py

示例13: read_CurrentHouseTemp

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
  time.sleep(1)

  # Read the Current Garage Temperature
  def read_CurrentHouseTemp():
    f = open("/home/robin/CurrentHouseTemp", "r")
    line1 = f.readlines()
    f.close
    line2 = line1[0]
    HouseTemp = float(line2)
    return HouseTemp

  HouseTempRound = (round(read_CurrentHouseTemp(),2))

  if DEBUG > 0:
    print "House Temp File reads: ", read_CurrentHouseTemp()
    print "House Temp Rounded: ", HouseTempRound

  # Send the value 100 to a feed called 'Foo'.
  #aio.send('basement-temp', 19.8)
  aio.send('house-temp', HouseTempRound)

  # Retrieve the most recent value from the feed 'Foo'.
  # Access the value by reading the `value` property on the returned Data object.
  # Note that all values retrieved from IO are strings so you might need to convert
  # them to an int or numeric type if you expect a number.
  data = aio.receive('house-temp')
  if DEBUG > 0:
    print('Received value: {0}'.format(data.value))
  sys.exit()

开发者ID:robingreig,项目名称:raspi-git,代码行数:31,代码来源:HouseTempAio.py

示例14: Client

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
# Import library and create instance of REST client.
from Adafruit_IO import Client
aio = Client('ve6rbn', 'e69155097ffa4624ae09d57213e200ed')

# Send the value 100 to a feed called 'Foo'.
aio.send('Foo', 100)

# Retrieve the most recent value from the feed 'Foo'.
# Access the value by reading the `value` property on the returned Data object.
# Note that all values retrieved from IO are strings so you might need to convert
# them to an int or numeric type if you expect a number.
data = aio.receive('Foo')
print('Received value: {0}'.format(data.value))
开发者ID:robingreig,项目名称:raspi-git,代码行数:15,代码来源:quickstart.py

示例15: read_CurrentGarageTemp

# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive [as 别名]
  time.sleep(1)

  # Read the Current Garage Temperature
  def read_CurrentGarageTemp():
    f = open("/home/robin/CurrentGarageTemp", "r")
    line1 = f.readlines()
    f.close
    line2 = line1[0]
    GarageTemp = float(line2)
    return GarageTemp

  GarageTempRound = (round(read_CurrentGarageTemp(),2))

  if DEBUG > 0:
    print "Garage Temp File reads: ", read_CurrentGarageTemp()
    print "Garage Temp Rounded: ", GarageTempRound

  # Send the value 100 to a feed called 'Foo'.
  #aio.send('basement-temp', 19.8)
  aio.send('garage-temp', GarageTempRound)

  # Retrieve the most recent value from the feed 'Foo'.
  # Access the value by reading the `value` property on the returned Data object.
  # Note that all values retrieved from IO are strings so you might need to convert
  # them to an int or numeric type if you expect a number.
  data = aio.receive('garage-temp')
  if DEBUG > 0:
    print('Received value: {0}'.format(data.value))
  sys.exit()

开发者ID:robingreig,项目名称:raspi-git,代码行数:31,代码来源:GarageTempAio.py


注:本文中的Adafruit_IO.Client.receive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。