2

Nest thermostat SDK, using iOS sample code from Nest as reference.

Setting the temperature is outlined in the sample code. Setting the away status to away or home (string value saed to firebase is not).

From a previous question Change Away Status on Nest Thermostat (Nest API) im changing the away status:

    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"];

This reflects as away in the logs. Getting this to stick is causing a problem.

After being set away the logs a second later show it's back to home again.

The stat seems to be overriding the request from the app, whatever's on the stat has priority

- (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"]);

        }];
}

Has anyone successfully set the away status with the nest SDK? Ive tried setting the away status immediately when the app launches in many different sections of the apps model just to try and get the status to stay. Not anything on a google search to assist either, apart from a sample project on github that was not suitible

Community
  • 1
  • 1
JSA986
  • 5,870
  • 9
  • 45
  • 91
  • Where else in your code accesses structures/structure_id_0/away? Is the nest thermostat set to home? If the answer is not in code then maybe ones of the devices is getting notified of the change to away and then overwriting the node with it's settings. – Jay Mar 28 '16 at 17:40
  • `structures/structure_id_0/away` is only accessed in one place. Experimenting further, setting the stat to `away` and then setting it to `home` from the app does the same behaviour in reverse, so as you suggested the stat could be overriding the request from the app, whatever's on the stat has priority. The stat respects the home/away state set from the official nest and unofficial apps out there. – JSA986 Mar 28 '16 at 20:20

1 Answers1

0

are you sure you are calling the structures correctly? it supposes to be following:

structures/VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3/away

depends on your actual structure_id, refer here

Allen
  • 6,505
  • 16
  • 19
  • No not sure, can you add some more context to your answer at all? Open to all suggestions here – JSA986 Apr 26 '16 at 13:36
  • your code `Firebase *thisStructureRef = [structuresRef childByAppendingPath: @"structure_id_0"];` should be `Firebase *thisStructureRef = [structuresRef childByAppendingPath: @"VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3"];`, but you need your actual structure_id from your API, this is just an example. – Allen Apr 26 '16 at 15:22