Nest Binding - Cannot update data model?

Hi there. Super new to OH, but am enjoying building my config out. :smiley:
Hoping someone can help me out with the Nest binding. I am fairly certain I’ve gone about following the Nest binding Wiki section correctly, but when I go to set Away mode my log spits this out:

2015-11-22 21:29:11.557 TRACE o.o.b.n.internal.NestBinding[:256]- internalReceiveCommand(item='home_away',    command='away')
2015-11-22 21:29:11.560 DEBUG o.o.b.n.internal.NestBinding[:322]- About to set property 'structures(Home).away' to 'away'
2015-11-22 21:29:11.598 ERROR o.o.b.n.internal.NestBinding[:355]- Unable to update data model
java.lang.NullPointerException: null
    at org.openhab.binding.nest.internal.NestBinding.updateNest(NestBinding.java:325)
    at org.openhab.binding.nest.internal.NestBinding.commandNest(NestBinding.java:281)
    at org.openhab.binding.nest.internal.NestBinding.internalReceiveCommand(NestBinding.java:257)
    at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:96)
    at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:42)
    at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)

I am running OH 1.70 on an RPI2 Raspbian wheezy - java is 1.8.0

Cheers!

To clarify, it appears to be that everything Nest related is not functioning. The last check-in shown is just blank, and I am not getting a humidity reading off of the thermostat, either.

The exception is caused by not having successfully polled the Nest API earlier, which is where the problem lies. Please turn on TRACE logging per the wiki to help identify the root cause.

Here is a fresh snip. Thank you for reading!

2015-11-23 21:17:38.442 DEBUG o.o.b.n.internal.NestActivator[:33]- Nest binding has been started.
2015-11-23 21:17:38.487 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig==[structures(Home).away]
2015-11-23 21:17:38.493 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=structures(Home).away
2015-11-23 21:17:38.495 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘=[structures(Home).away]’
2015-11-23 21:17:38.498 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig=<[thermostats(Living Room).last_connection]
2015-11-23 21:17:38.500 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).last_connection
2015-11-23 21:17:38.501 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘<[thermostats(Living Room).last_connection]’
2015-11-23 21:17:38.503 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig==[thermostats(Living Room).hvac_mode]
2015-11-23 21:17:38.504 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).hvac_mode
2015-11-23 21:17:38.505 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘=[thermostats(Living Room).hvac_mode]’
2015-11-23 21:17:38.507 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig=<[thermostats(Living Room).temperature_scale]
2015-11-23 21:17:38.508 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).temperature_scale
2015-11-23 21:17:38.509 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘<[thermostats(Living Room).temperature_scale]’
2015-11-23 21:17:38.511 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig=<[thermostats(Living Room).ambient_temperature_f]
2015-11-23 21:17:38.512 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).ambient_temperature_f
2015-11-23 21:17:38.514 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘<[thermostats(Living Room).ambient_temperature_f]’
2015-11-23 21:17:38.515 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig=<[thermostats(Living Room).ambient_temperature_c]
2015-11-23 21:17:38.516 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).ambient_temperature_c
2015-11-23 21:17:38.517 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘<[thermostats(Living Room).ambient_temperature_c]’
2015-11-23 21:17:38.519 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig=<[thermostats(Living Room).humidity]
2015-11-23 21:17:38.520 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).humidity
2015-11-23 21:17:38.521 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘<[thermostats(Living Room).humidity]’
2015-11-23 21:17:38.523 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig==[thermostats(Living Room).target_temperature_f]
2015-11-23 21:17:38.524 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).target_temperature_f
2015-11-23 21:17:38.526 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘=[thermostats(Living Room).target_temperature_f]’
2015-11-23 21:17:38.528 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig==[thermostats(Living Room).target_temperature_low_f]
2015-11-23 21:17:38.530 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).target_temperature_low_f
2015-11-23 21:17:38.531 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘=[thermostats(Living Room).target_temperature_low_f]’
2015-11-23 21:17:38.533 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig==[thermostats(Living Room).target_temperature_high_f]
2015-11-23 21:17:38.534 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).target_temperature_high_f
2015-11-23 21:17:38.535 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘=[thermostats(Living Room).target_temperature_high_f]’
2015-11-23 21:17:38.537 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig=<[thermostats(Living Room).away_temperature_low_f]
2015-11-23 21:17:38.538 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).away_temperature_low_f
2015-11-23 21:17:38.539 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘<[thermostats(Living Room).away_temperature_low_f]’
2015-11-23 21:17:38.541 TRACE o.o.b.n.i.NestGenericBindingProvider[:148]- validateItemType called with bindingConfig=<[thermostats(Living Room).away_temperature_high_f]
2015-11-23 21:17:38.542 TRACE o.o.b.n.i.NestGenericBindingProvider[:157]- validateItemType called with property=thermostats(Living Room).away_temperature_high_f
2015-11-23 21:17:38.543 DEBUG o.o.b.n.i.NestGenericBindingProvider[:111]- Processing binding configuration: ‘<[thermostats(Living Room).away_temperature_high_f]’
2015-11-23 21:20:20.781 TRACE o.o.b.n.internal.NestBinding[:256]- internalReceiveCommand(item=‘home_away’, command=‘home’)
2015-11-23 21:20:20.784 DEBUG o.o.b.n.internal.NestBinding[:322]- About to set property ‘structures(Home).away’ to ‘home’
2015-11-23 21:20:20.812 ERROR o.o.b.n.internal.NestBinding[:355]- Unable to update data model
java.lang.NullPointerException: null
at org.openhab.binding.nest.internal.NestBinding.updateNest(NestBinding.java:325)
at org.openhab.binding.nest.internal.NestBinding.commandNest(NestBinding.java:281)
at org.openhab.binding.nest.internal.NestBinding.internalReceiveCommand(NestBinding.java:257)
at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:96)
at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:42)
at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197)

The binding can’t set “away” mode until it has completed at least one polling cycle, because it uses the name of the structure “Home” to identify the specific structure to send the command to. The binding learns all the names of structures, thermostats, smoke+CO detectors and cameras after it’s performed its first polling cycle, which usually happens very soon after the binding starts. You attempted to send the “away” command almost three minutes after the binding started, but there is no evidence that the binding attempted to perform a poll in that period of time, which I don’t have an explanation for yet.

Could you share the lines in your openhab.cfg file that start with nest: (but scramble some of the letters to the right of the = sign for security’s sake)?

Did the initial setup process of creating a “product” at nest.com appear to follow the wiki instructions, and then were you presented with a PIN that you added to openhab.cfg?

Hi @watou,

Thanks so much for helping me out. The Wiki was pretty much spot-on from what I recall. Client ID was populated with the Product ID, Client Secret was populated with Product Secret, and for the PIN I visited the Authorization URL. Here is my openhab.cfg - thanks for the reminder to use bogus values :slight_smile:

# Data refresh interval in ms (optional, defaults to 60000)
  nest:refresh=60000

# the Nest Client ID needed to use the API, must be supplied (this is Product ID)
  nest:client_id=08daghfoasdfhsaldfadasdfdbe

# the Nest Client Secret needed to use the API, must be supplied (Product Secret)
  nest:client_secret=qOMS9KSaksldjfha098sd7f2

# the PIN code that Nest presented when you authorized the above client, must be supplied
  nest:pin_code=asdiufhoaisdf902834

I’ve never put spaces before a config choice before. I don’t know it to be wrong, but could you remove the leading spaces? Also, your PIN code is how many letters long? Lastly, what OS are you running on and if you type

ls -al ~/.java

Do you see a .userPrefs directory? If you remove it and restart openHAB, does it make a difference?

Spaces removed, but same symptom.
PIN is 8 characters long.
Running Raspbian wheezy on an RPi2.
ls -al ~/.java doesn’t return anything, but I can run java -version:

java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode)

I deleted the .userPrefs directory, and now I seem to have lots of new messages in nest.log:

2015-11-25 16:27:39.080 TRACE o.o.b.n.internal.NestBinding[:128]- Querying Nest API
2015-11-25 16:27:39.082 TRACE o.o.b.n.internal.NestBinding[:570]- Retrieving access token in order to access the Nest API.
2015-11-25 16:27:39.084 TRACE o.o.b.n.internal.NestBinding[:573]- Request: AccessTokenRequest[pinCode=xxxxxxxx,clientId=xxxx,clientSecret=xxxx]
2015-11-25 16:27:39.086 TRACE o.o.b.n.i.m.AbstractRequest[:125]- About to execute 'https://api.home.nest.com/oauth2/access_token?code=xxxxxxxx&client_id=xxxxxclient_secret=xxxxgrant_type=authorization_code'
2015-11-25 16:27:39.527 WARN  o.o.b.n.i.m.AbstractRequest[:147]- Method failed: HTTP/1.1 400 Bad Request
2015-11-25 16:27:39.529 TRACE o.o.b.n.i.m.AbstractRequest[:166]- {"error":"oauth2_error","error_description":"authorization code not found","instance_id":"xxxxxx"}
2015-11-25 16:27:39.530 TRACE o.o.b.n.internal.NestBinding[:576]- Response: AccessTokenResponse[accessToken=<null>,expiresIn=<null>,error=oauth2_error,errorDescription=authorization code not found]
2015-11-25 16:27:39.531 ERROR o.o.b.n.internal.NestBinding[:579]- Error retrieving access token: AccessTokenResponse[accessToken=<null>,expiresIn=<null>,error=oauth2_error,errorDescription=authorization code not found]'
2015-11-25 16:27:39.532 WARN  o.o.b.n.internal.NestBinding[:136]- Periodic poll skipped.

OK, that suggests that the client_id, client_secret and/or pin_code are not consistent with a valid “Product” as defined at developer.nest.com and authorized to use your normal nest.com account. Could you re-check those values, and possibly create a new “Product” (previously referred to as “Client” before Nest changed the nomenclature)?

1 Like

Success!!

I created a new product, and that seems to have taken care of it!

Thank you so much @watou!

Glad that’s sorted!