Last active
April 20, 2017 10:02
-
-
Save IlyaSkriblovsky/f5dff83b8f627a7692b89f534daadf18 to your computer and use it in GitHub Desktop.
Example of getting temperatures and setting guard state of ZONT H-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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