Nest binding in 2.0?

Please let us know if it seems to be running properly with the later JSON library.

watou, were you working on a dedicated updated Nest binding for 2.0?

I am not now working on one, but I do very much want to as my first contribution to OH2/ESH. I am excited to have discovery populate the available Things instead of currently requiring manual definition. It will be a nice step forward, like OH2.

I have the version 1 binding returning and parsing now from OH2 except last event time, but that is being returned in the json, so I think it is a simple matter of not ignoring it when it changes and it should populate as well. I am working with smoke_co currently. The thermostat should work as well though, I just need to create the virtual home device for it. Getting it going was mostly a dependency issue resolution. I will commit back to my fork, but I would like to see if it still works in OH1 first. I don’t have OH1 installed anymore though. A funny? situation would be the OH1 binding working only with OH2. Okay, not so funny…

I know there was some reason I was limited to using the older org.codehaus JSON library instead of com.fasterxml, but in the 2.0 version I plan to switch to GSON, as I recently read that that is the preferred library. Perhaps it would make sense to add the org.codehaus library to the 1.x compatibility layer so we can avoid code changes before then?

I agree, this bundle is used by some other bindings as well. Would you be so kind to create a PR, which adds Jackson to the openHAB 2 TP and to the dependencies feature, so that it ends up in the distribution?

Amended issue#274 for the time being.

Is there a old thread I can read that debates gson vs jackson?

Not that I am aware of. But in Eclipse SmartHome, GSON had been chosen for a few central parts, that’s why it also leaks into openHAB 2.
From what I find on the net, there might be some slightly better performance in gson vs. jackson and the API is rather nice to use. So for all new bindings, gson is the suggested library to use.

Regards,
Kai

Anyone find a way to bind the nest? try to, but it find no things

Since the Nest binding is currently a 1.x binding, you must specify a binding config string in a .items file. See the wiki page for more information. I plan on having a 2.0 version that discovers your thermostats, smoke + CO detectors and cameras.

ah thanks, would be nice with discovery

I Installed the Nest1 Binding and configured items and a test sitemap, and now I’m getting a Could not lock User prefs every 30 seconds in my log. I’ve checked ownership and permissions on my Linux instance. What file is the Nest binding trying to touch?

2016-12-20 14:31:49.260 [WARN ] [java.util.prefs                     ] - Could not lock User prefs.  Unix error code 2.
2016-12-20 14:31:49.261 [WARN ] [java.util.prefs                     ] - Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.

I added bindings = zwave,astro,nest1 into my addons.cfg in

bundle:list
211 | Active | 80 | 1.9.0.201612190210 | openHAB Nest Binding

~openhab/.java/.userPrefs should be it.

I don’t have a Home for openhab in my OH2 instance. Is this a Karaf location instead of a true home directory? I tried creating these in my install directory /opt/openhab2/.java/.userPrefs without luck.

What am I missing here?

pi@openhab2:/opt/openhab2 $ sudo service openhab status
● openhab.service - Starts and stops the openHAB Home Automation Bus
   Loaded: loaded (/usr/lib/systemd/system/openhab.service; enabled)
   Active: active (running) since Tue 2016-12-20 17:00:57 EST; 1min 16s ago
     Docs: http://www.openhab.org
 Main PID: 524 (karaf)
   CGroup: /system.slice/openhab.service
           ├─524 /bin/sh /opt/openhab2/runtime/bin/karaf
           └─707 /usr/bin/java -Dopenhab.home=/opt/openhab2 -Dopenhab.conf=/opt/openhab2/conf -Dopenhab.runtime=/opt/openhab2/runtime -Dopenhab.userdata=/opt/openhab2/use...

OK, whichever user under which the openHAB runtime is started will be the correct home (~) directory, below which there should be .java/.userPrefs.

You can change this in your startup script by passing

-Djava.util.prefs.userRoot=/path/to/writeable/directory

and so the Java Preferences files will be read and written there.

Now just need to find where the start.sh picks the others up from. Off to search for all the -Djava parameters.

You could edit runtime/bin/setenv or you might be able to change that system property by starting like

EXTRA_JAVA_OPTS=-Djava.util.prefs.userRoot=/path/to/writeable/directory ./start.sh
1 Like

I came across the setenv about the same time that you posted.

I went ahead and put it in the other OPTIONS section. I didn’t have luck with the EXTRA JAVA OPTS, probably because I didn’t put a return in the string.

#
# set java options
#

export JAVA_OPTS="${JAVA_OPTS}
  -Djava.util.prefs.userRoot=/opt/openhab2/.java/.userPrefs
  -Dopenhab.home=${OPENHAB_HOME}
  -Dopenhab.conf=${OPENHAB_CONF}

Errors have been eliminated!

Thanks!

1 Like

To avoid having to authorize a new PIN after upgrades, make sure that /opt/openhab2/.java/.userPrefs survives the upgrade unharmed!

1 Like