planetk/homebridge-netatmo

Homekit Camera Support

Opened this issue · 6 comments

Hey,

With the new Homekit App supporting Cameras, wanted to know if there were any plans to extend this plugin out to add the live streaming for the welcome cameras as well.

Looks like its accessible via the API:
https://dev.netatmo.com/dev/resources/technical/reference/cameras/live

I'm thinking of using the FFmpeg plugin in the meantime but I'm sure having the cameras integrated into this plugin would be a much more elegant solution (especially if you can choose whether or not to look at the local version if home)

I don't actually own a netatmo welcome, (but I'm thinking of getting one) but thank you for all your hard work on this plugin! It makes it easier for people like me to integrate these devices with our existing setups.

Hi,
Thanx for your Input. I do. have some plans for live picture support.
Currently there are two problems with this.
First ist the very limited spare Time I have for this project.
The other is, that I would Need to support the netatmo event and streaming API, which requires to connect to a public accessible IP.
I'm still thinking how to sort this in a way, that still keeps the plugin usable for everybody.
Kind regards
Stefan

Resources:

https://www.domoticz.com/forum/viewtopic.php?t=15124
https://github.com/openhab/openhab1-addons/wiki/Netatmo-Binding

I've bought a Netatmo Welcome camera, and got it working using the homebridge ffmpeg plugin. Not sure if it will be helpful to you, but I figured I would list my steps in case someone out there is looking to do the same thing I did. References above, some of my steps below are shamelessly copy pasted.

Step 1: Get your Home ID

  1. Login here using Google Chrome:
    https://my.netatmo.com/app/camera
  2. Click the gear Icon and a popup settings box will appear
  3. Right click on "Location" and select inspect, about 2 lines up from the default highlight you will see "href="/settingscamera/localisation/YOURHOMEID"

Step 2: Set your Welcome to a static IP.
This can be done under the setting for each camera. Under advanced settings. You can also do this at the router level. You just need to know the IP of your camera and that it will not change.

Step 3: Get your Access Token

Create an application at https://dev.netatmo.com/dev/createapp and Authorize your Application.
(You did this if you have this plugin setup)

Authorize the application by visiting the following URL in your Browser.

https://api.netatmo.com/oauth2/authorize?client_id=<CLIENT_ID>&redirect_uri=http%3Alocalhost%3A8080%2Ftest%2F&scope=&state=42"

The variables to fill in are:

<CLIENT_ID> Your client ID taken from your App at https://dev.netatmo.com/dev/listapps
<SCOPE> A list of devices and capabilities. The full scope would be read_station read_thermostat write_thermostat read_camera access_camera, see the Netatmo Scope Documentation for more info. Please ensure that the variable is URL encoded if your browser doesn't do it automatically, e.g. the URL encoded complete list of scopes would be read_station%20read_thermostat%20write_thermostat%20read_camera%20access_camera

When entering the URL to your browser it will take you to the Netatmo Webpage asking you to authorize your application to access your Netatmo data. The page should look something like this. After this step your Application should appear as an authorized application in your Netatmo profile. Please make sure it is there, it will not work if your app is not authorized.

Step 4: Retrieve an access_token
Retrieve an access token from Netatmo API, using e.g. curl.

curl -d 'grant_type=password&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&username=<USERNAME>&password=<PASSWORD>&scope=<SCOPE>' 'https://api.netatmo.net/oauth2/token'

The variables to fill in are:

<CLIENT_ID> Same as before
<CLIENT_SECRET> Your client secret taken from your App at https://dev.netatmo.com/dev/listapps
<USERNAME> Your Netatmo username
<PASSWORD> Your Netatmo password
<SCOPE> Same as before.

A successful response looks like this:

{
"access_token":"2YotnFZFEjr1zCsicMWpAA|alksdmaslkdmaslkdmaslkmsa",
"expires_in":10800,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
}

Make sure include the full access token in future steps including the "|".

Step 5: Get your Local IP access Key per camera

Use Curl again to pull the home data for your home_ID.

curl -d 'access_token=<access_token>&home_id=<HOME_ID>&size=5' 'https://api.netatmo.com/api/gethomedata'

For each camera in your network, grab the VPN url

So your url should look something like:

_https://0.vpn.netatmo.net/10.255.0.1/52ced8bcc8149089968095f995XXXXXX/ur8YcNFRXOyPTHONKZeeHXXXXX

This Url contains the local access Key. It should be something like:

https://v2.netatmo.net/restricted/XXX.XXX.XXX.XXX/<Access_Key>/<Nonsense>

With this Access Key and the Static IP we set before we can now access the cameras on the local network.

Step 6: Homebridge-ffmpeg config

Use the configuration below substituting your local IP and access key.

{
"platform": "Camera-ffmpeg",
"cameras": [
{
"name": "Camera Name",
"videoConfig": {
"source": "-re -i http://<Local_Static_IP>/<Local_Access_Key>/live/files/high/index.m3u8",
"stillImageSource": "-i http://<Local_Static_IP>/<Local_Access_Key>/live/snapshot_720.jpg",
"maxStreams": 2,
"maxWidth": 1280,
"maxHeight": 720,
"maxFPS": 30
}
}
]
}

This seems to work for me. Hopefully it works for you too :)

Hope that is helpful to someone. Good luck!

@creedda Thanks for this - this was very helpful! After following your instructions I do indeed see the camera in the home app, but when I click on it Home fails to connect to the live stream. I do see an updating snapshot every 10 seconds or so, but the live stream does not work (times out after about 20 secs). Can you access the live stream and if so could you confirm the ffmpeg string you see in the home bridge log? Thanks in advance!

Not sure. A couple of weeks later I started having the same problem. I am now waiting on netatmo's promised homekit support. We'll see if they provide everything, if not I will try and troubleshoot what the issue is.

I came back to this today since Netatmo still has not released their HomeKit support for welcomes.

Everything still seems to work it just seems like live-streaming depends on your connection.

If you are ok with lower quality here are the lower level stream URLS:

#EXTM3U
#EXT-X-ALLOW-CACHE:NO
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=144000,CODECS="avc1.42001f,mp4a.40.2",NAME="640x360"
files/poor/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=688000,CODECS="avc1.42001f,mp4a.40.2",NAME="640x360"
files/low/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1012000,CODECS="avc1.42001f,mp4a.40.2",NAME="1280x720"
files/medium/index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=3300000,CODECS="avc1.420028,mp4a.40.2",NAME="1920x1080"
files/high/index.m3u8

Hi creedda, all,

Thanks again for your instructions, they were a great assistance!
I just followed them and succeeded to add my Netatmo presence camera.

However for the scope I needed to update it to cope with the presence camera. Everywhere needed I used this one instead: read_station%20read_thermostat%20write_thermostat%20read_camera%20access_camera%20read_presence%20access_presence

Both snapshot & streaming work. Quality is however quite low, and streaming with more than 1min of delay.