Skip to content

Commit e837be5

Browse files
author
brentru
committed
add optional precision kwarg to send_data to io
1 parent 847df6d commit e837be5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_io/adafruit_io.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,17 @@ def _delete(self, path):
133133
return response.json()
134134

135135
# Data
136-
def send_data(self, feed_key, data, metadata=None):
136+
def send_data(self, feed_key, data, metadata=None, precision=None):
137137
"""
138138
Sends value data to a specified Adafruit IO feed.
139139
:param str feed_key: Adafruit IO feed key
140140
:param str data: Data to send to the Adafruit IO feed
141141
:param dict metadata: Optional metadata associated with the data
142+
:param int precision: Optional amount of precision points to send with floating point data
142143
"""
143144
path = self._compose_path("feeds/{0}/data".format(feed_key))
145+
if precision:
146+
data = round(data, precision)
144147
payload = self._create_data(data, metadata)
145148
self._post(path, payload)
146149

0 commit comments

Comments
 (0)