This is really great @gbus! I’ve so far done everything via bash scripts and ssh calls to the camera from HA, but this will be a much better solution! I will start working on converting to this platform.
Thank you very much for sharing!
On another note, last night I found a great way to view my cameras via a Lovelace custom card that someone developed. I’ve always wanted a single pane view via the desktop to save me having to visit each camera web interface in turn, and this ticks all the boxes!
You can set an update interval in seconds (min 0.5) for the thumbnails and another for the main video so that it doesn’t consume too many resources. It also has the ability to focus on a camera that detects motion, so I’m hoping we may be able to use your MQTT integration to send messages to a topic when motion is detected, which in turn would be monitored via an MQTT sensor in HA. Looking at Rpi-Cam-MQTT I don’t think it can do this yet(?), so it would be a great feature if not.
The surveillance-card was originally released 4 months ago which had a scrollable list of cameras down the left hand side, but someone has forked that with an improved version which shows camera thumbnails along the top that resize as more are added (see my screenshot above). The forked GitHub project can be found here: https://github.com/azgooon/surveillance-card (my preferred version).
In addition to the readme notes on that page, you’ll need to edit surveillance-card.js
and remove the hat symbol (^) from this line:
} from 'https://unpkg.com/@polymer/lit-element@^0.5.2/lit-element.js?module';
So that it looks like this:
} from 'https://unpkg.com/@polymer/[email protected]/lit-element.js?module';
My yaml then looks like the following:
camera:
- platform: mjpeg
name: Cam1
mjpeg_url: http://192.168.0.10/html/cam_pic_new.php?
username: !secret cam_user
password: !secret cam_pass
- platform: mjpeg
name: Cam2
mjpeg_url: http://192.168.0.11/html/cam_pic_new.php?
username: !secret cam_user
password: !secret cam_pass
- platform: mjpeg
name: Cam3
mjpeg_url: http://192.168.0.12/html/cam_pic_new.php?
username: !secret cam_user
password: !secret cam_pass
#etc
then in ui-lovelace.yaml
I have:
resources:
- url: /local/surveillance-card.js?v=1.1
type: module
views:
- title: Cameras
icon: mdi:cctv
path: camera
panel: true
cards:
- type: custom:surveillance-card
thumb_interval: 5
update_interval: 1
cameras:
- entity: camera.cam1
- entity: camera.cam2
- entity: camera.cam3
Hope this helps others too!