Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- set curl_path=c:\nest\curl
- set client_pin=[you get this from the provided URL on the client page]
- set client_id=[you get this from the client page]
- set client_secret=[you get this from the client page]
- set access_token=[you'll get this from a successful oauth]
- rem set new_url=https://firebase-apiserver02-tah01-iad01.dapi.production.nest.com:9553
- rem TOGGLE FOR AUTH
- rem set GET_AUTH=true
- rem TOGGLE FOR AUTH
- rem TOGGLE FOR DEAUTH
- set GET_DEAUTH=true
- rem TOGGLE FOR DEAUTH
- rem TOGGLE FOR GET
- rem set GET_DATA=true
- rem TOGGLE FOR GET
- rem TOGGLE FOR SET
- rem set SET_DATA=true
- rem TOGGLE FOR SET
- rem TOGGLE FOR STREAM
- rem set STREAM_DATA=true
- rem TOGGLE FOR STREAM
- rem DEVICE_CONFIG
- rem virtual:
- set dev_id1=[manually enter example devid]
- rem real:
- set dev_id2=
- set dev_id=%dev_id1%
- rem DEVICE_CONFIG_END
- rem VALUE_CONFIG
- set value1=target_temperature_f
- set value2=name
- set value3=hvac_mode
- set value4=ambient_temperature_f
- set value5=target_temperature_high_f
- set value_name=%value3%
- set new_int_value=77
- set new_string_value=heat
- set new_value=%new_string_value%
- rem VALUE_CONFIG_END
- rem STRUCT_CONFIG
- set struct1=devices
- set struct2=structures
- set struct3=metadata
- set struct4=devices/thermostats
- set struct4=devices/smoke_co_alarms
- set struct4=devices/company
- set struct_name=%struct2%
- rem STRUCT_CONFIG_END
- set url=https://developer-api.nest.com/%struct_name%.json?auth=%access_token%
- set url_by_id=%new_url%/devices/thermostats/%dev_id%.json?auth=%access_token%
- set url_by_value=%new_url%/devices/thermostats/%dev_id%/%value_name%.json?auth=%access_token%
- set header=Content-Type: application/json
- rem GET_DATA
- set get_struct=curl\curl.exe -k -L %url%
- set get_by_id=curl\curl.exe -k -L %url_by_id%
- set get_by_value=curl\curl.exe -k -L %url_by_value%
- set get_url=%get_by_id%
- rem GET_DATA_END
- rem OAUTH
- rem set oauth=curl\curl.exe -k -i -v -X POST -d "code=%client_pin%&client_id=%client_id%&client_secret=%client_secret%&grant_type=authorization_code" https://api.home.nest.com/oauth2/access_token
- set oauth=curl\curl.exe -k -i -v -X POST "https://api.home.nest.com/oauth2/access_token?code=%client_pin%&client_id=%client_id%&client_secret=%client_secret%&grant_type=authorization_code"
- rem SET_DATA
- rem set change_num=curl\curl.exe -k -i -L -X PUT %url_by_value% -H "Content-Type: application/json; charset=UTF-8" -d "%new_int_value%"
- rem set change_text=curl\curl.exe -k -i -L -X PUT "%url_by_value%" -H "%header%" -d '"%new_string_value%"'
- rem set change_text=curl\curl.exe -k -i -L -X PUT -H "Content-Type: application/json; charset=UTF-8" -d "{"%value_name%":%new_value%}" %url_by_id%
- rem set change_text=curl\curl.exe -k -i -L -X PUT "%url_by_value%" -H "%header%" -d '"%new_value%"'
- rem THIS WORKS:
- rem set change_text=curl\curl.exe -k -L -X PUT "https://developer-api.nest.com/devices/thermostats/%dev_id%?auth=%access_token%" -H "Content-Type: application/json" -d "{\"hvac_mode\":\"heat\"}"
- rem set stream=curl\curl.exe -k -i -v -L -X GET -H "Accept: application/json" -H "Accept: text/event-stream" -H "Keep-Alive: 60" -H "Connection: keep-alive" "https://firebase-apiserver02-tah01-iad01.dapi.production.nest.com:9553/?auth=[FILL IN AUTH_TOKEN]"
- set deauth=curl\curl.exe -k -i -v -L -X DELETE "https://api.home.nest.com/oauth2/access_tokens/%access_token%"
- set set_data=%change_text%
- echo.
- if defined GET_AUTH %oauth%
- if defined GET_AUTH echo.
- if defined GET_DEAUTH %deauth%
- if defined GET_DEAUTH echo.
- if defined GET_DATA echo %get_url%
- if defined GET_DATA echo.
- if defined GET_DATA %get_url%
- if defined GET_DATA echo.
- if defined SET_DATA echo %set_data%
- if defined SET_DATA echo.
- if defined SET_DATA %set_data%
- if defined SET_DATA echo.
- if defined STREAM_DATA %stream%
- if defined STREAM_DATA echo.
- goto end_com
- - To **change** the specific structure to away. The value here is a string so be sure to include the single quotes:
- curl -v -L -X PUT "https://developer-api.nest.com/structures/<STRUCTURE ID>/away?auth=<AUTH_TOKEN>" -H "Content-Type: application/json" -d '"away"'
- :end_com
- goto end_com2
- echo %curl_path%
- echo %client_pin%
- echo %client_id%
- echo %client_secret%
- echo %access_token%
- :end_com2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement