Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Lightweight implementation for publishing to feeds needed #33

Open
probonopd opened this issue Mar 3, 2014 · 0 comments
Open

Lightweight implementation for publishing to feeds needed #33

probonopd opened this issue Mar 3, 2014 · 0 comments

Comments

@probonopd
Copy link

For memory-constrained python environments (think OpenWrt) it would be good to have a lightweight implementation for publishing data to feeds.

I am using something along these lines:

def update_xively(dictionary):
    datastreams = ""
    for key in dictionary:
        datastreams = datastreams + '{"id":"' + str(key) + '", "current_value":"' + str(dictionary[key]) + '"},'
    datastreams = datastreams[:-1] # Remove last ","
    json='{"version":"1.0.0", "datastreams":[' + datastreams + ']}'

    print json

    command = ("curl --silent --insecure  --header 'X-ApiKey: %s' " \
    "--header 'Content-Type: application/json; charset=utf-8' --verbose '%s' " \
    " --request PUT -d '%s'" % (apiKey,feed,json))
    os.system(command)

values = {'seconds':passed, 'percent':level, 'millivolts':voltage, 'voltage_now':voltage_now, 'capacity':capacity, 'temperature':temperature}

update_xively(values)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant