1

是否可以一次调用两种恒温器模式(冷、热)的目标温度?现在我有一种感觉,我可以获取当前恒温器模式的目标温度,然后将恒温器模式更改为第二个,并获得第二个恒温器模式的目标温度。

改变目标温度也是同样的问题。是否可以在一个请求中同时更改加热和冷却模式的目标温度?

4

2 回答 2

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 次电话来设置模式并设置温度。

于 2014-10-07T19:49:53.843 回答
0

可以获取所有恒温器数据,即使是单个 API 调用中的多个恒温器。我刚刚在 BitBucket 上发布了一个用 python 编写的开源应用程序:

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。

于 2014-10-28T03:09:25.307 回答