Skip to content

Commit 52c8167

Browse files
author
brentru
committed
removal of bad eval()
1 parent 188e90b commit 52c8167

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

adafruit_io/adafruit_io.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
https://github.com/adafruit/circuitpython/releases
3737
"""
3838
import time
39+
import json
3940
from adafruit_io.adafruit_io_errors import (
4041
AdafruitIO_RequestError,
4142
AdafruitIO_ThrottleError,
@@ -152,8 +153,8 @@ def _on_message_mqtt(self, client, topic, payload):
152153
# Adafruit IO Group Feed(s)
153154
feeds = []
154155
messages = []
155-
# TODO: Remove eval here...
156-
payload = eval(payload)
156+
# Conversion of incoming group to a json response
157+
payload = json.loads(payload)
157158
for feed in payload["feeds"]:
158159
feeds.append(feed)
159160
for msg in feeds:
@@ -177,7 +178,14 @@ def _on_message_mqtt(self, client, topic, payload):
177178

178179
def loop(self):
179180
"""Manually process messages from Adafruit IO.
180-
Use this method to check incoming subscription messages.
181+
Call this method to check incoming subscription messages.
182+
183+
Example usage of polling the message queue using loop.
184+
185+
..code-block:: python
186+
187+
while True:
188+
io.loop()
181189
"""
182190
self._client.loop()
183191

0 commit comments

Comments
 (0)