是否可以在一次通话中获取恒温模式(冷却,加热)的目标温度?现在我感觉我可以获得当前恒温器模式的目标温度,然后将恒温器模式更改为第二个,并获得第二个恒温器模式的目标温度。
同样是改变目标临时值的问题。是否可以在一次请求中更改加热和冷却模式的目标温度?
答案 0 :(得分:2)
假设您的系统可以冷却和加热,恒温器有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次调用以设置模式并设置温度。
答案 1 :(得分:0)
即使是单个API调用中的多个恒温器,也可以获得所有恒温器数据。我刚刚发布了一个用python编写的开源应用程序,它在BitBucket上执行:
https://bitbucket.org/dwalton64_/window-watcher
该应用程序查看来自地下天气的天气数据,来自airnow的空气质量数据和来自Nest的数据,以确定用户是应该打开还是关闭窗户。我对Nest进行API调用,在一次调用中获取所有数据,然后解析结构中的数据。然后应用程序使用恒温器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。