# Wiki source code of nest_set.py

Last modified by Richard Johnson on 2018/08/01 00:47
Export
Office Formats
Export as PDF
Other Formats

Select the pages to export:

select all/ none

Legend:
  Created Page
  Modified Extension Page
  Clean Extension Page

Export as HTML

Show last authors

author | version | line-number | content
--- | --- | --- | ---
|  | 1 | {{{#! /usr/bin/env python
|  | 2 |
|  | 3 | import requests
|  | 4 | import sys
|  | 5 |
|  | 6 | my_token = 'my_nest_access_token'
|  | 7 |
|  | 8 | everything = requests.get('',
|  | 9 | headers={'Authorization': 'Bearer ' + my_token, 'Content-Type': 'application/json'})
|  | 10 |
|  | 11 | for x in everything.json()['thermostats']:
|  | 12 | device_id = x
|  | 13 | break
|  | 14 |
|  | 15 | if sys.argv[1] == 'off':
|  | 16 | print 'off'
|  | 17 | cmd = 'off'
|  | 18 | elif sys.argv[1] == 'on':
|  | 19 | print 'on'
|  | 20 | cmd = 'heat-cool'
|  | 21 |
|  | 22 | set = requests.put('' +
|  | 23 | device_id +
|  | 24 | '?auth=my_nest_access_token',
|  | 25 | headers={'Authorization': 'Bearer ' + my_token, 'Content-type': 'application/json'},
|  | 26 | data='{"hvac_mode": cmd}')
|  | 27 | }}}

# Applications

# Tips

Jump to any page in the wiki with Ctrl+G or Meta+G.
See more shortcuts.

# Need help?

If you need help with XWiki you can contact:

- Community Support
- Professional Support

XWiki Debian 13.10.2