Nanit Baby Monitor Integration

Anyone have any tips to get this working? I setup the container from indiefan but when I add to Home Assistant it just shows as unavailable. Not sure where I went wrong.

Made the common mistake of using the camera IP rather than the docker host IP. All set now.

Do you think it will work for temperature as well?

It should, but itā€™s weird that you werenā€™t seeing temperature to begin with because the issue I found was that if it returns a temperature from the Nanit camera, it just stops there and essentially ignores the humidity reading.

(this is merged into the main fork now btw, along with some other fixes @shred provided) Thanks shred!

1 Like

Hey guys, new dad expecting here. First kid, Home Assistant nerd, so naturally I found this page. Lol. Does the API allow you to get the biometric data if you have smart sheets and such? IE breathing, size, etc.? So far Iā€™ve just seen stuff for the camera, temp, and humidity in this thread.

@indiefan, thank you so much, I could finally make the nanit work after months.
A question, at the moment we have a nanit app in the background and hearing itā€™s annoying white noise all the time. Isnā€™t a possibility to get sound detected or other notifications to mqtt?

@indiefan Kind of expanding on the above message, but can we use this to pull more sensor data? I was looking at the websocket_handlers.go code and was wondering if that is where we can add more. Particularly iā€™m looking for Motion data to tie that into other automations.

Am I in the ballpark?

looks like api.nanit.com/login is down? Tried migrating to a new docker host and Iā€™m unable to ping.

Looks like it, getting the same here - they may have changed or moved the API endpoints. Will raise an issue on the gh

I have not gotten these errors and I set up the camera today. If that helps troubleshooting at all.

Hello, cant see to pass the first part of getting the token for the 2fa authetication, Im running the script on a raspberry pi OS terminal , where Im using the docker. When I run the script asks me for the e-mail and password, but after gives me the error on line 27 and 33, Im pretty newbie by the way

I ran the ini.nanit.sh in debug mode ad got this

$ ./init.nanit.sh
Running script in debug modeā€¦
Nanit Email: [email protected]
Nanit Password: ./init.nanit.sh: line 27: jq: command not found
LOGIN Result: {ā€œmessageā€:ā€œnot authorizedā€}
./init.nanit.sh: line 33: jq: command not found
MFA_TOKEN Result:

Blockquote

I can get in the app and I can get the mfa_token via postman, I think IĀ“m running the wrong way the script, anyone have a step by step of how to run, IĀ“m using raspberry pi OS, running this script on the terminal of the raspberry, should I run in docker?

Hello I tried this way and I get error code; 402 when run the docker, do you know how to fix it

I think itā€™s not possible to get more data out of nanit to mqtt in this way.
So I went to another path to find a solution, first of all itā€™s not really straight but works very good.

Just a quick overview if you like to do it as well to have some automation base on your nanit (honestly better using a normal cam but nanit is what we have here)

my setup looks like

nanit
ā†’ this docker container
ā†’ Scrypted
ā†’ Frigate
ā†’ [Frigate audio detection (cry + scream + speech), Frigate object detection]
ā†’ Home assistant
ā†’ Frigate HACS integration
ā†’ Using frigate card for the dashboard + entities for automations

Thatā€™s exactly what I use as well. Frigate crying detection is solid.

Hi all, I had the Nanit <> Docker <> HB integration working at my last place but since moving I have not been able to get it going again. Iā€™m hoping someone can see what I donā€™t have right.

Notes

  • Auth session has been renewed and is working.
  • Camera IP: 192.168.2.238
  • Docker IP: 192.168.2.3
  • Port: 1935

Docker Compose

  nanit:
    container_name: nanit
    image: indiefan/nanit:latest
    restart: unless-stopped
    network_mode: host
    environment:
      - NANIT_RTMP_ADDR=192.168.2.238:1935
      - NANIT_LOG_LEVEL=trace
    volumes:
      - './nanit/data:/data'
    ports:
    # Nanit port
      - 1935:1935

Homebridge

{
    "name": "Camera FFmpeg",
    "cameras": [
        {
            "name": "Baby Cam",
            "unbridge": false,
            "videoConfig": {
                "source": "-i rtmp://192.168.2.3:1935/local/{{baby_id}}",
                "maxWidth": 1280,
                "maxHeight": 960,
                "maxFPS": 10,
                "maxBitrate": 3145,
                "audio": true
            }
        }
    ],
    "_bridge": {
        "username": "0E:58:C3:93:A4:2C",
        "port": 45753
    },
    "platform": "Camera-ffmpeg"
}

Docker Log

Docker Log
INF Application started
INF No .env file found. Using only environment variables path=/app/.env
INF Setting log level to trace
INF Loaded app session from the file filename=/data/session.json
TRC Starting attempt runner=websocket-{{serial}} try=1
INF RTMP server started addr=:1935
TRC Connecting to websocket
INF Connected to websocket url=wss://api.nanit.com/focus/cameras/{{serial}}/user_connect
DBG Baby state updated baby_uid={{baby_uid}} is_websocket_alive=true
TRC Notifying websocket ready handlers num_handlers=2
DBG Sending message data="type:REQUEST request:{id:1 type:GET_SENSOR_DATA getSensorData:{all:true}}"
TRC Sending data rawdata="\b\x01\x12\b\b\x01\x10\fb\x02\b\x01"
INF Requesting local streaming target=rtmp://192.168.2.238:1935/local/{{baby_uid}}
DBG Sending message data="type:REQUEST request:{id:2 type:PUT_STREAMING streaming:{id:MOBILE status:STARTED rtmpUrl:\"rtmp://192.168.2.238:1935/local/{{baby_uid}}\" attempts:1}}"
TRC Sending data rawdata="\b\x01\x126\b\x02\x10\x02\"0\b\x02\x10\x00\x1a(rtmp://192.168.2.238:1935/local/{{baby_uid}} \x01"
DBG Received message data="type:RESPONSE response:{requestId:1 requestType:GET_SENSOR_DATA statusCode:200 sensorData:{sensorType:TEMPERATURE isAlert:false timestamp:99847 valueMilli:-1000000 value:-1000 7:1719285991531} sensorData:{sensorType:HUMIDITY isAlert:false timestamp:99847 valueMilli:-1000000 value:-1000 7:1719285991533} sensorData:{sensorType:LIGHT isAlert:false timestamp:99847 valueMilli:230000 value:230 7:1719285991538} sensorData:{sensorType:NIGHT isAlert:true timestamp:99847 value:1 7:1719285991538}}"
DBG Baby state updated baby_uid={{baby_uid}} humidity=-1000 is_night=true temperature=-1000
DBG Received message data="type:RESPONSE response:{requestId:2 requestType:PUT_STREAMING statusCode:200 7:\"\\x08\\x02\\x10\\x00\\x1a$rtmps://{{ext_ip}}:{{ext_port}}/nanit/p2p\"}"
INF Local streaming successfully requested
DBG Baby state updated baby_uid={{baby_uid}} stream_request_state=1
DBG Received message data="type:REQUEST request:{id:5754 type:PUT_SENSOR_DATA sensorData:{sensorType:TEMPERATURE isAlert:false timestamp:99864 valueMilli:-1000000 value:-1000 7:1719286008102}}"
DBG Received message data="type:REQUEST request:{id:5755 type:PUT_SENSOR_DATA sensorData:{sensorType:HUMIDITY isAlert:false timestamp:99864 valueMilli:-1000000 value:-1000 7:1719286008111}}"
TRC Sending message data=type:KEEPALIVE
TRC Sending data rawdata="\b\x00"
TRC Sending message data=type:KEEPALIVE
TRC Sending data rawdata="\b\x00"
TRC Sending message data=type:KEEPALIVE
TRC Sending data rawdata="\b\x00"
DBG Received message data="type:REQUEST request:{id:5757 type:PUT_SENSOR_DATA sensorData:{sensorType:HUMIDITY isAlert:false timestamp:99924 valueMilli:-1000000 value:-1000 7:1719286068126}}"
DBG Received message data="type:REQUEST request:{id:5758 type:PUT_SENSOR_DATA sensorData:{sensorType:TEMPERATURE isAlert:false timestamp:99924 valueMilli:-1000000 value:-1000 7:1719286068128}}"
TRC Sending message data=type:KEEPALIVE
TRC Sending data rawdata="\b\x00"
DBG New stream subscriber connected baby_uid={{baby_uid}} client_addr=192.168.2.3:37142
WRN No stream publisher registered yet, closing subscriber stream baby_uid={{baby_uid}} client_addr=192.168.2.3:37142

HB Log

HB Log
[Camera FFmpeg] Restarting Process...
[Camera FFmpeg] Launched child bridge with PID 4947
Registering platform 'homebridge-camera-ffmpeg.Camera-ffmpeg'
[Camera FFmpeg] Loaded homebridge-camera-ffmpeg v3.1.4 child bridge successfully
Loaded 0 cached accessories from cachedAccessories.{{id}}.
[Camera FFmpeg] [Baby Cam] Configuring bridged accessory...
Homebridge v1.8.3 (HAP v0.12.2) (Camera FFmpeg) is running on port 45753.
[Camera FFmpeg] [Baby Cam] Failed to fetch snapshot.
[Baby Cam] Snapshot request handler provided empty image buffer!
[Camera FFmpeg] [Baby Cam] Starting video stream: 1280 x 720, 10 fps, 299 kbps (AAC-eld)
[Camera FFmpeg] [Baby Cam] FFmpeg exited with code: 1 and signal: null (Error)
[Camera FFmpeg] [Baby Cam] Stopped video stream.
[Camera FFmpeg] [Baby Cam] Failed to fetch snapshot.
[Baby Cam] Snapshot request handler provided empty image buffer!
[Camera FFmpeg] [Baby Cam] Failed to fetch snapshot.
[Baby Cam] Snapshot request handler provided empty image buffer!
[Camera FFmpeg] [Baby Cam] Failed to fetch snapshot.
[Baby Cam] Snapshot request handler provided empty image buffer!
[Camera FFmpeg] [Baby Cam] Starting video stream: 1280 x 960, 10 fps, 802 kbps (AAC-eld)
[Camera FFmpeg] [Baby Cam] FFmpeg exited with code: 1 and signal: null (Error)
[Camera FFmpeg] [Baby Cam] Stopped video stream.
[Camera FFmpeg] [Baby Cam] Failed to fetch snapshot.
[Baby Cam] Snapshot request handler provided empty image buffer!
[Camera FFmpeg] [Baby Cam] Failed to fetch snapshot.

Thank you for making Scrypted plugin, took literally 30 seconds to set it up,

Compare that to Docker integration which I gave up on after 30 minutes of trying to pull the session json, (having to extract the script, installing jq and then it still not working cause of some bad handshake issue)

ā€¦ So anyone who wants an easy solution, use his Scrypted plugin (it shows up in Scrypted repo) and then pump the feed to your HA and HomeKit if needed. You just install the plugin feel in your details in the input boxes, get the pin and you are done.

Yes it would be nice if it was local or if sensors were there but hey, I am just happy to have my feed.

Hello everyone, first time dad (in a few days hopefully) and home assistant fan here :slight_smile:

first of all thanks a lot for the load of useful information here, and the job done to create the container in order connect the Nanit to HA, youā€™re awasome :smiley:

Iā€™m trying to setup the Nanit in home assistant following the indiefan docker GitHub guide and so far I managed to setup the container authenticate and connect to MQTT for the 2 sensors (actually humidity is not reporting data but Iā€™ll figure it out later, temperature is working).

problem is the stream isnā€™t working and the error I get in the log of the container is the following:

11 Oct 24 11:45 UTC DBG New stream subscriber connected baby_uid=(reducted) client_addr=192.168.42.81:58890
11 Oct 24 11:45 UTC WRN No stream publisher registered yet, closing subscriber stream baby_uid=(reducted)  client_addr=192.168.42.81:58890

the configuration in home assistant is the following

  - name: Nanit
    platform: ffmpeg
    input: rtmp://192.168.42.143:1935/local/(reducted)

FYI
192.168.42.81 home assistant host
192.168.42.143 docker host for Nanit container

thanks in advance to whoever might help

Seems like you need to install jq (apt-get install jq) to process the json output of the script?

@indiefan It looks like someone submitted a change to fix the jq error message when receiving a token, would you be able to publish it?