Skip to main content

Query Sensoterra probes using the Customer API

Project description

Sensoterra

Package to retrieve Sensoterra probe data by polling the Sensoterra Customer API using async/await.

Example code

When the email and password are always available:

import time
import asyncio

from sensoterra.customerapi import CustomerApi

async def main(email, password):
  api = CustomerApi(email, password)
  api.set_language("en")

  while True:
    api.poll()

    for probe in api.probes():
        print(probe)
        for sensor in probe.sensors():
            print(sensor)
        print()

    time.sleep(900)
    print('-' * 70)

asyncio.run(main("me@example.com", "secret"))

Otherwise request a authentication token:

from datetime import datetime

async def get_token(email, password):
  api = CustomerApi(email, password)
  api.set_language("en")

  tag = "My Application"
  scope = "READONLY"
  expiration = datetime(2038, 1, 1, 0, 0)
  token = await api.get_token(tag, scope, expiration)

And use this token:

async def main(email, password):
  token = await get_token(email, password)

  api = CustomerApi()
  api.set_language("en")
  api.set_token(token)

  while True:
    probes = await api.poll()

    for probe in probes:
        print(probe)
        for sensor in probe.sensors():
            print(sensor)
        print()

    time.sleep(900)
    print('-' * 70)

Changelog

CHANGELOG

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sensoterra-2.0.1.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

sensoterra-2.0.1-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page