Search code examples
iosobjective-cfirebasenest-api

Nest Thermostat Away Status changes back to home


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


Solution

  • 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