Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[netatmo] Adding Webhook event support for Doorbell #12972

Merged
merged 5 commits into from
Jun 24, 2022

Conversation

clinique
Copy link
Contributor

@clinique clinique commented Jun 20, 2022

Resolves #12952
Signed-off-by: clinique gael@lhopital.org

Signed-off-by: clinique <gael@lhopital.org>
@clinique clinique self-assigned this Jun 20, 2022
@clinique clinique added the bug An unexpected problem or unintended behavior of an add-on label Jun 20, 2022
Signed-off-by: clinique <gael@lhopital.org>
@lolodomo
Copy link
Contributor

Maybe you can build a jar so that @HaKuNaCH can test and confirm it is working well with your change?

@clinique
Copy link
Contributor Author

@HaKuNaCH : you'll find the jar file here

@jlaur
Copy link
Contributor

jlaur commented Jun 20, 2022

@clinique - FYI, please use "Resolves #xxxxx" or "Fixes #xxxxx" next time to have issue automatically linked (and closed on merge). "Solves Issue #xxxxx" or "Solves #xxxxx" will not work.

@HaKuNaCH
Copy link

HaKuNaCH commented Jun 20, 2022

Edit: 20.06.2022 / 18:25 CEST
I installed the jar org.openhab.binding.netatmo-3.3.0-SNAPSHOT-12952.jar and made some quick tests.

2022-06-20 18:24:10.415 [WARN ] [org.eclipse.jetty.server.HttpChannel] - /netatmo/webhook/629db037f6a44d197f5bb32b
com.google.gson.JsonParseException: Error deserializing : NDB-rtc
	at org.openhab.binding.netatmo.internal.deserialization.NAPushTypeDeserializer.deserialize(NAPushTypeDeserializer.java:49) ~[?:?]
	at org.openhab.binding.netatmo.internal.deserialization.NAPushTypeDeserializer.deserialize(NAPushTypeDeserializer.java:1) ~[?:?]
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[?:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) ~[?:?]
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:963) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:928) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:877) ~[?:?]
	at com.google.gson.Gson.fromJson(Gson.java:848) ~[?:?]
	at org.openhab.binding.netatmo.internal.deserialization.NADeserializer.deserialize(NADeserializer.java:73) ~[?:?]
	at org.openhab.binding.netatmo.internal.servlet.WebhookServlet.processEvent(WebhookServlet.java:106) ~[?:?]
	at org.openhab.binding.netatmo.internal.servlet.WebhookServlet.service(WebhookServlet.java:99) ~[?:?]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[bundleFile:3.1.0]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799) ~[?:?]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550) ~[?:?]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:74) ~[?:?]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600) ~[?:?]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440) ~[bundleFile:9.4.46.v20220331]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:294) ~[?:?]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501) ~[?:?]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[bundleFile:9.4.46.v20220331]
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:90) ~[?:?]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.Server.handle(Server.java:516) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732) ~[bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:555) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:410) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:164) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) [bundleFile:9.4.46.v20220331]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) [bundleFile:9.4.46.v20220331]
	at java.lang.Thread.run(Thread.java:829) [?:?]

@lolodomo
Copy link
Contributor

Apparently event type RTC is missing.

@clinique
Copy link
Contributor Author

Does anyone has a clue of what rtc means ? I can add it but would prefer to get this precious information

@HaKuNaCH
Copy link

Now I had more time to test. These are (all) the different events from the doorbell I've seen today.

Person detected:

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","snapshot_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","snapshot_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","event_type":"human","camera_id":"xx:xx:xx:xx:xx:xx","device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","home_name":"Mein Haus","event_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","subevent_id":"xxxxxxxxxx-xxxx-xxxx-xxxxxx-xxxxxxxxxxxxx","message":"Person erfasst","push_type":"NDB-human"}

Doorbell button pressed:

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","session_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","data":{"type":"offer"},"device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","push_type":"NDB-rtc"}

Incoming call, comes always after "push_type":"NDB-rtc":

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","event_type":"incoming_call","device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","home_name":"Mein Haus","camera_id":"xx:xx:xx:xx:xx:xx","event_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","subevent_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","session_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","push_type":"NDB-incoming_call"}

Missed call, when not accepted the incoming call via app:

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","event_type":"missed_call","device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","home_name":"Mein Haus","camera_id":"xx:xx:xx:xx:xx:xx","event_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","subevent_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","session_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","push_type":"NDB-missed_call"}

@lolodomo
Copy link
Contributor

lolodomo commented Jun 21, 2022

c in RTC could be for call.
r for ringing?

@clinique
Copy link
Contributor Author

c in RTC could be for call. r for ringing?

According to dev.netatmo.com (where this event is not related to doorbell btw) it seems to just be "Button pressed" :)

Enhancing NAPushType deserialization

Signed-off-by: clinique <gael@lhopital.org>
@clinique
Copy link
Contributor Author

Now I had more time to test. These are (all) the different events from the doorbell I've seen today.

Person detected:

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","snapshot_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","snapshot_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","event_type":"human","camera_id":"xx:xx:xx:xx:xx:xx","device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","home_name":"Mein Haus","event_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","subevent_id":"xxxxxxxxxx-xxxx-xxxx-xxxxxx-xxxxxxxxxxxxx","message":"Person erfasst","push_type":"NDB-human"}

Doorbell button pressed:

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","session_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","data":{"type":"offer"},"device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","push_type":"NDB-rtc"}

Incoming call, comes always after "push_type":"NDB-rtc":

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","event_type":"incoming_call","device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","home_name":"Mein Haus","camera_id":"xx:xx:xx:xx:xx:xx","event_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","subevent_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","session_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","push_type":"NDB-incoming_call"}

Missed call, when not accepted the incoming call via app:

{"user_id":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","event_type":"missed_call","device_id":"xx:xx:xx:xx:xx:xx","home_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","home_name":"Mein Haus","camera_id":"xx:xx:xx:xx:xx:xx","event_id":"xxxxxxxxxxxxxxxxxxxxxxxxxx","subevent_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","session_id":"xxxxxxxxx-xxxx-xxxx-xxxxx-xxxxxxxxxxxxxx","push_type":"NDB-missed_call"}

I have tested the for message types you were kind enough to list. Everything seems fine. I have delivered you another test version on the shared folder.

Signed-off-by: clinique <gael@lhopital.org>
@HaKuNaCH
Copy link

HaKuNaCH commented Jun 21, 2022

Thanks for the new version.
I have tested several cases.
Some items go back to empty after some webhook events -> when the attribute is not delivered by the webhook JSON.
I'm not sure if this is wanted or only the new states should update the items and leave the not delivered untouched.
Also with the automatic refresh, the states get "overwritten". But at least all the events are working now !

Movement detected
Webhook content in openhab.log

2022-06-21 17:35:40.119 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61ee54e8exxxxx645a0962a1","snapshot_id":"62b1e54bcaxxxxxff27b4e65","snapshot_key":"1af627f7b39c91aa741f9069721xxxxxxxxxxd50afa49464f1548618378c858b","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e54bcaxxxxxff27b4e651af627f7b39c91aa741f9069721xxxxxxxxxxd50afa49464f1548618378c858b","vignette_id":"62b1e54bca00yyyyyyyyye66","vignette_key":"3dfe5780eb10dexxxxxxd96835c82d81830288eefa2b9477cbyyyyyy47768994","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e54bca00yyyyyyyyye663dfe5780eb10dexxxxxxd96835c82d81830288eefa2b9477cbyyyyyy47768994","event_type":"human","camera_id":"70:xx:yy:zz:aa:7a","device_id":"70:xx:yy:zz:aa:7a","home_id":"61f1650exxxxxb111006b4d7","home_name":"Mein Haus","event_id":"62b1e54bca00257ff27b4e64","subevent_id":"8b205316-62c4-4cca-a3e4-a6fbe53e82ea","message":"Person erfasst","push_type":"NDB-human"}

Channel-items updated:

2022-06-21 17:35:40.121 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from OUTDOOR to HUMAN
2022-06-21 17:35:40.121 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellMessage' changed from  to Person erfasst
2022-06-21 17:35:40.375 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshot' changed from UNDEF to raw type (image/jpeg): 309857 bytes
2022-06-21 17:35:40.376 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e54bcaxxxxxff27b4e651af627f7b39c91aa741f9069721xxxxxxxxxxd50afa49464f1548618378c858b
2022-06-21 17:35:40.391 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignette' changed from UNDEF to raw type (image/jpeg): 68567 bytes
2022-06-21 17:35:40.391 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e54bca00yyyyyyyyye663dfe5780eb10dexxxxxxd96835c82d81830288eefa2b9477cbyyyyyy47768994
2022-06-21 17:35:40.391 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T11:50:51.000+0200 to 2022-06-21T17:35:40.119593+0200

Until the next event, the following items get updated:

022-06-21 17:36:51.139 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLivesnapshot' changed from raw type (image/jpeg): 185191 bytes to raw type (image/jpeg): 188065 bytes
2022-06-21 17:36:51.140 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSignalValue' changed from 37 to 36
2022-06-21 17:36:51.140 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from HUMAN to OUTDOOR
2022-06-21 17:36:51.140 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:35:40.119593+0200 to 2022-06-21T17:35:27.000+0200
2022-06-21 17:36:51.140 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellMessage' changed from Person erfasst to 
2022-06-21 17:36:51.146 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshot' changed from raw type (image/jpeg): 309857 bytes to UNDEF
2022-06-21 17:36:51.146 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e54bcaxxxxxff27b4e651af627f7b39c91aa741f9069721xxxxxxxxxxd50afa49464f1548618378c858b to NULL
2022-06-21 17:36:51.147 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignette' changed from raw type (image/jpeg): 68567 bytes to UNDEF
2022-06-21 17:36:51.147 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e54bca00yyyyyyyyye663dfe5780eb10dexxxxxxd96835c82d81830288eefa2b9477cbyyyyyy47768994 to NULL
2022-06-21 17:36:51.148 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastEventTimestamp' changed from 2022-06-21T11:50:51.000+0200 to 2022-06-21T17:35:27.000+0200
2022-06-21 17:36:51.148 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastVideoLocalURL' changed from http://10.0.1.36/835440bcecff7xxxxxx4899906a729f4/vod/0865c789-1c66-xxxx-yyyy-10f923115e7a/index.m3u8 to http://10.0.1.36/835440bcecff7xxxxxx4899906a729f4/vod/2c3abcbb-xxxx-yyyy-zzzz-8e3a3d55331c/index.m3u8
2022-06-21 17:36:51.148 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastVideoVpnURL' changed from https://prodvpn-eu-13.netatmo.net/restricted/10.255.85.225/835440bcecff7xxxxxx4899906a729f4/MTY1NTgzODAwMDxxxxxx7FIj7vzzzzXeTqH-Ha1qRCw,,/vod/0865c789-1c66-xxxx-yyyy-10f923115e7a/index.m3u8 to https://prodvpn-eu-13.netatmo.net/restricted/10.255.85.225/835440bcecff7xxxxxx4899906a729f4/MTY1NTgzODAwMDxxxxxx7FIj7vzzzzXeTqH-Ha1qRCw,,/vod/2c3abcbb-xxxx-yyyy-zzzz-8e3a3d55331c/index.m3u8

Movement detected / incoming call / unanswered
Webhook content in openhab.log

2022-06-21 17:37:41.571 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61ee54e8exxxxx645a0962a1","snapshot_id":"62b1e5c58e2aaaaa8f70b84b","snapshot_key":"ec7d75f54ec350xxxxx04145910165e33c278zzzzzzf87ace8bb2480c5a75697","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e5c58e2aaaaa8f70b84bec7d75f54ec350xxxxx04145910165e33c278zzzzzzf87ace8bb2480c5a75697","vignette_id":"62b1e5cxxxxxx3288f70b84c","vignette_key":"66f67e045240e9bc6e0d4e1cXXXXXXe91ddcd829e412e80592be0e9525519ad4","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e5cxxxxxx3288f70b84c66f67e045240e9bc6e0d4e1cXXXXXXe91ddcd829e412e80592be0e9525519ad4","event_type":"human","camera_id":"70:xx:yy:zz:aa:7a","device_id":"70:xx:yy:zz:aa:7a","home_id":"61f1650exxxxxb111006b4d7","home_name":"Mein Haus","event_id":"62bxxxxxxe20c3288f70b84a","subevent_id":"a81121c0-d53a-xxxx-yyyy-e73daba310d6","message":"Person erfasst","push_type":"NDB-human"}

Items updated:

2022-06-21 17:37:41.572 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from OUTDOOR to HUMAN
2022-06-21 17:37:41.572 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellMessage' changed from  to Person erfasst
2022-06-21 17:37:41.598 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e5c58e2aaaaa8f70b84bec7d75f54ec350xxxxx04145910165e33c278zzzzzzf87ace8bb2480c5a75697
2022-06-21 17:37:41.622 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e5cxxxxxx3288f70b84c66f67e045240e9bc6e0d4e1cXXXXXXe91ddcd829e412e80592be0e9525519ad4
2022-06-21 17:37:41.623 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:35:27.000+0200 to 2022-06-21T17:37:41.571767+0200

Incoming call:
Webhook content in openhab.log

2022-06-21 17:37:44.859 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61ee54e8exxxxx645a0962a1","session_id":"b5axxxxx-xxxx-xxxx-97a8-5d2fa6e33c73","data":{"type":"offer"},"device_id":"70:xx:yy:zz:aa:7a","home_id":"61f1650exxxxxb111006b4d7","push_type":"NDB-rtc"}

Items updated:

2022-06-21 17:37:44.860 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from HUMAN to RTC
2022-06-21 17:37:44.861 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellMessage' changed from Person erfasst to 
2022-06-21 17:37:44.861 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e5c58e2aaaaa8f70b84bec7d75f54ec350xxxxx04145910165e33c278zzzzzzf87ace8bb2480c5a75697 to NULL
2022-06-21 17:37:44.861 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e5cxxxxxx3288f70b84c66f67e045240e9bc6e0d4e1cXXXXXXe91ddcd829e412e80592be0e9525519ad4 to NULL
2022-06-21 17:37:44.862 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:37:41.571767+0200 to 2022-06-21T17:37:44.859770+0200

Webhook content in openhab.log

2022-06-21 17:37:46.726 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61ee54e8exxxxx645a0962a1","event_type":"incoming_call","device_id":"70:xx:yy:zz:aa:7a","home_id":"61f1650exxxxxb111006b4d7","home_name":"Mein Haus","camera_id":"70:xx:yy:zz:aa:7a","event_id":"62bxxxxxxe20c3288f70b84a","subevent_id":"e0cb9000-yyyy-xxxx-zzzz-7e9f3774e858","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e5ca6558ac74d002ba3386765570xxxxxxabbacae754018cb53zzzzza29f5e363759ea10d1753ad3673f","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e5ca6558ac74d002ba3479d7089a1737e1xxxxxx0966fd0ee905d14beee8d43zzzzzzz0d50476f42f8bb","session_id":"b5axxxxx-xxxx-xxxx-97a8-5d2fa6e33c73","push_type":"NDB-incoming_call"}

Items updated:

2022-06-21 17:37:46.727 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from RTC to INCOMING_CALL
2022-06-21 17:37:46.749 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e5ca6558ac74d002ba3386765570xxxxxxabbacae754018cb53zzzzza29f5e363759ea10d1753ad3673f
2022-06-21 17:37:46.772 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e5ca6558ac74d002ba3479d7089a1737e1xxxxxx0966fd0ee905d14beee8d43zzzzzzz0d50476f42f8bb
2022-06-21 17:37:46.773 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:37:44.859770+0200 to 2022-06-21T17:37:46.726747+0200

Webhook content in openhab.log

2022-06-21 17:38:26.509 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61ee54e8exxxxx645a0962a1","event_type":"missed_call","device_id":"70:xx:yy:zz:aa:7a","home_id":"61f1650exxxxxb111006b4d7","home_name":"Mein Haus","camera_id":"70:xx:yy:zz:aa:7a","event_id":"62bxxxxxxe20c3288f70b84a","subevent_id":"e0cb9000-yyyy-xxxx-zzzz-7e9f3774e858","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e5ca6558ac74d002ba3386765570xxxxxxabbacae754018cb53zzzzza29f5e363759ea10d1753ad3673f","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e5ca6558ac74d002ba3479d7089a1737e1xxxxxx0966fd0ee905d14beee8d43zzzzzzz0d50476f42f8bb","session_id":"b5axxxxx-xxxx-xxxx-97a8-5d2fa6e33c73","push_type":"NDB-missed_call"}

Items updated:

2022-06-21 17:38:26.511 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from INCOMING_CALL to MISSED_CALL
2022-06-21 17:38:26.546 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshot' changed from UNDEF to raw type (image/jpeg): 131514 bytes
2022-06-21 17:38:26.565 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignette' changed from UNDEF to raw type (image/jpeg): 12645 bytes
2022-06-21 17:38:26.565 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:37:46.726747+0200 to 2022-06-21T17:38:26.510075+0200

Incoming call / answered (webhook from netatmo does not send "answered-call")
Webhook content in openhab.log

2022-06-21 17:39:49.456 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61ee54e8exxxxx645a0962a1","session_id":"fa490c27-xxxx-yyyy-qqqq-cbbe31dc83d2","data":{"type":"offer"},"device_id":"70:xx:yy:zz:aa:7a","home_id":"61f1650exxxxxb111006b4d7","push_type":"NDB-rtc"}

Items updated:

2022-06-21 17:39:49.458 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from MISSED_CALL to RTC
2022-06-21 17:39:49.461 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshot' changed from raw type (image/jpeg): 131514 bytes to UNDEF
2022-06-21 17:39:49.461 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e5ca6558ac74d002ba3386765570xxxxxxabbacae754018cb53zzzzza29f5e363759ea10d1753ad3673f to NULL
2022-06-21 17:39:49.461 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignette' changed from raw type (image/jpeg): 12645 bytes to UNDEF
2022-06-21 17:39:49.461 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e5ca6558ac74d002ba3479d7089a1737e1xxxxxx0966fd0ee905d14beee8d43zzzzzzz0d50476f42f8bb to NULL
2022-06-21 17:39:49.461 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:38:26.510075+0200 to 2022-06-21T17:39:49.456507+0200

Webhook content in openhab.log

2022-06-21 17:39:53.795 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61ee54e8exxxxx645a0962a1","event_type":"incoming_call","device_id":"70:xx:yy:zz:aa:7a","home_id":"61f1650exxxxxb111006b4d7","home_name":"Mein Haus","camera_id":"70:xx:yy:zz:aa:7a","event_id":"6xxxx647zzzzzb73fd4fba56","subevent_id":"b3cdad1f-xxxx-yyyy-zzzz-df05bb5c239d","snapshot_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e64793b7cb73fd4fbaxxxxx1a76adfeaf41e5c3c3ezzzzz9d3a26e6647138a6a804207ce2dd384488cd6","vignette_url":"https:\/\/netatmocameraimage.blob.core.windows.net\/production\/62b1e64793b7cb73fd4fba583zzzzzb60b3fc8ca8ffe732cfxxxxxa67f70f5f1491e68a33d82c45bef847692","session_id":"fa490c27-xxxx-yyyy-qqqq-cbbe31dc83d2","push_type":"NDB-incoming_call"}

Items updated:

2022-06-21 17:39:53.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLivesnapshot' changed from raw type (image/jpeg): 188065 bytes to raw type (image/jpeg): 146541 bytes
2022-06-21 17:39:53.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSignalValue' changed from 36 to 38
2022-06-21 17:39:53.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from RTC to OUTDOOR
2022-06-21 17:39:53.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:39:49.456507+0200 to 2022-06-21T17:37:37.000+0200
2022-06-21 17:39:53.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastEventTimestamp' changed from 2022-06-21T17:35:27.000+0200 to 2022-06-21T17:37:37.000+0200
2022-06-21 17:39:53.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastVideoLocalURL' changed from http://10.0.1.36/835440bcecff7xxxxxx4899906a729f4/vod/2c3abcbb-xxxx-yyyy-zzzz-8e3a3d55331c/index.m3u8 to http://10.0.1.36/835440bcecff7xxxxxx4899906a729f4/vod/fe49e901-xxxx-zzzz-b14b-5ee9f488a012/index.m3u8
2022-06-21 17:39:53.601 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastVideoVpnURL' changed from https://prodvpn-eu-13.netatmo.net/restricted/10.255.85.225/835440bcecff7xxxxxx4899906a729f4/MTY1NTgzODAwMDxxxxxx7FIj7vzzzzXeTqH-Ha1qRCw,,/vod/2c3abcbb-xxxx-yyyy-zzzz-8e3a3d55331c/index.m3u8 to https://prodvpn-eu-13.netatmo.net/restricted/10.255.85.225/835440bcecff7xxxxxx4899906a729f4/MTY1NTgzODAwMDxxxxxx7FIj7vzzzzXeTqH-Ha1qRCw,,/vod/fe49e901-xxxx-zzzz-b14b-5ee9f488a012/index.m3u8
2022-06-21 17:39:53.796 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from OUTDOOR to INCOMING_CALL
2022-06-21 17:39:53.841 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshot' changed from UNDEF to raw type (image/jpeg): 146541 bytes
2022-06-21 17:39:53.841 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e64793b7cb73fd4fbaxxxxx1a76adfeaf41e5c3c3ezzzzz9d3a26e6647138a6a804207ce2dd384488cd6
2022-06-21 17:39:53.860 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignette' changed from UNDEF to raw type (image/jpeg): 13817 bytes
2022-06-21 17:39:53.860 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from NULL to https://netatmocameraimage.blob.core.windows.net/production/62b1e64793b7cb73fd4fba583zzzzzb60b3fc8ca8ffe732cfxxxxxa67f70f5f1491e68a33d82c45bef847692
2022-06-21 17:39:53.860 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:37:37.000+0200 to 2022-06-21T17:39:53.795644+0200

afterwards without any action items updated:

2022-06-21 17:42:55.677 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLivesnapshot' changed from raw type (image/jpeg): 146541 bytes to raw type (image/jpeg): 185125 bytes
2022-06-21 17:42:55.678 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSignalValue' changed from 38 to 37
2022-06-21 17:42:55.678 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventType' changed from INCOMING_CALL to OUTDOOR
2022-06-21 17:42:55.678 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellSubEventTimestamp' changed from 2022-06-21T17:39:53.795644+0200 to 2022-06-21T17:39:49.000+0200
2022-06-21 17:42:55.681 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshot' changed from raw type (image/jpeg): 146541 bytes to UNDEF
2022-06-21 17:42:55.682 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellEventSnapshotUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e64793b7cb73fd4fbaxxxxx1a76adfeaf41e5c3c3ezzzzz9d3a26e6647138a6a804207ce2dd384488cd6 to NULL
2022-06-21 17:42:55.682 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignette' changed from raw type (image/jpeg): 13817 bytes to UNDEF
2022-06-21 17:42:55.682 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellVignetteUrl' changed from https://netatmocameraimage.blob.core.windows.net/production/62b1e64793b7cb73fd4fba583zzzzzb60b3fc8ca8ffe732cfxxxxxa67f70f5f1491e68a33d82c45bef847692 to NULL
2022-06-21 17:42:55.682 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastEventTimestamp' changed from 2022-06-21T17:37:37.000+0200 to 2022-06-21T17:39:49.000+0200
2022-06-21 17:42:55.682 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastVideoLocalURL' changed from http://10.0.1.36/835440bcecff7xxxxxx4899906a729f4/vod/fe49e901-xxxx-zzzz-b14b-5ee9f488a012/index.m3u8 to http://10.0.1.36/835440bcecff7xxxxxx4899906a729f4/vod/5fc6b69d-zzzz-xxxx-yyyy-bec2f18fc051/index.m3u8
2022-06-21 17:42:55.682 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorbellLastVideoVpnURL' changed from https://prodvpn-eu-13.netatmo.net/restricted/10.255.85.225/835440bcecff7xxxxxx4899906a729f4/MTY1NTgzODAwMDxxxxxx7FIj7vzzzzXeTqH-Ha1qRCw,,/vod/fe49e901-xxxx-zzzz-b14b-5ee9f488a012/index.m3u8 to https://prodvpn-eu-13.netatmo.net/restricted/10.255.85.225/835440bcecff7xxxxxx4899906a729f4/MTY1NTgzODAwMDxxxxxx7FIj7vzzzzXeTqH-Ha1qRCw,,/vod/5fc6b69d-zzzz-xxxx-yyyy-bec2f18fc051/index.m3u8

@lolodomo
Copy link
Contributor

Some items go back to empty after some webhook events -> when the attribute is not delivered by the webhook JSON.
I'm not sure if this is wanted or only the new states should update the items and leave the not delivered untouched.
Also with the automatic refresh, the states get "overwritten". But at least all the events are working now !

@clinique : can you confirm it is expected?
@HaKuNaCH : can you explain a use case for which it makes no sense in your opinion?

@jlaur : you are welcome to finish this review in time for 3.3, I am sorry, I will not have much time before next weekend.

@clinique
Copy link
Contributor Author

clinique commented Jun 22, 2022

I confirm this is not as it should be : empty values should go to "NULL". Will post an update on this soon.
@HaKuNaCH : thanks for your detailed feedback. The faultly updated field seems to be "message" that may be empty depending upon the event type - but I also discovered a wrong update to UNDEF on the snapshot and vignette images.

Regarding automatic refresh, it can compete with delivery of web hook events because it will automatically request last available event for the device (that should be the same that last webhook triggered I guess - but not predictable). Would this mean that when a webhook is set, we should ignore events coming from automatic refresh ? I think this is too late in regard of 3.3 to make such a modification.

@clinique
Copy link
Contributor Author

@HaKuNaCH : updated version available in the folder.

Signed-off-by: clinique <gael@lhopital.org>
@HaKuNaCH
Copy link

HaKuNaCH commented Jun 22, 2022

@lolodomo
Some values are not present in automatic refresh and always empty. We should keep the last received values there and not overwrite them with NULL values.

@clinique
From my point of view, the following channels should not be updated during automatic refresh, because they are not delivered or empty:
sub-event#message
sub-event#snapshot
sub-event#snapshot-url
sub-event#event
sub-event#event-url

Currently I use the "HTTPListener Binding" for the netatmo webhook integration.
There I only update the received values from the webhook JSON or during polling:
-> https://community.openhab.org/t/webhook-new-very-simple-binding-for-listening-incomming-http-requests/123597/23
Binding download:
-> https://github.com/ptrbojko/openhab-addons/releases/tag/initial

Finally, I can test today evening because I have no access to my installation atm.

@HaKuNaCH
Copy link

HaKuNaCH commented Jun 22, 2022

@clinique
I tested your latest build and the channels gets now updated with NULL, except sub-event#message

Channels updated with NULL:
sub-event#snapshot
sub-event#snapshot-url
sub-event#event
sub-event#event-url

Channels with emtpy value:
sub-event#message

But as mentioned in my last comment, the binding should not overwrite existing values of all these channels with NULL.

@HaKuNaCH
Copy link

HaKuNaCH commented Jun 22, 2022

@HaKuNaCH : can you explain a use case for which it makes no sense in your opinion?

@clinique
If a event occurs and the sub-event#snapshot gets a new picture and a few milliseconds later the polling overwrites the channel with NULL the picture snapshot from the event is lost. If the channels are only overwritten with new content, you can display the snapshot in a sitemap/HABpanel or MainUI and you have always a picture of the last event.

@HaKuNaCH
Copy link

To be complete ...
There is also an additional webhook push which generates a warning.

2022-06-22 19:21:30.497 [DEBUG] [atmo.internal.servlet.WebhookServlet] - Event transmitted from restService : {"user_id":"61xxxxxxxxxxxe645a0962a1","user":{"id":"61xxxxxxxxxxxe645a0962a1","email":"name@domain.com"},"push_type":"webhook_activation"}
2022-06-22 19:21:30.500 [WARN ] [serialization.NAPushTypeDeserializer] - Unexpected syntax received for push_type field : webhook_activation
2022-06-22 19:21:30.501 [WARN ] [serialization.NAPushTypeDeserializer] - Unknown module or event type : webhook_activation, deserialized to 'UNKNOWN-unknown'

This happens on restart of OH or reenable the netatmo account thing.

@lolodomo
Copy link
Contributor

If a event occurs and the sub-event#snapshot gets a new picture and a few milliseconds later the polling overwrites the channel with NULL the picture snapshot from the event is lost. If the channels are only overwritten with new content, you can display the snapshot in a sitemap/HABpanel or MainUI and you have always a picture of the last event.

The question is to always get the snapshot associated to the last event. If the last event has no snapshot, you must not keep the snapshot of a previous event.

@HaKuNaCH
Copy link

But every event has a snapshot except "push_type":"NDB-rtc", but after that event there is always an "push_type":"NDB-incoming_call" afterwards within a few seconds.
And the pulling overwrites every 180s the 5 sub-event channels mentioned above, which is not correct from my point of view. If you won't change that I'll use proxy items for these channels and ignore NULL values.
I'm still happy with the binding, but I guess this will confusing other users as well, when the "real" last event values are overwritten by the pulling.

@lolodomo
Copy link
Contributor

Why the polling is not returning the last event pushed through webhook?

IMHO, we should have the same data as we get when clicking on the last event in the netatmo app. That event is not providing all data fields, it depends on event type.

With the welcome camera, not all events have a snapshot, for example when camera monitoring is enabled or disabled. In this case, we do not want to keep the snapshot of an outdated event that could one day before.

We have to find a general behaviour that will work for any Netatmo device, and not only something suitable for doorbell.

The combination of polling events and webhook events is a good question but I was expecting that the last event to be the same in the two cases.

@lolodomo
Copy link
Contributor

3.3 RC1 will be published in less than 2 days. We have to decide quickly what to do. I have the feeling it is better to have something working for webhook than nothing at all. If the current implementation does not satisfy everyone it could be discussed and enhanced after 3.3 is released.
WDYT?

@clinique
Copy link
Contributor Author

clinique commented Jun 22, 2022

3.3 RC1 will be published in less than 2 days. We have to decide quickly what to do. I have the feeling it is better to have something working for webhook than nothing at all. If the current implementation does not satisfy everyone it could be discussed and enhanced after 3.3 is released. WDYT?

Agree that this has to be thought. I would not agree on a partial update on the kind of event. I would rather prefer implement something like "if device expects webhook events then it should not be updated by pulled events" after the initial one.

@lolodomo
Copy link
Contributor

Ok so this PR will be delayed after 3 3 is released.
Can we update the current documentation to mention webhook feature is not yet working and maybe even dissble it in the code?

@HaKuNaCH
Copy link

I guess the webhook part ist ok, because I tested now the call on the API directly.
I think there is a bug in the status polling. If required I can open a new bug report for that.

/homedata -> if required, I can post an example
/homestatus -> if required, I can post an example
/getevents (I left 1 event in, but all the follwowing events also contain the same attributes and all with values)

{
	body: {
		home: {
			id: "xxxxxxxxxxxxxxxxxxxxxxxx",
			events: [{
				id: "xxxxxxxxxxxxxxxxxxxxxxxx",
				type: "outdoor",
				time: 1655917778,
				module_id: "xx:xx:xx:xx:xx:xx",
				video_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
				video_status: "available",
				subevents: [{
					id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
					type: "human",
					time: 1655917778,
					verified: true,
					offset: 1,
					snapshot: {
						url: "https://netatmocameraimage.blob.core.windows.net/production/xxxxxxxxxxxxxxxxxxx",
						
					},
					vignette: {
						url: "https://netatmocameraimage.blob.core.windows.net/production/xxxxxxxxxxxxxxxxxxx",
						
					},
					message: "Person erfasst"
				}]
			},

			.. around 40 entries, all with the same attributtes and values are present in all ..

			]
		}
	},
	status: "ok",
	time_exec: 0.042575836181640625,
	time_server: 1655967343
}

@clinique
Copy link
Contributor Author

Agree with @HaKuNaCH , I think the way webhooks are handled in here is correct but this raises the need for an enhancement in the regular pull part.

@lolodomo
Copy link
Contributor

So you all agree that this PR should be merged in its current state (after a code review)?

@clinique
Copy link
Contributor Author

Yes

result.add(getCameraId());
addNotBlank(result, homeId);
addNotBlank(result, deviceId);
addNotBlank(result, getCameraId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it expected to add camera ID twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. Some values may be empty. In some cases (e.g. smoke detector), the cameraId will be blank but the deviceId will be filled. Redundant entries will be ignored.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not fully convinced, there is certainly something I do not understand...
As you are apparently convinced you have to call this twice, let's go, we have no more time to debate.

@HaKuNaCH
Copy link

So you all agree that this PR should be merged in its current state (after a code review)?

Also a YES from my side.

Should I open a new bug report for the polling issue with the Doorbell?

@clinique
Copy link
Contributor Author

So you all agree that this PR should be merged in its current state (after a code review)?

Also a YES from my side.

Should I open a new bug report for the polling issue with the Doorbell?

Yes, please, do.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except one thing but this is probably not major.

@HaKuNaCH
Copy link

Should I open a new bug report for the polling issue with the Doorbell?

Yes, please, do.

done: #13002

@clinique clinique deleted the netatmo_12952 branch June 25, 2022 14:36
leifbladt pushed a commit to leifbladt/openhab-addons that referenced this pull request Oct 15, 2022
* Adding Webhook event support for Doorbell
* Adding doorbell rtc.
* Enhancing NAPushType deserialization
* Setting empty fields to NULL

Signed-off-by: clinique <gael@lhopital.org>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
* Adding Webhook event support for Doorbell
* Adding doorbell rtc.
* Enhancing NAPushType deserialization
* Setting empty fields to NULL

Signed-off-by: clinique <gael@lhopital.org>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
* Adding Webhook event support for Doorbell
* Adding doorbell rtc.
* Enhancing NAPushType deserialization
* Setting empty fields to NULL

Signed-off-by: clinique <gael@lhopital.org>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
* Adding Webhook event support for Doorbell
* Adding doorbell rtc.
* Enhancing NAPushType deserialization
* Setting empty fields to NULL

Signed-off-by: clinique <gael@lhopital.org>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
* Adding Webhook event support for Doorbell
* Adding doorbell rtc.
* Enhancing NAPushType deserialization
* Setting empty fields to NULL

Signed-off-by: clinique <gael@lhopital.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Netatmo] Webhook does not update all available channels - Smart Video Doorbell
4 participants