I came down with this solution: https://gitlab.com/adam.stanek/nanit. It is not exactly the same thing as you are doing, but you can easily fork it and adjust the FFMPEG command to dump it to the file instead. The Auth + Stream URL part is covered.
I havenāt got to the Home Assistant yet. Currently only trying to stream to my TV. Btw. you should be able to also use the HLS stream on your dashboard somehow, but it is only supported in Safari AFAIK.
Now I am thinking about exposing metrics like temperature + times between events through MQTT. From there it should be possible to integrate them into HA.
Great work, everyone. I can grab a single frame using ffmpeg -i "rtmps://media-secured.nanit.com/nanit/{{baby_id}}.{{access_token}" -frames:v 1 ~/tmp/test.jpg. One can then display that image in Lovelace I presume.
Personally, Iād love to have it restreamed as a camera to Homekit via the HA bridge.
Actually, right when I wrote that, I realized that HA/Homebridge uses ffmpeg to restream. I got the Homekit camera showing up with this Homebridge config (I havenāt fully migrated my setup from HB to HA). Iām sure you can tweak it and have something similar via HA:
This is great ā I got something similar working last night and want to build a basic HomeBridge plugin with authentication.
Did anyone manage to pull the humidity/temperature from the sensor? It also looks like there are references to web sockets. I imagine those might be used for the events. Did anybody figure that part out already as well?
This will add the camera to your home assistant, and you can just use it or include it into your homekit. I am worries about the token that needs to be refreshed. Maybe it just needs a simple component to do that at first, in addition you might want to add things like events etc.
For myself and newbies like me, Iām trying to make sense of everything in this post. Can you confirm that the full steps to get it working on HA are the following?
This is awesome news! I donāt have any experience with HomeBridge so I didnāt realized it uses FFMPEG under the hood. I think I have a way how to solve it now together with authentication. Before I have written the go app for restreaming I was using nginx-rtmp. It is possible to just republish the RTMP stream that way. It would be already authenticated and you can just pass it to Homebridge!
I think I have discovered the way how to read the sensor data. Yes, it goes through web sockets. But it sends binary messages using protobuf. I am gonna try to reverse engineer it today. Already managed to get it output some temperature info.
So for now I have mapped the homeassistant www folder to the nanit docker.
So the docker is doing the authentication, and outputting the stream to an HA accessible location.
Then for HA Iāve simply added it as an FFMPEG camera