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
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-0.3.0.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for sensoterra-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55730ba354bad19ab456e0bcd069edf2e8179d10e2d155dd3e29e4e691bd46c1 |
|
MD5 | 5a90705a92ad8497c49b8c0e8f2005d5 |
|
BLAKE2b-256 | 18ca02f4c2770bcd90b36946b4d0faaa87d2f1eb9f4f714c66a956ca5b41e907 |