在一次調用中是否可以獲取恆溫器模式(冷卻,加熱)的目標溫度?現在我有一種感覺,我可以獲得當前恆溫器模式的目標溫度,然後將恆溫器模式更改爲第二個,並獲得第二恆溫器模式的目標溫度。兩種恆溫器模式的嵌套api目標溫度
也是同樣的問題改變目標臨時工。是否有可能在一個請求中更改目標溫度和散熱模式?
在一次調用中是否可以獲取恆溫器模式(冷卻,加熱)的目標溫度?現在我有一種感覺,我可以獲得當前恆溫器模式的目標溫度,然後將恆溫器模式更改爲第二個,並獲得第二恆溫器模式的目標溫度。兩種恆溫器模式的嵌套api目標溫度
也是同樣的問題改變目標臨時工。是否有可能在一個請求中更改目標溫度和散熱模式?
假設您的系統可以冷卻和加熱,恆溫器有3種模式:加熱,冷卻,加熱 - 冷卻。
如果您處於加熱模式或冷卻模式,您可以設置target_temperature。如果您處於散熱模式,則可以設置target_temperature_low_c & target_temperature_high_c。
您可以檢索在一個恆溫通話的目標溫度:
https://developer-api.nest.com/devices/thermostats/$THERMOSTAT_ID?auth=$AUTH
您可以在一個呼叫建立熱氣溫涼爽,但您將需要在加熱 - 冷卻方式:
{"target_temperature_low_c": 19, "target_temperature_high_c": 21}
您可以設置熱或涼爽溫度在一個呼叫,但你需要在熱或製冷模式:
{"target_temperature_c": 20}
如果您尚未處於適當的模式,您需要進行2次呼叫才能設置模式並設置溫度。
即使對於單個API調用中的多個恆溫器,也可以獲得所有的恆溫器數據。我剛剛張貼用Python編寫的一個開源應用程序,做它到位桶在:
https://bitbucket.org/dwalton64_/window-watcher
該應用程序看起來從天氣地下,從airnow和數據從鳥巢的空氣質量數據氣象數據,以確定用戶是否應打開或關閉窗戶。我將API調用給Nest,在一次調用中獲取所有數據,然後解析結構中的數據。應用程序然後使用恆溫器hvac模式和目標溫度來查看用戶是否應打開窗戶。
下面是一些Python代碼,我拿出我的應用程序:
nestUserUrl = "https://developer-api.nest.com/?auth=" + auth_token
nest_user_file = urllib2.urlopen(self.nestUserUrl)
nest_user_json = json.loads(nest_user_file.read())
# copy thermostat data out of the json from Nest
thermostat_data = []
for tstat_id in nest_user_json['devices']['thermostats']:
thermostat_data.append(nest_user_json['devices']['thermostats'][tstat_id])
# create thermostat objects containing the thermostat data we want to access
thermostats = []
for tstat in thermostat_data:
thermostats.append(
NestThermostat(tstat['ambient_temperature_f'], tstat['device_id'],
tstat['hvac_mode'],
tstat['is_online'], tstat['last_connection'],
tstat['name'],
tstat['software_version'], tstat['structure_id'],
tstat['target_temperature_f'],
tstat['target_temperature_high_f'],
tstat['target_temperature_low_f']))
class NestThermostat():
def __init__(self, ambient_temperature_f, device_id, hvac_mode, is_online,
last_connection, name, software_version, structure_id,
target_temperature_f, target_temperature_high_f, target_temperature_low_f):
self.ambient_temperature_f = ambient_temperature_f
self.device_id = device_id
self.hvac_mode = hvac_mode
self.is_online = is_online
self.last_connection = last_connection
self.name = name
self.software_version = software_version
self.structure_id = structure_id
self.target_temperature_f = target_temperature_f
self.target_temperature_high_f = target_temperature_high_f
self.target_temperature_low_f = target_temperature_low_f
def print_current_temp_f(self):
print("Thermostat " + self.name + " measures a current temperature of " + str(
self.ambient_temperature_f) + " degrees F")
def print_target_temp_f(self):
print("Thermostat " + self.name + " is set to " + str(self.target_temperature_f) + " degrees F")
有一次我在恆溫對象的數據,我可以同時使用HVAC模式和目標溫度:
email = ""
for thermostat in thermostats:
email += "For the thermostat " + thermostat.name + ":\n"
if thermostat.hvac_mode == 'cool':
if myWeather.temp_f < thermostat.target_temperature_f:
open_windows = True
email += " - It is cool outside (" + str(myWeather.temp_f) + " Deg F). \n"
else:
email += " - It is too hot outside to have the windows open. \n"
email += " - Thermostat is set at " + str(thermostat.target_temperature_f) + \
" Deg F\n"
if thermostat.hvac_mode == 'heat-cool':
if thermostat.target_temperature_high_f > myWeather.temp_f > thermostat.target_temperature_low_f:
open_windows = True
email += " - Thermostat is set to heat-cool and it's comfortable out (" + \
str(myWeather.temp_f) + " Deg F). \n"
elif myWeather.temp_f >= thermostat.target_temperature_high_f:
email += " - The thermostat is set to heat-cool and it is hot outside (" + \
str(myWeather.temp_f) + " Deg F). \n"
else:
email += " - The thermostat is set to heat-cool & it is cold outside (" + \
str(myWeather.temp_f) + " Deg F). \n"
email += " - The thermostat is set to cool at " + \
str(thermostat.target_temperature_high_f) + " Deg F\n"
email += " - The thermostat is set to heat at " + \
str(thermostat.target_temperature_low_f) + " Deg F\n"
if thermostat.hvac_mode == 'heat':
if myWeather.temp_f > thermostat.target_temperature_f:
open_windows = True
email += " - The thermostat is set to heat and it is warm outside (" + \
str(myWeather.temp_f) + " Deg F). \n"
else:
email += " - The thermostat is set to heat and it is cool outside (" + \
str(myWeather.temp_f) + " Deg F). \n"
email += " - Thermostat is set at " + str(thermostat.target_temperature_f) + \
" Deg F\n"
email += "\n"
請注意,熱量和冷卻模式的目標溫度是相同的值:target_temperature_f。
除了檢索所有目標溫度之外,所有內容都很清晰。我認爲我無法在一個呼叫目標溫度中檢索冷熱模式?在一次調用中,我可以檢索當前恆溫器模式的目標溫度加上描述熱 - 冷模式的target_temperature_low_c和target_temperature_high_c。你同意嗎? – user1442611 2014-10-08 08:12:17
您可以在一次調用中檢索冷卻和加熱模式下的目標溫度,因爲它們是相同的:target_temperature_c。不管你在什麼模式。 – thesimm 2014-10-08 12:29:22
我不這麼認爲。target_temperature_c與target_temperature_f的攝氏溫度相同 – user1442611 2014-10-08 13:09:21