Skip to content

Plugins: Getting Started

Sean Shahkarami edited this page Oct 7, 2020 · 12 revisions

Plugins: Getting Started

Overview

pywaggle provides an implementation of the Waggle plugin interface to make it easy to hook existing code into the Waggle data pipeline. This allows developers to publish and subscribe to various data streams throughout the pipeline.

Examples

Basic Publishing

We'll start with the basics of publishing. In this example, we make up a fake humidity value and publish it so it can be sent to beehive and other plugins.

import waggle.plugin as plugin
import time

plugin.init()

while True:
    # publish made up htu21d humidity value
    plugin.publish('env.humidity.htu21d', 12.34)
    time.sleep(1)

Technical Notes

The plugin interface performs its work in a background thread and communicates through thread-safe queues. This allows it to be used safely and easily in a range of existing designs (multithreaded, callback based, asyncio based, etc) without interrupting the program flow.

Clone this wiki locally