adafruit.io#

class platypush.plugins.adafruit.io.AdafruitIoPlugin(username, key, throttle_seconds=None, **kwargs)[source]#

Bases: Plugin

This plugin allows you to interact with the Adafruit IO <https://io.adafruit.com>, a cloud-based message queue and storage. You can send values to feeds on your Adafruit IO account and read the values of those feeds as well through any device.

Requires:

  • adafruit-io (pip install adafruit-io)

  • Redis server running and Redis backend configured if you want to enable throttling

Some example usages:

# Send the temperature value for a connected sensor to the "temperature" feed
{
    "type": "request",
    "action": "adafruit.io.send",
    "args": {
        "feed": "temperature",
        "value": 25.0
    }
}

# Receive the most recent temperature value
{
    "type": "request",
    "action": "adafruit.io.receive",
    "args": {
        "feed": "temperature"
    }
}
__init__(username, key, throttle_seconds=None, **kwargs)[source]#
Parameters:
  • username (str) – Your Adafruit username

  • key (str) – Your Adafruit IO key

  • throttle_seconds (float) – If set, then instead of sending the values directly over send the plugin will first collect all the samples within the specified period and then dispatch them to Adafruit IO. You may want to set it if you have data sources providing a lot of data points and you don’t want to hit the throttling limitations of Adafruit.

delete(feed, data_id)[source]#

Delete a data point from a feed

Parameters:
  • feed (str) – Feed name

  • data_id (str) – Data point ID to remove

receive(feed, limit=1)[source]#

Receive data from the specified Adafruit IO feed

Parameters:
  • feed (str) – Feed name

  • limit (int) – Maximum number of data points to be returned. If None, all the values in the feed will be returned. Default: 1 (return most recent value)

receive_next(feed)[source]#

Receive the next unprocessed data point from a feed

Parameters:

feed (str) – Feed name

receive_previous(feed)[source]#

Receive the last processed data point from a feed

Parameters:

feed (str) – Feed name

send(feed, value, enqueue=True)[source]#

Send a value to an Adafruit IO feed

Parameters:
  • feed (str) – Feed name

  • value (Numeric or string) – Value to send

  • enqueue (bool) – If throttle_seconds is set, this method by default will append values to the throttling queue to be periodically flushed instead of sending the message directly. In such case, pass enqueue=False to override the behaviour and send the message directly instead.

send_location_data(feed, lat, lon, ele, value)[source]#

Send location data to an Adafruit IO feed

Parameters:
  • feed (str) – Feed name

  • lat (float) – Latitude

  • lon (float) – Longitude

  • ele (float) – Elevation

  • value (Numeric or string) – Value to send