Before a couple of days ago I was just like the people here: Help me for my ipcam Vstarcam C7837WIP and here: ieGeek IP C7837WIP cameras with Home Assistant , i.e. an owner of some impulse-buy 30$ 720p PTZ cameras that was struggling to get them working at more than the basic level of MJPEG in HA.
First of all, I managed to get ONVIF working, with this configuration.yaml entry:
ffmpeg:
camera:
- platform: onvif
host: X.X.X.X:10080/tcp/av0_0
name: 'living_room'
username: admin
password: XXXXXXX
The 10080 ONVIF port is standard on these cameras, however you also need to first find (use nmap with a full TCP port scan on your cameraâs IP address) the web port, then enter the cameraâs web UI, then set its networking to static IP. This will ensure that whatever crazy web port it uses will stay the same, otherwise at every restart or DHCP IP change, it will also get a new web port.
With that out of the way, the next challenge was goddamn PTZ. I would have expected the HA ONVIF componentâs PTZ support to work, but it most certainly did not (I remember reading somewhere that these particular cameras give back crappy http headers, which donât work with the existing ONVIF PTZ component in HA).
Thus, I went for the agricultural approach and entered the camera web UI in Chrome, opened Chrome Dev Tools, went to the Network tab, set a position preset in the web UI and looked at what http request came out when I pressed the preset button in the web UI.
After cleaning it up a bit, the request looked like this: http://YOUR_IP:YOURCAMERWEBPORT/decoder_control.cgi?loginuse=YOURUSER&loginpas=YOURPASS&command=35&onestep=0
Then I used the REST component in configuration.yaml:
rest_command:
living_room_camera_room_view:
url: http://YOUR_IP:YOURCAMERWEBPORT/decoder_control.cgi?loginuse=YOURUSER&loginpas=YOURPASS&command=35&onestep=0
Then I restarted HA.
Then I created a script that looked like this:
living_room_camera_room_view:
alias: Living Room Camera Room View
sequence:
- service: rest_command.living_room_camera_room_view
Then I created a Lovelace card with the camera as background and this (and other) buttons) overlaid on it:
- cards:
- camera_image: camera.living_room
entities:
- entity: script.living_room_camera_up
icon: 'mdi:arrow-up-bold-box'
- entity: script.living_room_camera_down
icon: 'mdi:arrow-down-bold-box'
- entity: script.living_room_camera_left
icon: 'mdi:arrow-left-bold-box'
- entity: script.living_room_camera_right
icon: 'mdi:arrow-right-bold-box'
- entity: script.living_room_camera_room_view
icon: 'mdi:sofa'
- entity: script.living_room_camera_back_to_wall
icon: 'mdi:wall'
title: Living Room
type: picture-glance
The other buttons I obtained via exactly the same procedure as the preset used in the living_room_camera_room_view one - you press the arrow in the cameraâs web UI, capture the HTTP request then keep clicking on it in HA to get the movement you need.
BTW, I made an automation which turns the camera towards the wall when in âHomeâ mode and towards the room when in âAwayâ mode, thus hopefully mitigating any hacking (while at home) issue, as the camera would physically have to be pointed in my face to be able to see anything other than the wall
Hope this helps someone!