本文整理汇总了Python中Adafruit_IO.Client.receive_random方法的典型用法代码示例。如果您正苦于以下问题:Python Client.receive_random方法的具体用法?Python Client.receive_random怎么用?Python Client.receive_random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_IO.Client
的用法示例。
在下文中一共展示了Client.receive_random方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Author
# 需要导入模块: from Adafruit_IO import Client [as 别名]
# 或者: from Adafruit_IO.Client import receive_random [as 别名]
"""
'random_data.py'
================================================
Example for accessing the Adafruit IO Random
Data Service.
Author(s): Brent Rubell for Adafruit Industries
"""
# Import JSON for forecast parsing
import json
# Import Adafruit IO REST client.
from Adafruit_IO import Client, Feed, RequestError
# Set to your Adafruit IO key.
ADAFRUIT_IO_USERNAME = 'brubell'
ADAFRUIT_IO_KEY = '6ec4b31bd2c54a09be911e0c1909b7ab'
# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
generator_id = 1461
# Get the specified randomizer record with its current value and related details.
random_data = aio.receive_random(generator_id)
# Parse the API response
data = json.dumps(random_data)
data = json.loads(data)
print('Random Data: {0}'.format(data['value']))