GroveStream Python - Quick Start

This tutorial will walk you through the creation of a user account, an organization, and a component with two streams. The tutorial includes Python script that uploads two random stream feed samples every 10 seconds.

Basic knowledge of the Python programming language is required.

Step 1: Create a Free User Account and Organization

GroveStreams - Create User Account

Open a browser and navigate to the GroveStreams registration page and sign up.
After creating a free user account, log into GroveStreams.

GroveStreams - Create Organization

You will be prompted to create an organization. Select Yes.

What's an Organization?
An organization is a Workspace, typically representing a home, business, or organization. Each organization has its own set of components, streams, dashboards, maps, and other items. An organization allows you to control user and device access to the organization. You are automatically the "owner" and given full access rights when you create an organization. Other users may invite you to their organizations with rights they give you. All of the organizations, you "own" or are a member of, will appear in your GroveStreams start page (the first page that appears when you sign in).


GroveStreams - Edit Organization

1. Enter a name for the new organization. It can be any name.
2. Click Create Organization.

GroveStreams - Select Organization

1. Enter your new organization by clicking on its name.


Step 2: Create Your Python Script


Below are two code examples that will upload two stream feeds into a GroveStreams organization. Both examples do the same thing but use a different GroveStreams API. Each example is written for two Python versions (2.7 and 3.2):
  • Example 1: Uploads feeds using only an HTTP URL.
  • Example 2: Uploads feeds using a compressed JSON body.


Open your favorite Python IDE (Integrated Development Environment) and create a new Python script file. Copy one of the below into the new script file:

How to Copy
Select all of the code below and copy it to the clipboard (Ctrl-c). Paste the code into the Python script file(Ctrl-v). Remove the first line "Data provided by Pastebin.com - Download Raw - See Original" from the Python IDE script.

Or

Click the Download Raw link below, select all of the code and copy it to the clipboard (Ctrl-c). Paste the code into the Python IDE script file (Ctrl-v).

Can't see the code below? It can also be found here:


Next you will need to set the api_key variable within the GroveStreams Settings section of the script:


GroveStreams - Modify Script API Key
1. Set the api_key variable in your script to match your GroveStreams organization Secret API Key.

GroveStreams - API Key

To find your Secret API Key:
1. Click the API Keys button
2. Select the Feed Put API Key (with auto-registration rights) key
3. Click View Secret Key
4. Select and copy the API Secret Key to the clipboard (Ctrl-c) and paste it into your script (Ctrl-v) replacing the existing api_key value.


Step 3: Run Your Stream Feeder

Run your python code.

Step 4: See Your Results

Stream View


Within your GroveStreams organization:
1. The notification button will indicate if you have any notifications. Some notifications report errors. Check for any notifications that may contain any upload errors.
2. Select the Components folder.
3. Click the Refresh button.
4. Your new component will appear under the Components folder. Expand it to view its streams.
5. Select a Stream.
6. Your latest measurements will appear within the Quick View panel. The Quick View panel will display No Data if no measurements have been uploaded.
7. Double click a stream to explore or edit historical values.

Congratulations! You have successfully created a Python script that uploads measurements into GroveStreams.

Click on the Dashboards tab to create dashboards and maps. Keep exploring and learning!

Troubleshooting

Watch for errors within your Python IDE debug window. Successful API calls to GroveStreams should return a status of: HTTP/1.1 200 OK. An error message should appear within the Python debug window if the call fails.

If the call made it to a GroveStreams server, but an error still occurred, a GroveStreams system notification will be created that contains the error. While in the GroveStreams organization's Observation Studio, click on the Notifications button (located in the top toolbar. It looks like an envelope) and select the System tab. Click Refresh to list new notifications.

Ensure your development environment can reach the GroveStreams servers. Do a command line ping to grovestreams.com. If that is unsuccessful, then try pinging the GroveStreams IP address directly (173.236.12.163). If you can ping the IP address, but cannot ping grovestreams.com, then you are experiencing a DNS lookup issue.

Any parameter that is part of the URL needs to be URL encoded. This should only become an issue if you have added parameters to the URL with reserved URL characters (such as spaces or commas). There are many free URL encoders on-line that you can use to encode your URL or URL parameters such as freeformatter.com.

Are you seeing more than one component? If so, you probably changed the script's component_id after running it once. Delete the GS component that has the incorrect ID by right clicking on it and selecting Delete. Double click the component to view its ID.

Ensure you are not using the same API Secret Key for different organizations. API Secret Keys are only associated with the organization they have been created within and can only be used for that organization.

Troubleshooting Checklist

  • Did you remember to change the script's api_key variable?
  • Have you checked your GS organization for any notifications?
  • Is the script's debug window reporting any errors?
  • Have you connected your computer or device to a network that has access to the world wide web?
  • Is the first line in your script "Data provided by Pastebin.com - Download Raw - See Original"? If so, delete it. It was automatically added by pastebin when you did a Ctrl-c and Ctrl-v while copying the sketch.
  • Still can't figure out what's wrong? Delete your GroveStreams organization, start over, and follow the instructions carefully. Sometimes it's easier and faster to start over than to try and figure out what step was missed or performed incorrectly.


Still having problems or you want to modify the solution and are not sure what to do?

Send us an email and we'll do our best to help you out: support@grovestreams.com

Helpful Links

GroveStreams Help Center
GroveStreams Forum
GroveStreams URL Feed PUT API
GroveStreams URL with JSON Feed PUT API
Python 2.7
Python 3.2