azogue / hass_config

My personal Home-Assistant configuration for my home.
MIT License
17 stars 3 forks source link

Escam Qf100 Configuration #1

Closed biejay closed 7 years ago

biejay commented 7 years ago

Hey dude i can't get my Escam qf100 working. Neither with HASS nor motioneye. Could you pls send me your config url or what you choose to get it streaming?

thanks a lot!

EDIT: By now, i got the stream in my motioneye working. But now: Wtf, where is the streaming URL from Motioneye?:D I can't find any anywhere?! What do i have to write into the HASS Conf.?

EDIT: Next and hopefully last question: Could you connect multiple devices to the Qf100? For me, its always just one. So i would like to stream it via motioneye but also use the ffmepg-binary-sensor-motion in HASS. Because its seems faster for me. Is this possivle or how are you doing it?

azogue commented 7 years ago

Sorry @biejay, I didn't see your msg (perhaps because you didn't mention me?)

I have binary_sensors reflecting the motion detection of cams handled by MotionEye, but it's something 'hacky', I hope could be of any help. I notice that you're talking about a 'qf100' model, mine is a QF001, so I don't know if the URLs are the same.

But first things first:

MotionEye config for the ESCAM QF001 (thread-X.conf):

My 'secrets' are between brackets

# @webcam_resolution 100
# @upload_subfolders on
# @upload_server
# @enabled on
# @network_server
# @motion_detection on
# @upload_port
# @upload_location motioneye
# @preserve_movies 0
# @network_username
# @upload_movie on
# @id 1
# @upload_password
# @upload_method post
# @upload_picture on
# @working_schedule_type outside
# @network_password
# @upload_service dropbox
# @name ESCAM QF001
# @preserve_pictures 1
# @storage_device custom-path
# @network_share_name
# @upload_enabled on
# @webcam_server_resize off
# @working_schedule
# @upload_username

ffmpeg_output_movies off
height 480
netcam_userpass [CAM_USER]:[CAM_PASSWD]
stream_quality 85
threshold 7500
quality 85
noise_level 50
ffmpeg_output_debug_movies off
smart_mask_speed 0
pre_capture 1
noise_tune on
stream_maxrate 5
output_pictures on
stream_localhost off
ffmpeg_variable_bitrate 75
ffmpeg_video_codec mp4
text_changes on
movie_filename %Y-%m-%d/ESCAM_%H-%M-%S
auto_brightness off
stream_port 8081
rotate 0
stream_auth_method 1
lightswitch 0
framerate 5
emulate_motion off
snapshot_filename
despeckle_filter
snapshot_interval 0
minimum_motion_frames 5
stream_motion off
target_dir /var/lib/motioneye/Camera1
netcam_url rtsp://[CAMERA_IP]:554/user=[CAM_USER]&password=[CAM_PASSWD]&channel=1&stream=1.sdp?
text_double on
width 640
post_capture 1
stream_authentication [MEYE_USER]:[MEYE_PASSWD]
output_debug_pictures off
on_picture_save /usr/local/lib/python2.7/dist-packages/motioneye/scripts/relayevent.sh "/etc/motioneye/motioneye.conf" picture_save %t %f
on_movie_end /usr/local/lib/python2.7/dist-packages/motioneye/scripts/relayevent.sh "/etc/motioneye/motioneye.conf" movie_end %t %f
text_left
picture_filename %Y-%m-%d/ESCAM_%H-%M-%S
locate_motion_style redbox
locate_motion_mode on
netcam_keepalive off
max_movie_time 0
on_event_end /usr/local/lib/python2.7/dist-packages/motioneye/scripts/relayevent.sh "/etc/motioneye/motioneye.conf" stop %t; curl -X POST -H "x-ha-access: [HAPASSWD]" -H "Content-Type: application/json" -d '{"state": "off", "attributes": {"device_class": "motion", "friendly_name": "Vídeo-Mov. en Salón", "homebridge_hidden": "true"}}' [HA_URL]/api/states/binary_sensor.motioncam_salon
text_right %Y-%m-%d\n%T
on_event_start /usr/local/lib/python2.7/dist-packages/motioneye/scripts/relayevent.sh "/etc/motioneye/motioneye.conf" start %t; curl -X POST -H "x-ha-access: [HAPASSWD]" -H "Content-Type: application/json" -d '{"state": "on", "attributes": {"device_class": "motion", "friendly_name": "Vídeo-Mov. en Salón", "homebridge_hidden": "true"}}' [HA_URL]/api/states/binary_sensor.motioncam_salon
event_gap 3
netcam_tolerant_check on
mask_file
on_camera_lost curl -X POST -H "x-ha-access: [HAPASSWD]" -H "Content-Type: application/json" -d '{"state": "on", "attributes": {"device_class": "motion", "friendly_name": "Vídeo-Mov. en Salón", "homebridge_hidden": "true"}}' [HA_URL]/api/states/binary_sensor.motioncam_salon
on_camera_found curl -X POST -H "x-ha-access: [HAPASSWD]" -H "Content-Type: application/json" -d '{"state": "off", "attributes": {"device_class": "motion", "friendly_name": "Vídeo-Mov. en Salón", "homebridge_hidden": "true"}}' [HA_URL]/api/states/binary_sensor.motioncam_salon

I suppose the URL you're looking for is: rtsp://[CAMERA_IP]:554/user=[CAM_USER]&password=[CAM_PASSWD]&channel=1&stream=1.sdp? To obtain the user and password first I had to use the typical app to access these cams and configure it.

As you can see, I'm doing motion detection in MotionEye and publishing the changes in a binary_sensor.motioncam_salon in Home Assistant. It works seamlessly with on_event_start and on_event_end events. Problem is the current frontend of MotionEye don't show all of these fields, so these you have to edit manually, and if something is changed and saved in the frontend, you will need to re-write (I have a python script to check the config and do the changes automatically at reboot with a CRON task).

Home Assistant configuration:

When MotionEye is working, copy the snapshot URL for the escam, and append a generic camera in Home Assistant, like I do here:

# MOTIONEYE CAMERAS
camera:
  # ESCAM QF001 cheap chinese cam (as still images - generic, or mjpeg stream)
  - platform: generic
    name: ESCAM QF001
    still_image_url: [MOTIONEYE_URL]/picture/1/current/?_username=[MEYE_USER]&_signature=[MEYE_SIGNATURE_USER_CAM]

About the multiple access and the ffmepg-binary-sensor

I think there are 2 streaming channels only, and one is lowRes. I only use one for MotionEye, and I can connect to the MotionEye stream (not the camera stream) from many devices simultaneously (don't know how many, but at least 2 or 3).

I hadn't got the time to try the new ffmepg-binary-sensor, so I can't help you there, but you could try my solution, using MotionEye motion detection. I have to say that in my config, MEye is running in a RPI2, analysing 2 video streams, and also runs a Home Assistant instance, but is a slave one. The master instance of the home automation (a RPI3) doesn't run Home Assistant (instead it has a PI Camera attached, but I'm not doing motion detection there yet)

biejay commented 7 years ago

Awesome! Thank for very much for this precise answer!

I got my Motioneye running together with HASS, getting the binary sensor activated by motioneye etc.! Really nice!

But still, its not perfect :D

The latency between the camera(actual happenings) and the video on both, motioneye and HASS is really big. Something like 30sec or so?! Is this the same for you?

and also: i can't see the still_image, cause i always get {"prompt": false, "error": "unauthorized"} when i surf to

http://IPOfPI:8765/picture/1/current/?_username=MYUSERNAME&_signature=1

Can i add the password somehow?

Thanks again, you are awesome! 👍

azogue commented 7 years ago

Hi @biejay,

For me, the latency of the MotionEye cams is about 2 sec, I think is a very good latency for a RPI2 processing 2 video streams. Are you using the optimal 'motion' binary? I remember there were multiple options to select/download/compile the best motion executable (in the motioneye wiki). 30 secs latency looks like something is not ok. Do you have this long delay in the MotionEye frontend??, The camera has a good connection? When you connect to the camera stream (with VLC, for example) do you have a good bandwidth and short latency?

In addition, to tune the motion detection in motioneye for each camera, you have to play with the threshold, the event gap and the number of motion frames needed to recognize motion, I think the parameters (in the thread-X.conf file) are:

threshold 7500
framerate 5
minimum_motion_frames 5
event_gap 3

About the 'unauthorized' problem, looks like the motioneye snapshot url is not good. Your signature can't be just 1. Mine is a 40-chars long hexadecimal code, unique for each camera. Did you copy it from the motioneye frontend?

biejay commented 7 years ago

Okay i got about 2sec latency with vlc and with the app. (Btw, the app shows me a 16chars long hexadecimal code, but this also doesnt work with the URL to authenticate) I'm running two Pi's, both running HASS connected via MQTT-Eventstream for communicating DHT-Sensors, Pir-Sensors, 433mhz transmitter and thats it mostly for the 2nd pi. When i stop HASS, the latency drops to at least 4-5 secs. So it seams to be HASS, that is triggering the latency. But i'm having two Pi3, is HASS really sucking that much computing power?

azogue commented 7 years ago

NO, Home Assistant is not a resource burner, you need to check your configs and your systems, and watch the CPU and memory usage and so on. Are you using the ffmpeg-camera component of HA in the same RPI which is running MotionEye with motion? If that is the case, that's your problem.

About the MotionEye config, I'm running v.0.35.1, with motion v4.0.1. In the frontend, inside the 'Video Streaming' section, there are three links ('Useful URLs'). The first, 'Snapshot URL', is the url you need to append the video stream to HA as a generic cam, and it has this structure: URL_MOTIONEYE/picture/1/current/?_username=USER&_signature=6d403f45fb6050467522e2274c34ee92f67f096a

My CPU usage in a RPI2 processing 2 video streams AND running Home Assistant with a few sensors (it's not the main HA machine) is ~25 %.

kozfelipe commented 1 year ago

So in order to get QF100's motion detection feature enabled to my home assistant I need an intermediary application such as MotionEye running on hardware other than HA's host? No way I could get motion detection directly from the camera? @biejay @azogue

azogue commented 1 year ago

So in order to get QF100's motion detection feature enabled to my home assistant I need an intermediary application such as MotionEye running on hardware other than HA's host? No way I could get motion detection directly from the camera? @biejay @azogue

Hi @kozfelipe,

This repo is archived and this issue is from 6 years ago 😅.

Maybe this is not the best place to search for this info 😂 The HA forum is for sure a better place 👌

Anyway, my old qf100 camera is still working and in use at home (it has ethernet + PTZ + 2 rtsp stable streams), but these days I'm running frigate to process people & object detection on multiple streams. I wouldn't use MotionEye for that.