Nanit Baby Monitor Integration

Great work! Got everything up and running on the live stream! Wife is happy! Onto the next home automation!

Happy New Year!

Adam, what you’ve done it amazing! Just had to install “Homebridge Camera FFmpeg” plugin and oh my it works! And Apple TV. This is a dream come true! Happy New Year! What a start!

Update: it lags big time though through the RTMP :frowning:

Local is not working. How to overcome ERR Failed to request local streaming and stream seems to be dead error=“Forbidden: Number of Mobile App connections above limit, declining connection”? It doesn’t allow local stream at all. Other apps use the server. I even tried to logged out

Warning for local websocket connection: There seem to be a limit of 2 active connections on the device. The authorization will fail with 403 if you exceed the limit.

While I don’t have two active connection I still trigger the limit. So I decided to test local stream in the app by removing the cord out of the router. It worked. Local steam was established. But once I switched to the RTMP to replenish the limit got 403 anyway. So point is that even if I don’t have an active local connection I still get 403 all the time. Removing my wife or the apps per se didn’t seem to address this limitation:( The camera should treat the nginx-rtmp as one of two apps.

P.S. I am a new user here and get only 3 posts per topic. This is 3rd. I know, right?

Filled it here - 403 Forbidden for local stream while no active connections (#7) · Issues · Adam Staněk / Nanit · GitLab

Got the monitors working off the dev branch. Have them going to Homekit:

As well as a little ESP8266-based device running esphome that displays the temp and humidity off the MQTT topic:

4 Likes

You keep doing heroes work!
The stream drop out was the only thing that was causing issues, but hourly docker restarts filled the gap.
Going to give this a whirl today :slight_smile:
Can’t thank you enough! It is such an important thing and you’ve made it so much easier for us parents to keep an eye on the little ones but also remind our partners why our home automation obsession / hobby is worthwhile lol

By chance have you seen the breathing rate come through as a sensor? Wondering if that could be overlaid on to the camera image - no biggy if not as the app will alert me if anything to be concerned by.

1 Like

Thank you for the kind words :slight_smile:

We decided to go without breathing wear so I have no idea if the cam exposes that data and how. You would have to check yourself (good start would be to start the app with trace log level so that you can see the communication traffic). But I haven’t noticed any mention of breathing stuff while reverse engineering the protocol.

Currently I am working on integrating the RTMP server into the app. I tried the watchdog approach but it just wasn’t stable enough for me and there were still some issues with RTMP server not being up at the time of requesting etc. I have some working PoC already (rtmpserver branch), but the development is going bit more slowly now when I am back at work. Maybe you should wait until then unless you want to deal with existing issues. The current stable version (0.4) is still probably the best to use unless you absolutely want to have that sensor data :wink:

Btw. guys is anybody actually using HLS streaming? I am thinking about dropping the support and go RTMP only in the future version. It just seems that the latency on HLS is too much for reasonable baby monitoring and I don’t want to keep additional complexity in the app without a reason.

1 Like

i’m using the RTMP, I know a few others are using homekit (not sure what stream type they opted for that) - but local seems to be the best and most reliable.

A watchdog sounds like a good approach, sorry its not stable - my knowledge in this space is limited but if I can help test/review LMK. On occasion the connection drops before my hourly restart, but I can totally live with it.

The breathing wear is great btw - sleep sacks are a little better as ours has figured out how to unvelcro the band lol

Gives us a little extra piece of mind, especially when he has a cold or isnt well. We also havent had a single false positive or negative. Dont suppose motion or noise sensor alerts appear in the traffic do you? Would be nice to look at some automations (like lower the tv volume if movement is detected or send a snapshot of the stream to my iphone/apple watch)

I’m in no rush, and very much appreciate the work you are putting in on this :smiley:

As far as next steps if you created a self contained docker with RTMP, you could package it up as:

  1. HASSIO add-on which are basically just containers.
  2. A full integration that requires your external docker (that essentially would just add the camera and sensors to HA automatically)

I for one would love to see a HASSIO add-on for simplicity. I’m comfortable adding the sensors in via MQTT and YAML. Also, thank you for all the hard work so far!

1 Like

I am not sure about the breathing wear traffic actually. I would say that it is something which is evaluated locally (similar to sound detection, etc.) and only results in notification. On the other hand if I am not mistaken then the UI shows BPM and it has to get it somehow. I would expect that you need to subscribe to it while the app is active to not pollute the channel with unnecessary data, but has to get to the app somehow :slight_smile:

I have been also toying with the idea of sound detection. It is not something the cam exposes, but with integrated RTMP stream processing it opens a lot of possibilities :wink: The ultimate goal for me would be image recognition to have state if the little one is in the crib or not. I am imagining a lot of cool automated scenes with that :wink:

But honestly guys I don’t know how much effort I will be able to put into the project. It is all fun, but now the vacation is over. My priority is to make it stable, so that I can rely on it without any need for restarts or workarounds. I will probably leave the native addons etc. to the community and focus only on the app.

1 Like

i wouldnt personally put the time into object detection as there are many options out there to leverage.

I can use Zoneminder, some use frigate or deepstack docker containers, some can use Shinobi or motioneye - and then just create rules.

You getting the feed out is genuinely the most important thing - and then detecting any drops would be super helpful.

Good point. It is just something I always wanted to learn and actually put to good use apart of few artificial tasks :slight_smile: But no point reinventing the wheel. If there is an easy integration of one of the existing solutions they will definitely do better job than I can hack together in few afternoons :slight_smile:

Just a thought,

If you’re integrating the RTMP Streamer into the app, would it be possible to setup options when you set up the docker container to include overlays on the feed? Some options that come to mind are:

  • Temperature
  • Humidity

Would it also be possible to add the option for a timer? Example: Setup a protocol for “Nap Time” that sends the video feed to the necessary devices and starts a timer for X minutes as an image overlay?

Not super important stuff but would make it easier to kick up a container for someone unfamiliar!

Thanks again for developing this!

No idea. I am not that well versed in video processing. This would require video stream manipulation. I would be bit worried if it would be usable for majority of people since it seems everybody are running it on PI and similar low powered devices. Any video stream manipulation involves decoding and reencoding the stream. In PI4 there should be usable option to leverage hardware acceleration but on other devices it would probably not be useable or it would add more latency to the stream due processing.

Alternative (and I think better) way would be adding the info in the dashboard widget so that the data are shown / updated directly over the video stream when you view it. Similary to what the phone app does.

Totally makes sense. I didn’t realize we’d need to re-encode the stream. I can definitely add the telemetry as their own widgets and send that as part of the cast.

Once again, excellent work on this! Much appreciated!

Hey everyone! Huge thank you to Adam! As a new dad with a Nanit and Homebridge setup, this is something I desperately wanted. Hoping someone can help me with an issue I’m having. I’m newer to docker, and when I run the docker build command inside of the directory where Adam’s file is downloaded, I get 4 purple completed lines and then the following error:

=> CANCELED [internal] load metadata for docker.io/library/golang:1.15.5-buster 0.4s
failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to parse stage name “registry.gitlab.com/adam.stanek/nanit/base:”: invalid reference format

The command I am running is: docker build -t nanit-restream .

Also attached a screenshot for reference. Any help is greatly appreciated! Thanks!!
Screen Shot|690x100

Hi Josh, seems to me that you are trying to build the application. It is not necessary, you can just run it. It is available as already built docker image.

For starters you can try to run it by:

docker run --rm \
  -e [email protected] \
  -e NANIT_PASSWORD=XXXXXXXXXXXXX \
  -p 8080:8080 \
  registry.gitlab.com/adam.stanek/nanit:v0-4

No prior downloads necessary, docker will do it for you if necessary. For additional information have a look at the README file: https://gitlab.com/adam.stanek/nanit/-/tree/master.

Thank you, Adam! This answered my question! When I run the command to to the local stream, it downloads and runs through the first six steps, but then I get the following error:

FTL Unable to fetch auth token error=“Post “https://api.nanit.com/login”: x509: certificate signed by unknown authority”

Any clue how to fix this? There is no rush at all. Thanks for your help! Great job on finding the local stream!

The error means, that the server it tries to communicate is not what it supposed to be. Something probably got in between the app and the server. I don’t know your setup, but check your networking / DNS (proxy? firewall?). Ensure that networking is working correctly in your docker containers first.

Did Nanit patch this?

My normal setup runs the rtmp with local stream. Both the rtmp and local stopped working. So then, I went to remote only (for testing) and get a black screen:

I haven’t changed my network at all and it was working fine yesterday. I thought it was an open API so not sure why it would suddenly stop working?

Thanks!

Everything still works as far as I know. The phone app is using the exact same API.

are you using the nanit docker? the RTMP stream can drop without any warning (issue highlighted on the Github)
I restart my docker every 45 mins and have no issue