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

Lightweight implementation for publishing to feeds needed #33

@probonopd

Description

@probonopd

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions