Skip to content

Commit d1b1ac8

Browse files
brentrubrentru
brentru
authored and
brentru
committed
add subscribe_randomizer and mqtt example
1 parent 32661c2 commit d1b1ac8

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Adafruit_IO/mqtt_client.py

+11
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ def subscribe_group(self, group_id):
205205
"""
206206
self._client.subscribe('{0}/groups/{1}'.format(self._username, group_id))
207207

208+
def subscribe_randomizer(self, randomizer_id):
209+
"""Subscribe to changes on a specified random data stream from
210+
Adafruit IO's random data service.
211+
212+
MQTT random word subscriptions will publish data once per minute to
213+
every client that is subscribed to the same topic.
214+
215+
:param int randomizer_id: ID of the random word record you want data for.
216+
"""
217+
self._client.subscribe('{0}/integration/words/{1}'.format(self._username, randomizer_id))
218+
208219
def subscribe_weather(self, weather_id, forecast_type):
209220
"""Subscribe to Adafruit IO Weather
210221
:param int weather_id: weather record you want data for

examples/api/random_data.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from Adafruit_IO import Client, Feed, RequestError
1313

1414
# Set to your Adafruit IO key.
15-
ADAFRUIT_IO_USERNAME = 'USER'
16-
ADAFRUIT_IO_KEY = 'KEY'
15+
ADAFRUIT_IO_USERNAME = 'brubell'
16+
ADAFRUIT_IO_KEY = '6ec4b31bd2c54a09be911e0c1909b7ab'
1717

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

0 commit comments

Comments
 (0)