ios - Nest Thermostat Away Status 变回 home

标签 ios objective-c firebase nest-api

Nest 恒温器 SDK,使用 Nest 的 iOS 示例代码作为引用。

示例代码中概述了温度设置。将离开状态设置为 awayhome(不是向 firebase 发送的字符串值)。

来自上一个问题 Change Away Status on Nest Thermostat (Nest API)我正在更改离开状态:

    self.rootFirebase = [[Firebase alloc] initWithUrl:@"https://developer-api.nest.com/"];
    Firebase *structuresRef = [self.rootFirebase childByAppendingPath:@"structures"];
    Firebase *thisStructureRef = [structuresRef childByAppendingPath: @"structure_id_0"];
    Firebase *awayRef = [thisStructureRef childByAppendingPath: @"away"];

    // Set Status
    [awayRef setValue:@"away"];

这在日志中反射(reflect)为 away。让这个坚持下去会导致问题。

设置离开后,一秒钟后的日志显示它又回到了home

统计数据似乎覆盖了来自应用程序的请求,统计数据中的内容具有优先权

- (void)addSubscriptionToURL:(NSString *)URL withBlock:(SubscriptionBlock)block {

    Firebase *newFirebase2 = [self.rootFirebase childByAppendingPath:@"structures"];
    [newFirebase2 observeEventType:FEventTypeChildAdded withBlock:^(FDataSnapshot *snapshot) {

        // Put structures int a dictionary
         NSMutableDictionary *dict = snapshot.value;
         NSLog(@"\n\n******** STATUS: Away Status =  %@ **********\n\n", [dict valueForKey:@"away"]);

        }];
}

有没有人用nest SDK成功设置离开状态?当应用程序在应用程序模型的许多不同部分启动时,我尝试立即设置离开状态,只是为了尝试让状态保持不变。除了 github 上不合适的示例项目外,谷歌搜索也没有任何帮助

最佳答案

你确定你调用的结构正确吗?它应该是以下内容:

structures/VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3/away

取决于你实际的structure_id,引用here

关于ios - Nest Thermostat Away Status 变回 home,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36266379/

相关文章:

ios - 无法执行委托(delegate)

ios - 如何退出在代码中初始化的 UIStoryboard

objective-c - NSString stringWithFormat不必要的结果

java - Android FirebaseRecyclerView 实现搜索用户功能时遇到的问题

android - 以位图作为覆盖流式传输视频

ios - SKPSMTPMessage中没有硬编码的“fromEmail”(发件人)

objective-c - 你能在一个选择器中存储多个方法吗?

java - 任务 ':app:processDebugGoogleServices' 执行失败

javascript - 如何确认 Firebase Web 中的推送请求成功?

ios - 在不修改其他属性的情况下替换 NSAttributedString 中的整个文本字符串