Netatmo: Another problem with the webhook servlet

I recently upgraded to OH 2.3.0 but this issue already existed before. I tried to clear the cache and restart the OH server but the issue persist so I hope that someone more knowledgeable will be able to direct me to a solution.

It seems that the Netatmo binding is trying to create the webhook servlet over and over. I’m repeatedly getting this error in the events.log

2018-06-01 13:09:41.479 [ERROR] [tatmo.internal.WelcomeWebHookServlet] - Could not start Netatmo Webhook servlet: servlet already registered with a different alias
javax.servlet.ServletException: servlet already registered with a different alias
	at org.ops4j.pax.web.service.spi.model.ServerModel.addServletModel(ServerModel.java:119) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:241) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:221) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:205) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerServlet(HttpServiceProxy.java:65) ~[?:?]
	at org.openhab.binding.netatmo.internal.WelcomeWebHookServlet.activate(WelcomeWebHookServlet.java:60) ~[?:?]
	at org.openhab.binding.netatmo.handler.NetatmoBridgeHandler.connectionSucceed(NetatmoBridgeHandler.java:110) ~[?:?]
	at org.openhab.binding.netatmo.handler.NetatmoBridgeHandler.lambda$0(NetatmoBridgeHandler.java:136) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
	at java.lang.Thread.run(Unknown Source) [?:?]

Everything else, except the Live snapshot pic that never update seems to be working.

What value did you set for the configuration setting relative to the webhook ?

Can you enable DEBUG logs for the binding and then search for “Started Netatmo Webhook servlet at …”.

The webhook address is defined in the Paper UI as the public address of the http tunnel for port 8080 of the openhab server local host.

So in my case it’s typed as http://XXXXX.ngrok.io in the paper UI and the devnetatmo application. Please note that with ngrok I’m able to replay the events and I see in their lof that all events gets a 200 reply and they appear in the openhab events log.

I cleared the log, restarted openhab from the console, set the log level to debug by issuing the command:
log:set DEBUG org.openhab.binding.netatmo

The resulting log file is quite large, too long to include here. What would be the best way to send it to you?

You have only one netatmo bridge thing ?
It looks lke the service is activated several times in your case and that is strange.

I only have a single bridge.

It used to be defined through a “thing” file but this binding instance was erased and the file deleted. Do you think that some residues were left despite that and also clearing the cache and temp directories?

Check what bridge things you have in Paper UI.

I just did, sorry it took me so long.

I don’t see an attempt to register another bridge, but perhaps I’m missing something?

2018-06-02 16:44:19.852 [DEBUG] [org.openhab.binding.netatmo         ] - BundleEvent STARTING - org.openhab.binding.netatmo
2018-06-02 16:44:19.866 [DEBUG] [org.openhab.binding.netatmo         ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory, org.openhab.binding.netatmo.internal.NetatmoHandlerFactory}={service.id=281, service.bundleid=230, service.scope=bundle, component.name=org.openhab.binding.netatmo.internal.NetatmoHandlerFactory, component.id=181} - org.openhab.binding.netatmo
2018-06-02 16:44:19.903 [DEBUG] [org.openhab.binding.netatmo         ] - BundleEvent STARTED - org.openhab.binding.netatmo
2018-06-02 16:44:32.429 [DEBUG] [org.openhab.binding.netatmo         ] - ServiceEvent REGISTERED - {javax.servlet.http.HttpServlet}={service.id=314, service.bundleid=230, service.scope=singleton} - org.openhab.binding.netatmo
2018-06-02 16:44:32.523 [DEBUG] [org.openhab.binding.netatmo         ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=315, service.bundleid=230, service.scope=singleton} - org.openhab.binding.netatmo
2018-06-02 16:44:32.677 [DEBUG] [netatmo.handler.NetatmoBridgeHandler] - Initializing Netatmo API bridge handler.
2018-06-02 16:44:34.687 [DEBUG] [netatmo.handler.NetatmoBridgeHandler] - Initializing API Connection and scheduling token refresh every 5400s
2018-06-02 16:44:35.266 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-06-02 16:44:36.542 [DEBUG] [org.openhab.binding.netatmo         ] - ServiceEvent REGISTERED - {javax.servlet.ServletContext}={osgi.web.version=2.3.0, osgi.web.contextpath=/, service.id=354, osgi.web.symbolicname=org.openhab.binding.netatmo, service.bundleid=230, service.scope=singleton, osgi.web.contextname=default} - org.openhab.binding.netatmo
2018-06-02 16:44:36.546 [DEBUG] [tatmo.internal.WelcomeWebHookServlet] - Started Netatmo Webhook servlet at /netatmo/9eb67ddb/camera
2018-06-02 16:44:36.547 [DEBUG] [netatmo.handler.NetatmoBridgeHandler] - Setting up Netatmo Welcome WebHook
2018-06-02 16:44:37.127 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Initializing class org.openhab.binding.netatmo.internal.station.NAMainHandler with id '70:ee:50:05:ca:d4'
2018-06-02 16:44:37.144 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:9e48654d318e4d2792ff5a89e53070eb:welcomePersonAtHome
2018-06-02 16:44:37.146 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Scheduling update channel thread in 30 s
2018-06-02 16:44:37.154 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:9e48654d318e4d2792ff5a89e53070eb:welcomePersonLastSeen
2018-06-02 16:44:37.389 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:9e48654d318e4d2792ff5a89e53070eb:welcomePersonLastEventUrl
2018-06-02 16:44:37.394 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:9e48654d318e4d2792ff5a89e53070eb:welcomePersonLastEvent
2018-06-02 16:44:37.622 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:c1cef9e672574186b876ca96c57041ef:welcomePersonLastSeen
2018-06-02 16:44:37.625 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:c1cef9e672574186b876ca96c57041ef:welcomePersonAtHome
2018-06-02 16:44:37.627 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:c1cef9e672574186b876ca96c57041ef:welcomePersonLastEventUrl
2018-06-02 16:44:37.628 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAWelcomePerson:9eb67ddb:c1cef9e672574186b876ca96c57041ef:welcomePersonLastEvent
2018-06-02 16:44:37.762 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Initializing class org.openhab.binding.netatmo.internal.welcome.NAWelcomeHomeHandler with id '56340dd765d1c469418b4596'
2018-06-02 16:44:37.765 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Scheduling update channel thread in 30 s
2018-06-02 16:44:37.941 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAModule1:9eb67ddb:0200000604a2:Temperature
2018-06-02 16:44:37.944 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAModule1:9eb67ddb:0200000604a2:TempTrend
2018-06-02 16:44:37.947 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAModule1:9eb67ddb:0200000604a2:Humidity
2018-06-02 16:44:37.968 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAModule1:9eb67ddb:0200000604a2:LowBattery
2018-06-02 16:44:38.019 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAModule1:9eb67ddb:0200000604a2:BatteryVP
2018-06-02 16:44:38.039 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAModule1:9eb67ddb:0200000604a2:RfStatus
2018-06-02 16:44:38.151 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAMain:9eb67ddb:70ee5005cad4:Co2
2018-06-02 16:44:38.153 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Data aged of 601 s
2018-06-02 16:44:38.154 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Trying to update channels on device 70:ee:50:05:ca:d4
2018-06-02 16:44:38.172 [DEBUG] [.handler.AbstractNetatmoThingHandler] - Refreshing netatmo:NAMain:9eb67ddb:70ee5005cad4:Temperature
2018-06-02 16:44:38.173 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Data aged of 601 s
2018-06-02 16:44:38.174 [DEBUG] [netatmo.handler.NetatmoDeviceHandler] - Trying to update channels on device 70:ee:50:05:ca:d4

The webhook seems to connect with the correct directory “9eb67ddb”, I don’t see an attempt to create another one and the (useless) error message doesn’t say which name is supposedly already registered.

2018-06-04 04:56:01.235 [DEBUG] [netatmo.handler.NetatmoBridgeHandler] - Initializing API Connection and scheduling token refresh every 5400s
2018-06-04 04:56:02.385 [ERROR] [tatmo.internal.WelcomeWebHookServlet] - Could not start Netatmo Webhook servlet: servlet already registered with a different alias
javax.servlet.ServletException: servlet already registered with a different alias
	at org.ops4j.pax.web.service.spi.model.ServerModel.addServletModel(ServerModel.java:119) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:241) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:221) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceStarted.registerServlet(HttpServiceStarted.java:205) ~[?:?]
	at org.ops4j.pax.web.service.internal.HttpServiceProxy.registerServlet(HttpServiceProxy.java:65) ~[?:?]
	at org.openhab.binding.netatmo.internal.WelcomeWebHookServlet.activate(WelcomeWebHookServlet.java:60) ~[?:?]
	at org.openhab.binding.netatmo.handler.NetatmoBridgeHandler.connectionSucceed(NetatmoBridgeHandler.java:110) ~[?:?]
	at org.openhab.binding.netatmo.handler.NetatmoBridgeHandler.lambda$0(NetatmoBridgeHandler.java:136) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
	at java.lang.Thread.run(Unknown Source) [?:?]
2018-06-04 04:56:02.406 [DEBUG] [netatmo.handler.NetatmoBridgeHandler] - Setting up Netatmo Welcome WebHook

Any help would be greatly appreciated.

You got the error 2 days after the initial OH startup ?
Why your bridge thing is initializing again ?
Don’t you see any logs about disposing the thing just before the second initializing ?

No I didn’t. The first error popped up within the first hour. I just grabbed the last one because i was too lazy to scroll up in the log.

Anyway, despite the errors the binding seems to work correctly, except for the Live Snapshot image, but that’s something which never worked for me in any case.

I’m having the same problem… Any update on this?

Likewise, same issue and I keep getting my webhook banned from dev netatmo site

Anyone confirm a fix?

On the update I’m working on for OH3 the auto subscription of the webhook will evolve

Thanks for the update!

Am I right in thinking the webhook for OH2 is broken then or is it just my setup?

Really frustrating to not get push notifications (kinda defeats the object without this feature e.g. Netatmo presence

From my understanding, the webhook works/should work but it is delicate and tedious to work with because of Netatmo policy that bans it for 24h as soon as he is not responded 10 times in a row. So, if your OH server stops for too long, it does not respond.
In version 2 of the binding, when an url is provided, the binding pushes the webhook URL at start and removes it at stop, so if for any reason your OH instance is not properly close, it will ban.

While reworking the binding, I’m trying to find a better way to handle this. I think I’m going to remove autosubscription of the webhook, so you get back control over it.

Sounds great thanks for the explanation.

Am I right in thinking that the version 2 binding works as follows?

  1. Set a DDNS up for openhab install so server is accessible from internet

  2. Define the address and port in the webhook url field in the netatmo api thing

  3. Enter the exact same url in the dev.netatmo webhook and url redirect fields

If so I’ve done all this and doesn’t work. I had to use port 443 with port forwarding to 8080 as netatmo don’t accept any other ports

You can set a DDNS or directly you IP address.
Regarding ports, Netatmo should accept 80, 88, 443 and 9443.

In the Netatmo binding, you should define something like this : https://my.public.ip:choosen_port
Then the binging declares https://my.public.ip:choosen_port/netatmo itself to netatmo via the API, you’ve got nothing to do yourself. BUT : the weird thing is that in Netatmo console, you do not see it (I don’t know why), reason why I think it should be better to let the user do it himself.

Getting live publications from Netatmo is really not an easy thing.
On my side, in OH2.5 production I ended up having a php script on my public cloud server as webhook that push the json notification to openhabcloud on a dedicated item. Uggly.

Ah thanks for the detailed info.

I think I will try something similar to you then as php is my code of choice anyway.

I assume you simply hosted a php file on a webserver then put the script url in the dev netatmo site webhook and redirect fields?

I understand how to use cURL and post methods in php fine, but how did you receive it in openhab? Very curious if you can share a few tips?

Thanks

Matt

Ok so I built a basic JSON php script but although the webhook is registered at the dev.netatmo site, I am only able to retrieve this each time from the JSON.

Am I missing something to retrieve the last event notification?

stdClass Object
(
[user_id] => 5c27xxxxxxxxxxxxxxxxxb5caa
[user] => stdClass Object
(
[id] => 5c27xxxxxxxxxxxxxxxxxb5caa
[email] => myemail@email.com
)

[push_type] => webhook_activation

)

Do not use this in parallel with webhook handling in the Netatmo binding. You should receive full notification messages as stated in the netatmo dev documentation