Sure, but I need to explain how it works, there are a lot of configuration files involved (I don’t use packages)
There’s no Lovelace here !
So I have several cameras, all of them have the same logic, I’ll give the yaml code for the one upstairs that I got the screenshot from :
- I’ve been using zoneminder for years, so I integrated the existing configuration. That probably was my first HA component !
- There’s one device tracker per camera, based on the arp table in my firewall. Tells me if it’s still there !
- zoneminder gives two sensors and a switch per camera : sensor._events, the number of motion recorded and sensor._status that tells the way the camera works : monitoring, motion detection… and switch._state to force this camera to enter a status. I’ve choosen to use monitor and motion detection, as only 2 status are possible.
- the image comes from 2 sources : the one created by zoneminder (named camera.) and I added a direct connection to the camera to show the image when zoneminder is off. I named the cameras with the same name as in zoneminder and adding “direct” : camera._direct
- customUI is used to hide what’s not needed : the number of events if it’s not important, the “direct” camera if zoneminder is on, the zoneminder camera if it’s off…
- scripts are calling a shell command, running zmcontrol.pl to move between presets. If works even when zoneminder is turned off, the great thing is that there is only one place to configure the camera’s commands.
Let’s start with the main configuration file (only relevant parts, I’ve added comments):
customize: !include config/customize.yaml
# all per-object customui in this file
customize_glob:
"*.*":
custom_ui_state_card: state-card-custom-ui
camera.*:
state_card_mode: badges
# actually, the only thing I added today to have cameras as badges. Easier to put it here to change all cameras at once, direct and zoneminder
customizer:
# customui configuration
custom_ui: local
hide_attributes:
- custom_ui_state_card
columns:
- 30
- 700
- 1500
- 2100
zoneminder:
# way to access the zoneminder server
host: !secret zm_host
username: !secret zm_user
password: !secret zm_pass
sensor.yaml: (exposes the event count and the status for each camera)
- platform: zoneminder
switch.yaml: (creates one switch per camera in zoneminder, to force the camera in motion detection or just monitoring)
- platform: zoneminder
command_on: Modect
command_off: Monitor
camera.yaml:
- platform: zoneminder
# the zoneminder cameras, names come from the zoneminder configuration
- platform: mjpeg
# example of one camera for direct access
mjpeg_url: http://192.168.7.14/videostream.cgi
still_image_url: http://192.168.7.14/snapshot.cgi
name: etage_direct
username: !secret zm_user
password: !secret zm_pass
customizer.yaml: The custom-ui options, I have this for each camera, mostly to display information as badges
device_tracker.Cam_Etage:
group:
group.cam_etage:
state_card_mode: badges
friendly_name: Camera Etage
sensor.etage_events:
state_card_mode: badges
friendly_name: Alarmes Etage
templates:
hidden: "return ((state === 'unknown') || (state <= 10));"
# don't show the badge if the server isn't ready or of there are not many events
sensor.etage_status:
state_card_mode: badges
templates:
hidden: "return (entities['switch.zmmonitor'].state === 'off'); "
# status of the camera shows only when zoneminder is running
switch.etage_state:
templates:
hidden: "return (entities['switch.zmmonitor'].state === 'off'); "
camera.etage:
templates:
hidden: "return (entities['switch.zmmonitor'].state === 'off'); "
camera.etage_direct:
templates:
hidden: "return (entities['switch.zmmonitor'].state === 'on'); "
# shown only if zoneminder is off : display the direct camera access instead of the zoneminder source
Last thing is to create a group for each camera, that has all items in the proper order. Note that this group doesn’t show, I add it to some other group to place it where needed :
cam_etage:
view: no
name: Camera Etage
control: hidden
entities:
- device_tracker.Cam_Etage
- sensor.etage_events
- sensor.etage_status
- camera.etage
- camera.etage_direct
- switch.etage_state
- script.ptz_escalier
- script.ptz_chambre
- script.ptz_pallier
- script.ptz_bureau
- script.ptz_chambres
Of course, if you don’t use zoneminder, there are not so many things to do !