File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ 'random_data.py'
3
+ ================================================
4
+ Example for accessing the Adafruit IO Random
5
+ Data Service.
6
+
7
+ Author(s): Brent Rubell for Adafruit Industries
8
+ """
9
+ # Import JSON for forecast parsing
10
+ import json
11
+ # Import Adafruit IO REST client.
12
+ from Adafruit_IO import Client , Feed , RequestError
13
+
14
+ # Set to your Adafruit IO key.
15
+ ADAFRUIT_IO_USERNAME = 'USER'
16
+ ADAFRUIT_IO_KEY = 'KEY'
17
+
18
+ # Create an instance of the REST client.
19
+ aio = Client (ADAFRUIT_IO_USERNAME , ADAFRUIT_IO_KEY )
20
+
21
+ generator_id = 1461
22
+
23
+ # Get the specified randomizer record with its current value and related details.
24
+ random_data = aio .receive_random (generator_id )
25
+ # Parse the API response
26
+ data = json .dumps (random_data )
27
+ data = json .loads (data )
28
+ print ('Random Data: {0}' .format (data ['value' ]))
You can’t perform that action at this time.
0 commit comments