GithubHelp home page GithubHelp logo

nscooling / cosmsender Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jackkelly/cosmsender

0.0 2.0 0.0 75 KB

Python class to send data to Cosm. Caches data to minimise API requests and to protect against network errors.

License: MIT License

cosmsender's Introduction

Simple module for sending data to Cosm. It caches datapoints to limit the number of API requests. If an API request fails then the data is saved in the cache and sent when the API request next succeeds.

Installation: Place this file in a directory. Add that directory to the environment variable PYTHONPATH

Usage:

from cosmSender import CosmSender

# Configure data stream defaults
dataStreamDefaults = {
                      "min_value"    : "0.0",
                      "unit": { "type"  : "derivedSI",
                                "label" : "watt",
                                "symbol": "W" }
                      }

# Create a new CosmSender object (add your APIKEY and FEED id).
# Use cacheSize=0 to send data to Cosm as soon as it arrives at this script
c=CosmSender(<APIKEY>, <FEED>, dataStreamDefaults, cacheSize=1)

# Send data to dataStream '8' with value '1'.
# Because this is the first time that we have referenced dataStream '8', 
# CosmSender will send Cosm the dataStreamDefaults for dataStream '8'
c.sendData('8','1')

# Send another datapoint to CosmSender.  Because cacheSize is set to 1,
# CosmSender will cache this datapoint (with its correct timecode)
# and will not send it to Cosm yet.
c.sendData('8','2')

# Send another datapoint.
# This point will be sent together with the previous data point.
c.sendData('8','3')

# Flush cache before finishing
c.flush()

cosmsender's People

Contributors

jackkelly avatar stringfellow avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.