Search code examples
iosfirebasenest-api

How do you cancel a Nest ETA using Firebase on iOS?


According to the nest API docs:

"To cancel an eta, send estimated_arrival_window_begin = 0. Check that you're sending an integer (0) in this call, not a string ("0"), or the call will fail."

See https://developers.nest.com/documentation/cloud/eta-reference/

My code is based on the iOS NestDK sample which uses Firebase.

I set things up using the addSubscriptionToURL method as follows: ​

[[FirebaseManager sharedManager] addSubscriptionToURL:[NSString stringWithFormat:@"structures/%@/eta", structureId] withBlock:^(FDataSnapshot *snapshot) {}];

I can then make successful calls to set an eta window for a specific trip.

However, i can't seem to be able to cancel the eta for the same trip. If i just specify the trip_id and estimated_arrival_window_begin properties i get an error message complaining that the estimated_arrival_window_end field is missing.

NSMutableDictionary *values = [[NSMutableDictionary alloc] init];
[values setValue:[_tripId UUIDString] forKey:@"trip_id"];
[values setValue:[NSNumber numberWithInt:0] forKey:@"estimated_arrival_window_begin"];
[[FirebaseManager sharedManager] setValues:values forURL:[NSString stringWithFormat:@"structures/%@/eta", structureId]];

I tried also setting estimated_arrival_window_end to 0 but i then get an error message saying that the estimated_arrival_window_begin is in the past. It seems to be interpreting the 0 value as the beginning of time. Well some time in 1970 anyway!

What am i doing wrong here?!

Thanks!


Solution

  • Are you using a Nest account with virtual devices created with the Nest Home Simulator? There appears to be a bug using virtual devices versus real devices. Please try using a Nest account with real devices.