Espec North America Examples of Web Controller rest api usage for SEL

Created by Myles Metzler
Some basic examples using Espec North America's web controller RESTful API

requires the requests library:
import requests, json, time

def pprint(data):
    print(json.dumps(data, sort_keys=True, indent=4))

uri = ''
headers = {'Content-type': 'application/json'}

# 1) Turn on the environmental chamber.
print('\n\nRun constant mode:')
pprint( + '/operations/constant').json())

# 2) Turn on humidity control.
data = [
    {'controller':1, 'N':2, 'enable':True}  #Humidity
pprint( + '/loops', data=json.dumps(data), headers=headers).json())

# 3/4) Set the temperature/humidity set point
data = [
    {'controller':1, 'N':1, 'enable':True, 'setValue':45}, #Temperature
    {'controller':1, 'N':2, 'enable':True, 'setValue':55}  #Humidity
pprint( + '/loops', data=json.dumps(data), headers=headers).json())

# 5/6) Read the temperature/humidity
print('Get control loop status')
pprint(requests.get(uri + '/loops').json())

# 7) Turn off the chamber.
print('\n\nStop operation for 10 seconds:')
pprint( + '/operations/standby').json())

Comments (0)


You can clone a snippet to your computer for local editing. Learn more.