# Automation of Video Sending to Robonomics This article discusses the process of saving and viewing video via the web3 cloud using Robonomics integration. **It has been tested with HAOS and Pre-installed image** Requirements: - Deployed image with Robonomics - Configured RTSP camera ## Adding a Camera to HA During camera setup, create a user and password for RTSP streaming. Some cameras may require enabling RTSP streaming separately. Since this is done individually for each camera, this article does not cover those details. Once the camera is set up, you should either know the stream URL or find it. To find the information, search for "<Camera Name> rtsp stream." For example, a camera from the tapo company might have a stream path like this: `rtsp://<IP Address>/stream1`. Open Home Assistant (HA) and go to integrations. Click on "Add Integration" and enter "generic camera": ![Generic Camera](https://hackmd.io/_uploads/rJx2yd9S3.png) Select it and wait for the installation. A configuration input window will appear: ![Configuration](https://hackmd.io/_uploads/SJRDxOcr2.png) In the `STREAM source` field, paste the stream URL. Enter the username and password created for the camera in the `Username` and `Password` fields. It should look like this: ![Configuration](https://hackmd.io/_uploads/H1MMVd5rh.png) Scroll down and click the "Submit" button. **If setting up on a Pre-installed image, you may encounter an error:** ![Error](https://hackmd.io/_uploads/B15IN_qH2.png) This is because the "stream" integration is not installed by default in HA. It starts installing now, but to complete the installation, you need to reboot HA. After rebooting, repeat all the steps for installing the "generic camera" integration. After the reboot and reconfiguration, after clicking the "Submit" button, the following window will appear: ![Confirmation](https://hackmd.io/_uploads/S108Su9Sn.png) Check the checkbox and confirm. Finish the installation. ![Finish Installation](https://hackmd.io/_uploads/r1TFBdcHh.png) In the end, you will see a new integration with 1 entity. ![New Integration](https://hackmd.io/_uploads/HyKCHd5Sn.png) Add the stream to the dashboard. Go to the dashboard, create a new "Picture Glance" card: - Enter any title. - Remove data from the image path. - Choose your camera in the camera_entity. - Select "live" in the camera view for less delay. Save, and you will have the stream on your dashboard. ![Dashboard Stream](https://hackmd.io/_uploads/SkSIwdcSh.png) Camera configuration is now complete. ## Adding a Media Folder Before sending the video, you need to save it somewhere, and HA should have access to that folder. The easiest way is to create a media folder where HA stores all media. Learn how to create a folder [here](https://www.home-assistant.io/more-info/local-media/setup-media). In summary, the main options are: - The Robonomics image has this folder by default. - It is initially available in HAOS. - In core, go to the .homeassistant folder through the terminal and create it. - In Docker, add the following line to the startup command: `-v /PATH_TO_YOUR_MEDIA:/media \` Now HA has access to the media. Go to the "Media" tab -> "local media" and see an empty folder (no errors visible): ![Media Folder](https://hackmd.io/_uploads/S1FklsoSn.png) ## Calling the Service Let's try to send a test video to Robonomics. Go to services: "developer tools" -> "services." Find the service `Robonomics: Save recording to robonomics`. ![Service](https://hackmd.io/_uploads/Bkx_J6hHh.png) Click "choose entity" and select your camera. Then specify the path to your created "media" folder. The general path format will be `<PATH_TO_HOMEASSISTANT_FOLDER>/.homeassistant/media`. - For our image, the path is: `/home/homeassistant/.homeassistant/media`. - For HAOS: `/media/` You can also set the camera recording time (default is 10 seconds). The final configuration looks like this: ![Service Configuration](https://hackmd.io/_uploads/BJWlI63Sn.png) Call the service and wait for some time until you see a green checkmark. It indicates that the service has been called, and recording and sending to Robonomics have started. ## Dapp To view the received video, go to our [DApp](https://vol4tim.github.io/videostream/). ![DApp](https://hackmd.io/_uploads/SyX7Dphr3.png) Insert the address of your controller and press the button. Wait for the twins to be found. In the end, you get an IPFS hash with all recorded videos. ![IPFS Hash](https://hackmd.io/_uploads/ry03_63S2.png) Then select the controller account from the dropdown list and sign the message with it to authorize in the web3 IPFS gateway and download all the videos. In the end, you can see all the videos recorded by your smart home. ![Videos](https://hackmd.io/_uploads/BJqWYphr3.png) Since all videos in the folder are encrypted with the controller's key, you need to insert it for decryption. After that, the play button activates, and clicking it downloads the video, making it available for playback.