Skip to content

Instantly share code, notes, and snippets.

@IlyaSkriblovsky
Last active April 20, 2017 10:02
Show Gist options
  • Save IlyaSkriblovsky/f5dff83b8f627a7692b89f534daadf18 to your computer and use it in GitHub Desktop.
Save IlyaSkriblovsky/f5dff83b8f627a7692b89f534daadf18 to your computer and use it in GitHub Desktop.
Example of getting temperatures and setting guard state of ZONT H-1
# -*- coding: utf-8 -*-
import requests
device_id = 1580
login = 'demo'
password = 'demo'
client = 'your@email.com'
result = requests.post(
'https://zont-online.ru/api/devices',
json={'load_io': True},
auth=(login, password),
headers={'X-ZONT-Client': client}
).json()
for device in result['devices']:
if device['id'] == device_id:
last_boiler_state = device['io'].get('last-boiler-state', {})
print 'Авария?', last_boiler_state['fail']
if last_boiler_state['ot']:
print 'ГВС активно?', 'dhw' in last_boiler_state['ot']['s']
import requests
device_id = 1580
login = 'demo'
password = 'demo'
client = 'your@email.com'
result = requests.post(
'https://zont-online.ru/api/devices',
json={'load_io': True},
auth=(login, password),
headers={'X-ZONT-Client': client}
).json()
for device in result['devices']:
if device['id'] == device_id:
for therm in device['thermometers']:
if therm['is_assigned_to_slot']:
print therm['serial'], therm['last_state'], therm['last_value']
guard_action = 'enabled'
requests.post(
'https://zont-online.ru/api/set_io_port',
json={'device_id': device_id, 'portname': 'guard-state', 'type': 'string', 'value': guard_action},
auth=(login, password),
headers={'X-ZONT-Client': client}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment