Nanit Baby Monitor Integration

I’m seeing the same thing as cstraface. Opened an issue here

I’ve seen this before. Nanit will only allow a certain number of connections.

In my case, closing the app in both mine and my partners phone and restarting the connection fixed it.

this is great, thanks @indiefan !

Any way to get this working on a webrtc card.

Reason I ask is because I’m seeing a good 15 second delay on the video feed.

I have it working via go2rtc and the webrtc card. I just added it as a camera to go2rtc and it worked without any problems at all.

Interesting, I thought I tried this but I’ll give it a shot. Are you just reading the stream via the webrtc crard?

How is the latency?

Edit: @WhimsySpoon I gave this a shot by adding the URL to the go2rtc.yaml file.

Then I’m calling the card like follows but no lukc:

type: custom:webrtc-camera
streams:
  - url: Nanit

It just spins at loading

That should work. First of all, does it work in the go2rtc UI? (click on the “stream” link).

What I do is add a generic camera to HA, pointing to go2rc, so the stream source url in the generic camera would be something like rtsp://localhost:8554/Nanit.

Once you then get that generic camera streaming, you can add the card in the rtc card specifying the camera entity, rather than the stream source.

Not working for me in go2rc UI, I was trying direct URL though.

When you add the generic camera are you using ffmpeg?

Also, how is your delay with this setup?

Try adding ffmpeg: at the start of your url.

I have an ffmpeg: in my configuration.yaml, but that’s because I’m using it for something else.

With mine, I have no delay at all.

Apologies, I wrote the response above in a hurry yesterday and it clearly doesn’t read very well. I’ll try again…

If you can confirm that you can consume the stream using something like VLC, the next step is to get it running in go2rtc. It looks like you’re using the Add-on too. This is what my configuration looks like in go2rtc:

streams:
  some_other_camera: rtsp://{internal_ip_address}/asdfsdfsd
  nanit: ffmpeg:rtmp://{ip_address}:1935/local/{nanitbabyid}

The URL that you used to consume the stream in VLC is what goes in the nanit value. You’ll notice I’ve prefixed mine with ffmpeg:. It works without that prefix, but on my setup it’s needed in order to make the audio work. I need to go back and investigate this further.

Once you’ve saved and restarted go2rtc, go back to the “streams” view in the go2rtc interface and click on the “stream” hyperlink of your nanit camera. It should load very quickly and have an “RTC” inticator in the top right.

Once you’ve got that working, you can move onto getting the camera in the UI.

I’ve been using this configuration for a month or two now and it’s been rock-solid.

Doesn’t the add on automatically convert the streams to Webrtc?

I would really like to find a way to disable and enable notifications (both motion and sound as found in the baby settings under notifications in the app) through the API. so far the best i can do it toggle the “receive notifications” permission of a user with a put request but that requires making the user not an admin and doesn’t affect all users.

Anyone know where in the API I might find the way to toggle these settings?

@indiefan - Don’t suppose you found a to get more data from the websocket stream, and feed it into MQTT? Trying to see if there s a way to get the breaking monition monitoring data, as well as the last even stuff.

For instance, would like to do stuff if baby has fallen asleep, and then crying etc

thank you, it was confusing for me to get it all running on UNraid, but after i got Portainer up and running and I found your 2FA fix, thing works like a dream. I am still having issues getting MQTT working with the HA MQTT broker addon (NANIT_MQTT_BROKER_URL=tcp://homeassistantIP:1883 should be correct right?) But other than that it works perfectly.

Edit:
I figured it out: the MQTT Evn settings needed to be changed (mqtt:// instead of tcp://)

NANIT_MQTT_BROKER_URL=mqtt://homeassistantIP:1883

You got to create the entities by adding to HA configuration yaml using Frewchen’s change.

mqtt:
  sensor:
    - name: "Nanit Temperature"
      unique_id: nanit_temperature
      state_topic: "nanit/babies/{your_baby_uid}/temperature"
      device_class: temperature
      unit_of_measurement: "°F"
      value_template: "{{(value | float * (9/5) + 32) | round(0)}}"
    - name: "Nanit Humidity"
      unique_id: nanit_humidity
      state_topic: "nanit/babies/{your_baby_uid}/humidity"
      device_class: humidity`

Then to populate the entities with data I am using the MQTT Broker Add-on for Home Assistant. I went into the MQTT add-on and and hit RE-CONFIGURE MQTT that is where i got the user name and password for NANIT_MQTT_USERNAME/PASSWORD variables. The docker env file says they are optional but when using the default MQTT Broker addon settings you have to populate the username and password variables

I’m able to get Portainer working successfully, but I’m not able to get the stream playing in go2rtc, neither in the UI nor in VLC. What am I doing wrong?

Here’s the go2rtc config I’m using. The IP is the local Nanit address on my network. The error I’m getting in the go2rtc UI is “exist status 145”.

It’s meant to be your portainer IP not the nanit IP

I have got all of this setup thanks to @indiefan but my temperature won’t update until I open the nanit app, weirdly the humidity is updating just fine though, is this happening to anyone else?

Sorry I was trying to get your nanit solution to work on homeassistant. I got scrypted installed and working, but didnt see that you needed node.js and nvm … did you do that on a seperate server / vm? I wanted a solution all contained in home assisant if i could. Thanks for the help.

I came across this post attempting to get access to my Nanit Pro humidity readings to automate a humidifier. I had to do some digging around to figure everything out but I figured I’d recap it in one post for anyone else looking to do something similar (accessing the camera, temperature and/or humidity sensors).

@indiefan created a docker container that connects to your Nanit camera, which allows you to access the camera feed through RTMP and temperature/humidity sensors using MQTT. By default, this container only exposes the camera and the documentation doesn’t mention MQTT, but looking at the source code, it is disabled by default.

The environment variables you can specify for MQTT are:

  • NANIT_MQTT_ENABLED (default is “false”)
  • NANIT_MQTT_BROKER_URL
  • NANIT_MQTT_CLIENT_ID (default is “nanit”)
  • NANIT_MQTT_USERNAME
  • NANIT_MQTT_PASSWORD
  • NANIT_MQTT_PREFIX (default is “nanit”)

You need your own MQTT broker that this Nanit container will connect to. So basically, this Nanit container connects to your Nanit camera and relays the temperature and humidity information to your MQTT broker.

I’m using docker compose, so here’s an example of my docker-compose.yaml:

  nanit:
    image: indiefan/nanit:latest
    container_name: nanit
    restart: unless-stopped
    environment:
      - NANIT_RTMP_ADDR=your_nanit_cam_ip:1935
      - NANIT_MQTT_ENABLED=true
      - NANIT_MQTT_BROKER_URL=mqtt://mosquitto:1883
      - NANIT_MQTT_USERNAME=your_mqtt_username
      - NANIT_MQTT_PASSWORD=your_mqtt_password
      - NANIT_LOG_LEVEL=info
    volumes:
      - nanit:/data
    ports:
      - 1935:1935

Some notes:

  • Consider putting your Nanit camera on a static IP.
  • Since my MQTT broker (Mosquitto) is in the same docker network as this Nanit container, I’m just accessing the MQTT broker using it’s host name which is “mosquitto”.
  • I changed the log level from “trace” to “info” once I had everything setup (not required, just preference).
  • I’m using docker volumes, hence the “nanit” volume name.
  • I don’t actually need to expose port 1935 since I’m not streaming the Nanit camera, but I just left it in there as an example.

Edit: I missed the docs folder but it does explain some of this here.

1 Like

Oddly enough, I was having the opposite problem where the temperature was updating but not the humidity. I opened an issue on the repo but ended up figuring it out and submitted a pull request.

I’m not sure when it will be merged, but I did create my own fork and pushed to my docker hub (shred86/nanit) to test it. Feel free to use my image in the mean time if you want to test it out.

I see that Nanit has recently added the ability to stream your video feed in a browser. Has anybody managed to successfully embed the stream into a Home Assistant dashboard?