My boring Blog

Mauro Frigerio blog

Watch camera from secondary home in Home Assistant

20-10-2021 2 min read Article

I wrote a post not long time ago about managing my secondary home with Home Assistant. Thanks to component the magic is possible, but an HA update has complicated things a bit. A few days ago there was the problem that the component could no longer connect with remote instances and since always (for me) it is not possible to view remote rooms.

Remote instances connection problem

The first case can be solved by updating the component to the latest version (> 3.4 or master) and install it also in remote instances. Moreover in the remote instances you have to add 2 simple lines to the configuration:

remote_homeassistant:
  instances:

Details can be found in the issue on GitHub.

View camera of a remote instance

According to a bug reported on GitHub for a long time remote cameras are not visible in the main instance. It wasn’t an urgent problem for me, but sooner or later I wanted to fix the situation even with a DIY solution. So I got around the problem.

Requirement/Information

The webcam is accessible via the network from the main instance of Home Assistant. In my case I use a Tapo C200 which has an rtsp stream.

Shell command

First of all you have to download the image from the remote instance using the HA API. This allows you to display an image when you open the page in Lovelance.

In the configuration of the main instance add:

shell_command:
  take_camera_picture: 'curl -X GET -H "Authorization: Bearer ABCDEF" -H "Content-Type: application/json" https://example.com/api/camera_proxy/camera.your_camera_name -o ./www/image.jpg'

Replace the address with that of the remote HA and camera entity. Replace ABCDEF with a permanent token.

Calling this command will save the image image.jpg in the folder /config/ww/ (create the folder if it is not present, more info).

Automation

An automation can call the shell command regularly to update the image. Example to run the command every 15 minutes.

alias: Save camera picture
description: ''
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - service: shell_command.take_camera_picture
mode: single

Generic camera

In the main instance create a generic camera that uses the automation image as a still image and stream rtsp when you want to watch the live stream.

camera:
  - platform: generic
    name: Camera RTSP
    stream_source: rtsp://user:password@1.2.3.4:554/stream2
    still_image_url: https://home.momo.casa/local/image.jpg

Replace rtsp streaming username and password, also change IP address.

I know it’s not a super elegant solution, but it works!


Photo by Pexels from Pixabay