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] Support Presence Camera #3059

Closed
rklueber opened this issue Dec 31, 2017 · 70 comments · Fixed by #7807
Closed

[netatmo] Support Presence Camera #3059

rklueber opened this issue Dec 31, 2017 · 70 comments · Fixed by #7807
Labels
enhancement An enhancement or new feature for an existing add-on

Comments

@rklueber
Copy link

rklueber commented Dec 31, 2017

Expected Behavior

Being able to turn on notification about movements seen dependent on other OH2 variables.

Target is to activate/deactivate the messaging of persons from the camera dependent of another OH2 item. I have a presence variable if at least someone is at home. If this is the case I would like to turn on/off the alarming of persons in the garden via a OH2 rule.

Current Behavior

Netatmo Presence is yet not supported by the v2 of the binding.

Possible Solution

Use the provided API from netatmo to access and modify the properties

Context

Your Environment

OH2, Netatmo Presence camera

@mister78
Copy link

mister78 commented Mar 2, 2018

I am looking forward for support of the presence camera too.

@lolodomo
Copy link
Contributor

lolodomo commented Mar 4, 2018

I am currently testing the Welcome camera and I am trying to fix all the little problems I can identify.
Then I will try to add the support for the Welcome Presence. It should even be very easy to add as the API is almost the same between Welcome and Presence.

@clinique: my feeling is that we have mainly to add the specific scopes for Presence camera and think about the few differences between the Welcome and the Presence camera. For example, an event for a Presence camera can include a list of sub-events.

@jannegpriv
Copy link
Contributor

I've made some local tests implementing support for my Presence based on the latest Netatmo 2.x binding and as @lolodomo mentions the Swagger API needs to be updated with support for the sub-event list array that is present for each event.

My local implementation uses c&p from the Welcome implementation adding a NAPresenceHomeHandler and a NAPresenceCameraHandler. A better solution might be to have a more generic CameraHome/Handler that supports both Welcome and Presence.

I'm able to beta-test your Presence implementation since I have a Presence camera (and soon a Welcome camera too).

Regarding the web hook support, is the only way of using the web hook to have my Openhab on a public IP or are there other ways of configuring it? The web hook is the only way as I understand to get immediate openhab events based on the Netatmo events/sub-events.

@lolodomo
Copy link
Contributor

lolodomo commented Mar 7, 2018

Yes for the webhook, unfortunately.

Is there any difference in your presence class compared to the welcome class ? I initially thought there would be no need of new classes. Or at least an abstract class that will contain everything in common, that is probably 95%.

@clinique
Copy link
Contributor

clinique commented Mar 7, 2018

Yes, for sake of clarity, I think we should have common abstract class, and specifics held by distinct classes.

Yes also regarding webhooks, it need a plublic IP and the tricky thing is that past very few unresponsive responses, you get blacklisted by Netatmo API for 24h. Currently, just to try it, I use a simple script hosted on a public cloud server that redirects to my home server.

@jannegpriv
Copy link
Contributor

jannegpriv commented Mar 7, 2018

Regarding the need to update the Swagger API, is that done by you guys or is it done by Netatmo? It looks like the 'Try It' functions on dev.netatmo.com also uses the Swagger API.

Regrading webhooks, is it possible to somehow integrate the webhook towards myopenhab.org?

@kaikreuzer
Copy link
Member

is it possible to somehow integrate the webhook towards myopenhab.org?

That would be a question that @marziman or @digitaldan could answer best.

@clinique
Copy link
Contributor

clinique commented Mar 7, 2018

@jannegpriv : swagger api evolution can be submitted on Github to cbornet repository: cbornet/netatmo-swagger-decl

Integrating webhooks to myopenhab.org could be a good approach, but it not bulletproof neither. This can also be down :(
My feeling is that the current approach of Netatmo is really not appropriate for a reliable notification system outside their own apps.

@jannegpriv
Copy link
Contributor

This can also be down :(

I've not had so much issues with it being down, isn't the new Google Home Action API also integrated towards myopenhab.org? Seems to be a natural way of integrating towards it since it is already there :-) Having the possibility to have almost immediate events in OpenHAB from Netatmo Events would be so useful and cool to have :-)

@lolodomo
Copy link
Contributor

lolodomo commented Mar 7, 2018

Integrating in myopenhab is not possible as Netatmo has not imagined that an authentication could be important for webhook !
I agree that this webhook architecture is unusable in practice due to security considerations.

@digitaldan
Copy link
Contributor

If my openhab can possibly help, ping me with some of the webhool details

@lolodomo
Copy link
Contributor

@digitaldan : pushing data to myopenhab without any authentication is forbidden, I imagine ?

@digitaldan
Copy link
Contributor

We can support oauth tokens or basic http auth, I don’t know the specifics of how you configure the webhook so it’s hard to know what the options are

@jannegpriv
Copy link
Contributor

The documentation is not so extensive, can you make something out of this API description of adding a webhook?

@digitaldan
Copy link
Contributor

Without knowing more, if they respect embeding the http auth parameters in the URL like "https://username:[email protected]/someRestEndpoint" then that might work. I understand this is passing your credentials around, so not ideal. Also note that myopenhab does support multiple "users" per account, so you could create a user in myopenhab with a complex password and use that (maybe a little better security)

@digitaldan
Copy link
Contributor

also note that you may need to esacpe the @ symbol with %40 when encoding :-)

@lolodomo
Copy link
Contributor

This will at least provide our myopenhab credentials to netatmo !!
For better security, I think we should stop logging this URL. And maybe consider this setting as a password to display stars in Paper UI.

@digitaldan
Copy link
Contributor

nginx would probably log this, I would need to check for a way for it to not.

@nbartels
Copy link

Just a short hint. The netatmo webhook sends an additional http header field called X-Netatmo-secret. This contains a hash sum. And it is calculated by the json content that netatmo is sending with the request and the client secret of the netatmo app. Here is an (official) example in PHP and I think this can be ported to Java: https://github.com/Netatmo/Netatmo-API-PHP/blob/master/Examples/Webhook_Server_Example.php

I use something similar using the Facebook Webhooks and because the secret is only known by the user and Netatmo and is not transferred it should be possible to identify the sender. Only Netatmo should be in the position to know this secret and the hash ensures that the content is not modified during the transfer. So we have a authorisation and a content check at once. If the calculated check sum and the one transferred do not match drop the request.

@lolodomo
Copy link
Contributor

lolodomo commented May 2, 2018

@jannegpriv : I would like to add support for Presence camera but I don't understand how I can distinguish Welcome camera from Presence camera in the API.
result.getCameras() returns a type List<NAWelcomeCamera>. There is no abstract class for camera in the API ? No class NAPresenceCamera ?
camera.getType() returns NACamera for a Welcome camera. What does it return for a Presence camera ?

@clinique : I don't understand on what library we rely on for the netatmo API ? I see a file netatmo-java-retrofit-1.1.1.jar in libs. Where does this file come from ? Where is the corresponding source code ?

@lolodomo
Copy link
Contributor

lolodomo commented May 2, 2018

@lolodomo
Copy link
Contributor

lolodomo commented May 2, 2018

Where is the source code of the class NAWelcomeCamera for example ?

@lolodomo
Copy link
Contributor

lolodomo commented May 2, 2018

@nbartels
Copy link

nbartels commented May 2, 2018

@lolodomo I analysed this, too. And it seems @cbornet wrote a swagger json to describe the Netatmo API and uses some tools to autogenerate a java lib from that. So someone has to extend the json file for the presence camera and then a new auto generated lib can be created and afterwards it is possible to improve this openhab2 addon. It's a bit bad we rely on a seldom updated 3rd party library. @lolodomo do you like to open an issue in @cbornet repo?

@lolodomo
Copy link
Contributor

lolodomo commented May 2, 2018

But the swagger json has maybe already all what we need (Presence support) ?
What we need is only a new corresponding jar file ?

@nbartels
Copy link

nbartels commented May 2, 2018

I don't think so, please check here: https://github.com/cbornet/netatmo-swagger-decl/blob/master/spec/swagger.yaml

There is no reference to presence and the "new" presence permissions are missing, too.

@clinique
Copy link
Contributor

clinique commented May 2, 2018

@lolodomo : the spec of the Netatmo API is in netatmo-swagger-decl, netatmo-swagger-api is used to generate the according retrofit client. Generated client that is present in the swagger-api repo has not been updated since a while.

@cbornet
Copy link

cbornet commented May 2, 2018

The netatmo-swagger-decl has the definitions for the Welcome camera endpoints which are the same as for Presence. So it should just be about adding the oauth scopes in the security definitions.

@clinique
Copy link
Contributor

clinique commented Jun 7, 2018

@lolodomo : don't know if I skipped it in previous reading but I discovered this in webhooks documentation today : "One valid request resets the failing counter of your application."
This is maybe the solution for a reliable usage of webhooks in events now !

@bruestel
Copy link
Contributor

@clinique I saw that you contributed to https://github.com/cbornet/netatmo-swagger-decl . How did you build the netatmo-java-retrofit-1.1.3.jar? Which arguments did you used with ´swagger-codegen`?

Thanks for you help.

@cbornet
Copy link

cbornet commented May 22, 2020

I don't really update or publish artifacts for netatmo-swagger-api. I think OpenHAB usually builds its own jar from the spec. @clinique , I think you did it initially ?

@clinique
Copy link
Contributor

I don't really update or publish artifacts for netatmo-swagger-api. I think OpenHAB usually builds its own jar from the spec. @clinique , I think you did it initially ?

Yes, IIRW using netatmo-swagger-api, I built locally the target jar and uploaded it to the openhab lib folder.

@Novanic
Copy link
Contributor

Novanic commented May 22, 2020

I don't really update or publish artifacts for netatmo-swagger-api. I think OpenHAB usually builds its own jar from the spec. @clinique , I think you did it initially ?

Yes, IIRW using netatmo-swagger-api, I built locally the target jar and uploaded it to the openhab lib folder.

Ok, thank you. That sounds simple, but which lib folder do you mean? I don't see a "lib" folder within the OpenHAB GitHub projects.

@clinique
Copy link
Contributor

You're right, now the lib folder has been suppressed, it's a dependency in the pom.xml :

    <dependency>
      <groupId>com.github.cbornet.netatmo-swagger-api</groupId>
      <artifactId>netatmo-java-retrofit</artifactId>
      <version>1.1.3</version>
      <scope>compile</scope>
    </dependency>

@Novanic
Copy link
Contributor

Novanic commented May 23, 2020

You're right, now the lib folder has been suppressed, it's a dependency in the pom.xml :

    <dependency>
      <groupId>com.github.cbornet.netatmo-swagger-api</groupId>
      <artifactId>netatmo-java-retrofit</artifactId>
      <version>1.1.3</version>
      <scope>compile</scope>
    </dependency>

Yes, I saw that but it seams to be difficult to get a new version of it uploaded to that repository (and I don't know which repository it is and who could do the release, it is not maven central).

Currently I try to integrate it within the maven build of the binding. So the maven build would download the swagger file (or uses a persisted copy of it) and generates the code with the swagger-codegen-maven-plugin. The advantage would be that it could get updated and built/"released" with just executing a maven phase and without involving 3 projects and various people. Is that a valid alternative solution?

For the events I would realize an event channel like "welcomeHomeEvent". But additionally to it I would realize 3 channels for boolean/switch items: humanDetectedChannel, animalDetectedChannel and vehicleDetectedChannel. That makes it easy to realize simple rules which are triggered by an item state change and to display the information within HabPanel for example. Would that be useful?

Thank you in advance and best regards

@clinique
Copy link
Contributor

clinique commented May 23, 2020

Yes, I think this is a very valid alternative solution, having these three projects has always been a pain preventing me to update more frequently this binding. Happy that you jumped in !

@Novanic
Copy link
Contributor

Novanic commented May 24, 2020

I have created a new pull-request which ...

  • uses the updated Netatmo API (to support the sub-event structure which is used by the Presence events)
  • delivers all information of the Presence events to the home thing (the message and snapshot is now available/set)
  • adds new channels to the home thing to report if a human, animal or vehicle was detected
  • simplifies the process of updating the Netatmo API (the retrofit code generation is now embedded within the Maven build)

The webhook is still untested and therefore still not yet activated for the Presence camera. I will check and support that later.

And it seems that I have a problem with updating my fork/branch (there are too many changes and required reviewers within the pull-request, I will try to solve it within the next days and create a new pull-request).

@Novanic
Copy link
Contributor

Novanic commented May 27, 2020

The pull-request is now available for review, see #7807

LoungeFlyZ pushed a commit to LoungeFlyZ/openhab2-addons that referenced this issue Jun 8, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
@cpmeister cpmeister linked a pull request Jun 8, 2020 that will close this issue
@Novanic
Copy link
Contributor

Novanic commented Jun 13, 2020

No, unfortunately the official Netatmo API doesn't seem to provide a solution to switch the floodlight. :-( We could try to ask Netatmo to extend the API.

There is a solution to stop/resume camera monitoring, to set the floodlight mode and to set the floodlight intensity !

To stop camera monitoring, run the Http request:
http://<netatmo presence camera ip address>/<vpn hash code>/command/changestatus?status=off

To set the floodlight mode in "auto" mode, run the Http request:
http://<netatmo presence camera ip address>/<vpn hash code>/command/floodlight_set_config?config={%22mode%22:%20%22auto%22}

To set the floodlight intensity to 50%, run the Http request:
http://<netatmo presence camera ip address>/<vpn hash code>/command/floodlight_set_config?config={%22intensity%22:%20%2250%22}

To get the <vpn hash code>:
1- Enter this URL into your web browser: https://dev.netatmo.com/apidocumentation/security#gethomedata
2- Click "Try it out" button
3- In Server Response, search the "vpn_url" field of your NOC camera
E.g:

...
"cameras": [
{
"id": "xx:xx:xx:xx:xx:xx",
"type": "NOC",
"status": "on",
"vpn_url": "https://prodvpn-eu-2.netatmo.net/restricted/255.255.255.255/a1f239843993d2a1k2201d336687d9a9/MTU5MDAxOTIwMDrR56gz25_ZK5vE3RLBH6s633rXxw,,",   

4- Identify/extract the from <vpn_url> (here: a1f239843993d2a1k2201d336687d9a9)

@Novanic, according to you, is it possible to integrate this into Netatmo binding ? :-)

Hi, good news, I got the floodlight running. ;-) I have created a feature request for it, see #7912 . There is also the information where to find the current state if you would like to test it.

Do you or someone other know if the start / stop video recording feature is also available for the Welcome camera? Is it available within the App for Welcome cameras? Or is it Presence exclusive?

@lolodomo
Copy link
Contributor

In the netatmo app, with the Welcome Camera, you can start and stop the live video. Is it the answer to your question ?

@Novanic
Copy link
Contributor

Novanic commented Jun 13, 2020

In the netatmo app, with the Welcome Camera, you can start and stop the live video. Is it the answer to your question ?

I see an option called "Überwachung" (german) at the Presence outdoor camera settings, see screenshot. That should be called "Monitoring", "Observation" or "Surveillance" in english. Is that the same what you see at the Welcome camera.

Screenshot_20200613-141455~2

@lolodomo
Copy link
Contributor

lolodomo commented Jun 13, 2020

Ah ok, yes of course, there is this option called "surveillance" in French to enable or disable the surveillance.
If the binding could control this option, that would be just wonderful. IMHO, this is the most important control I need in openHAB with the camera. I would like to enable the camera when leaving the house and stop it when I return, automatically by openHAB.

@Novanic
Copy link
Contributor

Novanic commented Jun 13, 2020

Ah ok, yes of course, there is this option called "surveillance" in French to enable or disable the surveillance.
If the binding could control this option, that would be just wonderful. IMHO, this is the most important control I need in openHAB with the camera. I would like to enable the camera when leaving the house and stop it when I return, automatically by openHAB.

Ah, ok. Then it should get realized for all/both camera models. Thank you. :-) The floodlight support #7912 is a good preparation for it, I will try to realize it after that.

@Novanic
Copy link
Contributor

Novanic commented Jun 18, 2020

Ah ok, yes of course, there is this option called "surveillance" in French to enable or disable the surveillance.
If the binding could control this option, that would be just wonderful. IMHO, this is the most important control I need in openHAB with the camera. I would like to enable the camera when leaving the house and stop it when I return, automatically by openHAB.

I have now opened issue #7938 for that.

J-N-K pushed a commit to J-N-K/openhab-addons that referenced this issue Jul 14, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this issue Jul 26, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
Signed-off-by: CSchlipp <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this issue Aug 31, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this issue Sep 1, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
Signed-off-by: Daan Meijer <[email protected]>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this issue Sep 19, 2020
…#7660)

* Support for the Presence camera added
* Files and thing types renamed because it handles now various camera types (not only the Welcome camera)
* README updated to clarify the Welcome and Presence product names
* Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras.
* Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible.
* welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later

Signed-off-by: Sven Strohschein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.