New Netatmo binding (starting OH 3.3 M5)

I have the same issue. Have been using the old binding for over a year w/o issue. Switched to 3.3.0M5, added the account thing, but getting the error:

**COMMUNICATION_ERROR**
Rest call failed: statusCode=UNKNOWN, message=Unexpected error deserializing '{"error":"invalid_grant"}'

Added:
Just saw the latest version of the docs on Netatmo - Bindings | openHAB I’m guessing the authorization process is about to be changed in M6? No more user/pass. So I guess I’ll wait a bit.

Yes the code grant process is available in the milestone version now

1 Like

I’ve just installed v3.3.0.M5 of the Netatmo binding and I cannot get it to start. After the command to start in openhab-console the binding is always waiting and an error is logged:

299 x Waiting x  80 x 3.3.0.M5              x org.openhab.binding.netatmo
2022-06-01 18:39:41.229 [WARN ] [ore.thing.internal.ThingRegistryImpl] - bundle org.openhab.core.thing:3.2.0 (212)[org.openhab.core.thing.internal.ThingRegistryImpl(247)] : Could not get service from ref {org.openhab.core.thing.binding.ThingHandlerFactory}={backgroundDiscovery=true, service.id=1994, service.bundleid=299, service.scope=bundle, service.pid=binding.netatmo, component.name=org.openhab.binding.netatmo.internal.NetatmoHandlerFactory, component.id=402}
2022-06-01 18:39:41.230 [WARN ] [ore.thing.internal.ThingRegistryImpl] - bundle org.openhab.core.thing:3.2.0 (212)[org.openhab.core.thing.internal.ThingRegistryImpl(247)] : DependencyManager : invokeBindMethod : Service not available from service registry for ServiceReference {org.openhab.core.thing.binding.ThingHandlerFactory}={backgroundDiscovery=true, service.id=1994, service.bundleid=299, service.scope=bundle, service.pid=binding.netatmo, component.name=org.openhab.binding.netatmo.internal.NetatmoHandlerFactory, component.id=402} for reference ThingHandlerFactory

I used the following command to install the binding:

 https://openhab.jfrog.io/artifactory/libs-milestone-local/org/openhab/addons/bundles/org.openhab.binding.netatmo/3.3.0.M5/org.openhab.binding.netatmo-3.3.0.M5.jar

Not sure if I need to do something else. Does anyone have any idea?

Thanks.

What‘s your base openHAB version ?

Looks like you are using 3.2.0 need to use 3.3.0-M5 or higher. I’d wait until M6 since there are some breaking changes between M5 and M6

FYI: I have pretty much everything back online using the current milestone. Thanks for your work!

1 Like

Hello,
my Netatmo worked finally well with 3.3.0M5, but failed after doing the upgrade to M6 this morning.

I created a new token and updated the binding, but still get below:

Unexpected error deserializing '{"error":"invalid_grant"}'

Any idea?

thanks
Stefan

Update your bridge parameters by removing username and password, they are not needed anymore. Then follow the steps here.

1 Like

Hello Chris,

thanks for your reply - I don’ use username and password, but the following config.

UID: netatmo:account:xxxxx
label: Netatmo Account
thingTypeUID: netatmo:account
configuration:
  reconnectInterval: 300
  clientSecret: xxxxxx
  clientId: xxxxxx
  refreshToken: xxxxx

However, step 5. doesn’t work for me

5. Go to the authorization page of your server. http://<your openHAB address>:8080/netatmo/connect/<_CLIENT_ID_>. Your newly added bridge should be listed there (no need for you to expose your openHAB server outside your local network for this).

When I enter the Client ID and the IP of my OH server, it page doesn’t exist.

Sorry

Requested content not found.

I guess its not an issue that I use a different port - 8192 instead 8080.

Of course port 8192 in the URL if this is the port you setup for openHAB.

Doesn’t work with 8192 unfortunately either.
Something got broken from M5 to M6.

I have not tested recently as it works perfectly in my case.
You should see at binding startup a log entry of this kind: Registered Netatmo servlet at xxxxxxx
It should help you to understand what is the path to use to access the special page.

The path should be http://<openhab_ip>:8080/netatmo/connect/<account_id>

This is what I use already, as below:

http://<OH3-IPAddress>:8192/netatmo/connect/<Client_ID>

However, this URL does not link to a valid page.

As mentioned, I used 3.3.0M5 for some weeks and everything worked well. I didn’t use username/password but the new format, using the ClientID and ClientSecret.

This worked for me with M5, but suddenly stopped working once I upgraded to 3.3.0M6.

Does this trace helps?

2022-06-06 22:31:37.938 [DEBUG] [mo.internal.handler.ApiBridgeHandler] - Initializing Netatmo API bridge handler.
2022-06-06 22:31:37.939 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'netatmo:account:7814b6f340' changed from INITIALIZING to UNKNOWN
2022-06-06 22:31:37.939 [DEBUG] [mo.internal.handler.ApiBridgeHandler] - Connecting to Netatmo API.
2022-06-06 22:31:38.174 [TRACE] [mo.internal.handler.ApiBridgeHandler] - executeUri POST  https://api.netatmo.com/oauth2/token 
2022-06-06 22:31:38.264 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'netatmo:account:7814b6f340' changed from UNKNOWN to OFFLINE (COMMUNICATION_ERROR): Unexpected error deserializing '{"error":"invalid_grant"}'
2022-06-06 22:31:41.740 [DEBUG] [mo.internal.handler.ApiBridgeHandler] - Shutting down Netatmo API bridge handler.
2022-06-06 22:31:41.740 [DEBUG] [mo.internal.handler.ApiBridgeHandler] - Initializing Netatmo API bridge handler.
2022-06-06 22:31:41.740 [DEBUG] [mo.internal.handler.ApiBridgeHandler] - Connecting to Netatmo API.

I just tested and I can confirm it is no more working, same result as @stefan13 .
An issue has to be created in Git and a fast fix has to be provided (before 3.3 is released).

@glhopital : I do not see this log at binding startup which is probably a good sign that the servlet is not started.

One question: is the servlet systematically started ?

The GrantServlet is created by the ApiBridgeHandler as soon as clientSecret and clientID are provided in the account counfiguration.

    public void openConnection(@Nullable String code, @Nullable String redirectUri) {
        ApiHandlerConfiguration configuration = getConfiguration();
        ConfigurationLevel level = configuration.check();
        switch (level) {
            case EMPTY_CLIENT_ID:
            case EMPTY_CLIENT_SECRET:
                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, level.message);
                break;
            case REFRESH_TOKEN_NEEDED:
                if (code == null || redirectUri == null) {
                    GrantServlet servlet = new GrantServlet(this, httpService);
                    servlet.startListening();
                    this.grantServlet = servlet;
                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, level.message);
                    break;
                } // else we can proceed to get the token refresh

@stefan13 : can you please file a bug report in github so we can study this. I’ll not be that available in the next coming days but should be able to find some time before end of the week.

If you expect to have the connect servlet, can you try removing the refreshToken line ?

So the servlet and the page is not available if a refresh token is already setup?
That explains why the page is falling for both of us.
Shouldn’t this psge be available everytime, in case you would like to restart the process? Or do you consider that the refresh token must be cleared first in the config to trigger the start of the servlet?
That could make sense and there might be finally no bug. But something to mention in the documentation because not very intuitive.

The reason I added the RefreshToken was, as the binding failed after upgrading M5 to M6.

I just removed the refreshToken for testing an the link

http://<OH3-IPAddress>:8192/netatmo/connect/<Client_ID>

is working now.

All Things are ONLINE again :slight_smile: