adafruit.io#

Description#

This plugin allows you to interact with Adafruit IO, a cloud-based message queue and storage. You can use this plugin to send and receive data to topics connected to your Adafruit IO account.

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"
    }
}

Configuration#

adafruit.io:
  # [Required]
  # Your Adafruit username
  username:   # type=str

  # [Required]
  # Your Adafruit IO key
  key:   # type=str

  # [Optional]
  # List of feeds to subscribe to. If not set, then the plugin
  # will not subscribe to any feed unless instructed to do so, neither
  # it will emit any event.
  # feeds: ()  # type=Iterable[str]

  # [Optional]
  # 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.
  # throttle_interval:   # type=Optional[float]

  # [Optional]
  # How often the `RunnablePlugin.loop <https://docs.platypush.tech/platypush/plugins/.html#platypush.plugins.RunnablePlugin.loop>`_ function should be
  # executed (default: 15 seconds). *NOTE*: For back-compatibility
  # reasons, the `poll_seconds` argument is also supported, but it's
  # deprecated.
  # poll_interval: 15  # type=Optional[float]

  # [Optional]
  # How long we should wait for any running
  # threads/processes to stop before exiting (default: 5 seconds).
  # stop_timeout: 5  # type=Optional[float]

  # [Optional]
  # If set to True then the plugin will not monitor
  # for new events. This is useful if you want to run a plugin in
  # stateless mode and only leverage its actions, without triggering any
  # events. Defaults to False.
  # disable_monitor: False  # type=bool

Dependencies#

pip

pip install adafruit-io

Triggered events#

Actions#

Module reference#

class platypush.plugins.adafruit.io.AdafruitIoPlugin(username: str, key: str, feeds: Iterable[str] = (), throttle_interval: float | None = None, **kwargs)[source]#

Bases: RunnablePlugin

This plugin allows you to interact with Adafruit IO, a cloud-based message queue and storage. You can use this plugin to send and receive data to topics connected to your Adafruit IO account.

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: str, key: str, feeds: Iterable[str] = (), throttle_interval: float | None = None, **kwargs)[source]#
Parameters:
  • username – Your Adafruit username

  • key – Your Adafruit IO key

  • feeds – List of feeds to subscribe to. If not set, then the plugin will not subscribe to any feed unless instructed to do so, neither it will emit any event.

  • throttle_interval – 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: str, data_id: str)[source]#

Delete a data point from a feed

Parameters:
  • feed – Feed name

  • data_id – Data point ID to remove

main()[source]#

Implementation of the main loop of the plugin.

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

Receive data from the specified Adafruit IO feed

Parameters:
  • feed – Feed name

  • limit – 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: str)[source]#

Receive the next unprocessed data point from a feed

Parameters:

feed – Feed name

receive_previous(feed: str)[source]#

Receive the last processed data point from a feed

Parameters:

feed – Feed name

send(feed: str, value: int | float | str, enqueue: bool = True)[source]#

Send a value to an Adafruit IO feed.

Parameters:
  • feed – Feed name.

  • value – Value to send.

  • enqueue – If throttle_interval 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: str, latitude: float, longitude: float, elevation: float, value: int | float | str | None = None)[source]#

Send location data to an Adafruit IO feed

Parameters:
  • feed – Feed name

  • lat – Latitude

  • lon – Longitude

  • ele – Elevation

  • value – Extra value to attach to the record

start()#

Start the plugin.

stop()[source]#

Stop the plugin.

subscribe(feed: str)[source]#

Subscribe to a feed.

Parameters:

feed – Feed name

unsubscribe(feed: str)[source]#

Unsubscribe from a feed.

Parameters:

feed – Feed name

wait_stop(timeout=None)#

Wait until a stop event is received.