Nanit Baby Monitor Integration

A little late on the replying here, but i was just messing with @zone99 implementation and couldnt get it to work, so i Claude vibecoded my way into taking the methodology from @indiefan using websockets/protobuf and forked GitHub - tman1206/scrypted-nanit with it.

Seems to be working, but i want to try it out w/ HomeKit, see if can add motion alerts, etc. Maybe will continue dinking with it as I have time :slight_smile:

I used MQTT Explorer and the MQTT integration to add them in the visual editor.

To answer your question, yes it is possible, but way more data would have to be pushed. If you look at the ring-mqtt integration, that is the level I think we can get too (eventually).

I set this up with Frigate and the indiefan proxy container. I’m not using Scrypted. I have a simple HA automation change the color of a Hue bulb when my little one cries or when motion is detected. Frigate’s audio detectors are super solid as others have said and they roughly match the Nanit app notifications, but often faster.

It took a bit to get set up, so here’s my setup for anyone curious:

Home Assistant - running on Proxmox but that part doesn’t matter as much. Mosquitto MQTT add-on running there too. I used the Home Aassistant OS script from Proxmox Scripts.

Docker: Frigate and indiefan/home_assistant_nanit docker container both running in the same docker-compose stack (created from Proxmox Docker LXC script). I mapped the GPU device here and as a passthrough in Proxmox. (I’m running on an Intel N150 Beelink box so I mapped /dev/dri/renderD128.) I ran Nanit auth process on my laptop and copied the session.json contents.

docker-compose.yml

Heads up that this docker compose uses a few volumes to partition storage, so definitely adjust as needed.

services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    stop_grace_period: 30s # allow enough time to shut down the various services
    image: ghcr.io/blakeblackshear/frigate:stable
    shm_size: "512mb" # update for your cameras based on calculation above
    devices:
      # - /dev/bus/usb:/dev/bus/usb # Passes the USB Coral, needs to be modified for other versions
      # - /dev/apex_0:/dev/apex_0 # Passes a PCIe Coral, follow driver instructions here https://github.com/jnicolson/gasket-builder
      # - /dev/video11:/dev/video11 # For Raspberry Pi 4B
      - /dev/dri/renderD128:/dev/dri/renderD128 # For intel hwaccel, needs to be updated for your hardware
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /mnt/frigate-config:/config
      - /mnt/frigate-storage:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "8971:8971"
      - "5000:5000" # Internal unauthenticated access. Expose carefully.
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp
    environment:
      FRIGATE_RTSP_PASSWORD: "A_PASSWORD"
    cap_add:
      - CAP_PERFMON

  nanit-proxy:
    # This name must match the RTSP frigate config.yml
    container_name: nanit-proxy
    image: indiefan/nanit
    restart: unless-stopped
    stop_grace_period: 10s # allow enough time to shut down the various services
    volumes:
      - /mnt/nanit:/data
    ports:
      - "1935:1935"
    environment:
      NANIT_RTMP_ADDR: 192.168.50.4:1935 # LAN IP address of this Docker container. Yes, weird.
      NANIT_LOG_LEVEL: trace
      NANIT_MQTT_ENABLED: true
      NANIT_MQTT_BROKER_URL: mqtt://192.168.50.5:1883 # In this case, my HA IP because HA Add-on.
      NANIT_MQTT_USERNAME: AN_MQTT_USERNAME
      NANIT_MQTT_PASSWORD: AN_MQTT_PASSWORD

Frigate config: This part took some tinkering but has been super solid once set up

Frigate YAML config
version: 0.16-0

go2rtc:
  streams:
    nanit:
      # The hostname nanit-proxy refers to the name in your docker-compose.yml
      - rtmp://nanit-proxy:1935/local/aab19b5c

mqtt:
  enabled: true
  host: 192.168.50.5 # IP address of HA if running Mosquitto add-on
  user: AN_MQTT_USERNAME
  password: AN_MQTT_PASSWORD


cameras:
  nanit:
    ffmpeg:
      inputs:
        - path: rtmp://nanit-proxy:1935/local/aab19b5c
          # The hostname nanit-proxy refers to the name in your docker-compose.yml
          input_args: preset-rtmp-generic
          roles:
            - detect
            - audio
    detect:
      enabled: true
    audio:
      enabled: true
#  test_crying_detection:
#    ffmpeg:
#      inputs:
#        - path: /media/frigate/crying2_25_31_783.120_327.mp4
#          input_args: -re -stream_loop -1 -fflags +genpts
#          roles:
#            - detect
#            - audio
#    detect:
#      enabled: false
#    audio:
#      enabled: false

    motion:
      threshold: 50
      contour_area: 40
      improve_contrast: true

detectors:
  ov:
    type: openvino
    device: GPU

# TODO TODO TODO Edit this section
# See https://docs.frigate.video/configuration/object_detectors/ for the correct model for your hardware. 
# You might also need to copy model files depending on your choice.
# This is for Intel N150 and most other Intel hardware. Note that you'll need to pass through /dev/dri/renderD128 for this.
model:
  width: 300
  height: 300
  input_tensor: nhwc
  input_pixel_format: bgr
  path: /openvino-model/ssdlite_mobilenet_v2.xml
  labelmap_path: /openvino-model/coco_91cl_bkgr.txt


audio:
  enabled: true
  max_not_heard: 15
  listen:
    - crying
    - babbling
    - scream
    - yell
    - smoke_detector # Bonus!
    - fire_alarm # Bonus!
  filters:
    crying:
      threshold: 0.6

face_recognition:
  enabled: true # Frankly this is unnecessary. It's only ever seen my baby's face.
  model_size: large


objects:
  track:
    - person

Inside Home Assistant, I’m using the Frigate HACS integration. I also created MQTT sensors with for temp and humidity for the topics nanit/babies/{babyId}/temperature and nanit/babies/{babyId}/humidity.

One bonus, you can add Frigate detectors for smoke_detector / fire_alarm and HA now knows about your fire alarm with just a couple lines of config.

I hope this helps! - sorry for so few links, new user.

1 Like

Hey all, I forked indiefan/nanit recently and added a bunch of features that I figured might be useful to others here.

The main additions:

  • Token refresh for reconnections - was hitting EOF errors when the auth token expired during stream reconnects. Now it grabs a fresh token before each reconnection attempt.
  • Stream failover - automatically switches between local (direct from camera) and remote (Nanit cloud) if one fails, then tries to restore local when it’s available again
  • Self-healing reconnection - stream drops get handled automatically with exponential backoff
  • IP whitelist for RTMP - lock down who can connect to your stream (presets for hassio, docker networks, or specify exact IPs)
  • MQTT auto-discovery - sensors show up in HA automatically without yaml config
  • Sleep tracking - sleep stats exposed as sensors
  • ARM64 builds - works on Pi and other arm64 systems

Docker Hub: seangreenhalgh/nanit
GitHub: GitHub - scgreenhalgh/home_assistant_nanit: Docker container for mirroring nanit feed suitable for Home Assistant integration

Setup is the same as indiefan’s version - run the init script for 2FA, then start the container. Docs are in the README.

Happy to hear if anyone runs into issues or has feature requests.

3 Likes

I have just swapped over to your image and it appears to be working fine after some troubleshooting. The main issue I ran into was the inability for me to connect to the RTMP stream without explicitly allowing the IP address " 151.101.125.140". I assume this is Nanit’s IP. Is it possible to use this image without explicitly allowing that IP?

Not sure if this is still valuable but I was able to get nanit streams into Uniti Protect with some frankenstein docker pipelines.

Essentially get the RTMP stream with indiefan’s image → Frigate restream to RTSP → RTSP-to-ONVIF wrapper → Unifi Protect

Here is the ONVIF wrapper I used: GitHub - daniela-hase/onvif-server: Virtual Onvif Server - Add support for multichannel Onvif cameras to Unifi Protect!

great updates, thank you! I was able to drop this in directly on my prior indiefan config, with the inclusion of the IP whitelisting.
Testing it out now but looks good so far.

Did you also have issues establishing a connection before whitelisting the Nanit public IP address?

I did not need to whitelist the public nanit IP address

1 Like

@scgreenhalgh Do you need to have an active Nanit Insights subscription for the In Bed / Asleep sensors to work?

Is there a way to get the nanit feed into an area?

Hi!

Nanit Add-on + Custom Integration

Had a vibe-coding session and made an add-on + integration for Nanit. I know that several people have done this before me, but i wanted to make something that was a little bit more ā€œplug-and-playā€ (please note that i am NOT saying anything bad about any of the other projects out there, in fact a lot of the code i used is based on their work so THANKS!!!).

It is probably a lot of bugs/issues with this code, so feel free to report anything u might notice! I want to try and keep this repo up-to-date (as long as there are people actually using it) :slight_smile: Let me know if you have any questions or suggestions for improvements!!

3 Likes

I have taken @trym.j.berg project as a starting point and started adding support for Nanit’s Light and Sound machine. So far it is working correctly locally, but will need to test it more before submitting it.

2 Likes

Super cool! @Phoenix12

Feel free to add PR(s) for the new features! The more robust we can make the project the higher the chances are that we can submit it as an official integration

This is awesome, thank you for doing the hard work. Is there a way to add a secondary instance for a second Nanit? When I added it I was only able to see one.

If you need testers, let me know. I’m very interested in getting the sound machine integrated.

I just submitted the PR that adds it, local testing for myself went well.

nice! I do not always see updates here, but i see them in github. Thanks for contributing

Am I able to control the night light on the nanit camera with this project?

I’m a bit of a novice when it comes to docker, home assistant and everything this involves. It will probably take me a solid day to get this all setup. So before hopping into it, I just wanted to ask. I’ve read through all of the comments on this thread and the project on GitHub and couldn’t find a definitive answer.

We have two nanit cams, and my biggest issue is that we accidentally leave the light on all of the time.

Sorry for the late reply!

I recently added support for dimming (and turning on/off) the night light. Also I added the auto-off timer options that you can already see in the Nanit app. My suggestion is to create an automation that triggers every night that turns the light off (for both cameras).

The integration is now fully setup without add-ons/docker containers. Setup is quite easy. Look at the README.md file in the repository and it will show you how to install and set it up. If you are struggling let me know :slight_smile: