Nanit Baby Monitor Integration

Hello guys, after longer pause I decided to release new version - 0.6. The connection recovery could still use some improvement, but it has been running solid for 2 weeks for me so I decided to publish it to wider audience.

This is the first release with integrated RTMP server. You don’t have to rely on NGINX anymore. It was rather problematic since the beginning. It was hard to ensure it is up and running during the initial streaming request and because we couldn’t handle any connection drop outs that way. With integrated RTMP server it should be much leaner setup.

Also in this release you can plug it to your MQTT server for sensors read out.

I have decided to drop the HLS streaming and focus on local RTMP streaming only. That is the only way how to get decent latency which is crucial for baby monitor. If you want HLS streaming, you should stick to v0_4.

Before you upgrade, please check https://gitlab.com/adam.stanek/nanit/-/blob/master/.env.sample for updated configuration variables. I had simplified them a bit for the new setup so some changes are required on your part.

Let me know how it works for you :slight_smile:

4 Likes

I really appreciate all your work!

But I do notice that I have to disable 2fa/mfa for been able to use docker right?
Nanit will enforce 2fa in the future for all users (found that on Nanit website).

Thanks for your continued efforts on this integration! I’m trying to run the new application, but it hangs on “fetching babies list”. I have 2 cameras fwiw.

The 2FA is currently not supported. It is generally problematic for headless applications, because it requires additional input form the user. I haven’t look at it yet. Hopefully they provide some form of persistent tokens after the initial auth. challenge. But yes, it will be a complication.

Hmm… That is strange. There was no change to this step between releases. Does it happen even after restart? The only reason I can think of is a network issue.

Yeah, I rebooted the Pi and it still hangs. Happens right after authorized token

Can you send me trace level log ( NANIT_LOG_LEVEL=trace)?

You can make a ticket on the project on GitLab, so that we don’t spam the thread.

Hey guys I just set this up… I have the same issue as above with version 5/6 stops at finding babies… if I use version 4 or below it works fine…

Adam revised the readme to include another environment setting. Try the following:

docker run --rm \
  -e [email protected] \
  -e NANIT_PASSWORD=XXXXXXXXXXXXX \
  -e NANIT_RTMP_ENABLED=true \
  -e NANIT_RTMP_ADDR=xxx.xxx.xxx.xxx:1935 \
  -p 1935:1935 \
  registry.gitlab.com/adam.stanek/nanit:v0-6
1 Like

This is brilliant. Just read the whole read after receiving a marketing sample of the Nanit Pro. Seems to be similar to the Plus version. Will give this a go shortly! Would be really cool to have as an addon. I think the delay is from the home assistant processing and I had something similar with unifi cameras. Shooting it over to motion eye first and then grabbing that stream url makes it instant. I’ll have to try with this stream too.

Hello! I was able to get everything working once I switched to Docker on my Pi. This is such a huge help and it worked the first try. Brilliant!

Couple questions… again, I’m newer to the docker side of things.

  1. I am using the new v0.6 version. Still getting a 4 second(ish) delay… any tips to get it faster? Wifi is great where the camera is and Pi is hardwired.
  2. How can I activate the MQTT side of things? I have Mosquitto installed on the same pi, but wondering how to get this module to publish to it.
  3. How can I get this to auto run on boot with the pi? Right now, I have to open terminal and run it… then leave that terminal window open for it to continue.

Running latest Homebridge on same Pi. Any and all help is greatly appreciated! Thanks!

1 Like

Hello Josh,

seems a lot of you guys are starting out with docker, so I have written quick setup guide with docker-compose which should contain the info you need (regarding the auto-start).

Here it is: https://gitlab.com/adam.stanek/nanit/-/blob/master/docs/docker-compose.md

The sensor setup is vaguely described here: https://gitlab.com/adam.stanek/nanit/-/blob/master/docs/sensors.md. If you have Mosquitto already up and running, you are half way there. Just pass the additional MQTT options to the app and it will start publishing the sensor data to it.

Regarding the delay, I am guessing you are streaming through Homekit or something, right? I don’t think you will get much lower than that. Some additional info: https://gitlab.com/adam.stanek/nanit/-/issues/9#note_479409071

The RTMP streaming itself isn’t exactly low-latency protocol, it usually gets about 1-2s (you see it even on your phone app). If you are reprocessing the stream for HomeKit or something, you get that twice (3-4s).

1 Like

@velky.bloud I’m getting the following log message when trying to restream.

No stream publisher registered yet, closing subscriber stream

Trying to figure out how to get MQTT working (again, my setup is on a Pi and I use Homebridge. Appreciate the help given we’re on HA here)

I passed the following to my docker-compose environment

NANIT_MQTT_ENABLED=true
NANIT_MQTT_BROKER_URL=tcp://iot.eclipse.org:1883

and have the homebridge/mqttthing plugin enabled with the following config

    "accessories": [
        {
            "type": "temperatureSensor",
            "name": "<baby#1>'s Temperature",
            "topics": {
                "getCurrentTemperature": "nanit/babies/<baby#1-UID>/temperature"
            },
            "accessory": "mqttthing"
        },
        {
            "type": "humiditySensor",
            "name": "<baby#1>'s Humidity",
            "topics": {
                "getCurrentRelativeHumidity": "nanit/babies/<baby#1-UID>/humidity"
            },
            "accessory": "mqttthing"
        }
    ],

Forgive my lack of knowledge…but what am I missing? How can I get these two sensors to show up in the Home app?

That message means that you are trying to play the stream, but cam is not streaming to the app. Probably due some failed streaming request attempt. Check the log for errors at start, this line itself is pretty much meaningless.

You still need to run your MQTT server like Mosquitto. Here is some more or less relevant tutorial you can try: https://selfhostedhome.com/setting-up-mqtt-broker-for-diy-home-assistant-sensors/

After you have your MQTT server up and running you pass its address to NANIT_MQTT_BROKER_URL and to homebridge/mqttthing plugin configuration (https://github.com/arachnetech/homebridge-mqttthing/blob/c2abf22dbef27bd329a038bd394a6ab112681fd6/docs/Configuration.md#mqtt-settings)

Got it. Installed Mosquito broker on the pi and the mqttthing sensors are now displaying the correct readouts. Again, thanks so much!

I have fixed the support for multiple cameras in 0.7 :tada:

1 Like

I’m not seeing anything that stands out to me

e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Application started e[36mgitversion=e[0m62fc318f
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m No .env file found. Using only environment variables e[36mpath=e[0m/app/.env
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Setting log level to info
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Authorizing using user credentials e[36memail=e[0m***************** e[36mpassword=e[0m****************
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Authorized e[36mtoken=e[***************************************************
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Fetching babies list
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m RTMP server started e[36maddr=e[0m:1935
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Connected to websocket e[36murl=e[0mwss://api.nanit.com/focus/cameras/************/user_connect
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Requesting local streaming e[36mtarget=e[0mrtmp://***.***.***.***:1935/local/********
e[90m03 Feb 21 09:47 ASTe[0m e[32mINFe[0m Local streaming successfully requested
e[90m03 Feb 21 09:47 ASTe[0m e[31mWRNe[0m No stream publisher registered yet, closing subscriber stream e[36mbaby_uid=e[0m******* e[36mclient_addr=e[0m***.***.***.***:******

The log says that the streaming was requested, but does not contain message that it was initiated => the cam most likely failed to reach the application. Check if the app is reachable at that RTMP address from the camera. Have you exposed that port?