Why can't set motion detect?

I have a usb camera,It can capture video with ffmpeg

    output="/tmp/sample.flv"
    va="-y -f alsa -i default -acodec aac "
    ffmpeg  -i /dev/video0  $va -pix_fmt yuv420p   $output

I installed motion :slight_smile:

sudo apt install motion

Set password in /etc/motion/motion.conf:

stream_auth_method 1
stream_authentication admin:123456

Start the motion:

sudo motion

I get an integration with Generic Camera for the use camera.

It works fine in overview,now i want to add a motion detect in configuration.yaml:

binary_sensor:
  - platform: ffmpeg_motion
    input: http://127.0.0.1:8081/
    name: motion detect

Restart homeassistant,the binary sensor is always unavailable!

image

127.0.0.1 is unlikely to be the proper IP, unless you are using a HA Core (pure python) installation.
Try with the actual IP of the host.

1.I am using HA Core
2.replace 127.0.0.1 with the actual IP

The motion detection function still can’t take effect.
Should i add user and passwd in ffmpeg_motion,how?I added it when to make an integration with Generic Camera!

Can you tell if http://127.0.0.1:8081/ is working out of HA?


I fill username and password,it can sign in.

Great, but ffmpeg_motion is expecting an actual video feed. It’s the integration that does the detection.
Is this what you are using: https://motion-project.github.io ? Then you’re mistaken.

2 options:

I downloaded a apk named “IP Camera Viewer_7.4.7_Apkpure.apk”,installed on my old android phone,to turn my old smartphone into a webcamera,and make integration in homeassistant’s ffmpeg_motion:

binary_sensor:
  - platform: ffmpeg_motion
    name: "android smartphone camera motion"
    input: rtsp://admin:[email protected]:8554/live

All the motion can be detected.With same way,i can’t make integration for my usb camera!Why?

Mmmm… Did you understand what I said?

2 options:

* Pass the usb cam directly to `ffmpeg_mtion`
* Use a dedicated integration;

How can pass my usb cam directly to ffmpeg_motion?

It can’t work!

  - platform: ffmpeg_motion
    input: /dev/video0
    name: motion_directly
  1. Don’t DM me
  2. Look at the doc, it’s literary there

image

I guess this should work, IF you are on HA Core or have mapped the device to the HA container.
Unlikely to work in HAOS

In my os:

lsusb | grep -i camera
Bus 001 Device 004: ID 2bdf:0284 SN0002 HIK 1080P CAMERA
ls  /dev/video*
/dev/video0  /dev/video1

I want to pass the HIK 1080P CAMERA directly to ffmpeg_motion,googled a tutorial “integrate USB local camera to home assistant”
https://www.kincony.com/forum/showthread.php?tid=1841

The main points are as below:

  1. connect with your USB camera.
  2. Enable home assistant “Advanced Mode”.
  3. “Add-ons, Backups & Supervisor” – “system” – “Host” – “Hardware” , search videox
  4. Configuration edit yaml
    camera:
  • platform: ffmpeg
    name: cam
    input: /dev/input/video0
  1. Home assistant restart
  2. Add camera to dashboard by “picture entity” card

In the youtube,

For the step3 ,i can’t find hardware to search video!

My hass info:

Version core-2023.7.3
Installation Type Home Assistant Core
Development false
Supervisor false
Docker false
User homeassistant
Virtual Environment true
Python Version 3.11.0rc2
Operating System Family Linux
Operating System Version 5.10.0-23-amd64
CPU Architecture x86_64
Timezone Asia/Hong_Kong
Configuration Directory /home/homeassistant/.homeassistant

Home Assistant Community Store

MANAGE

GitHub API ok
GitHub Content ok
GitHub Web timeout – more info
GitHub API Calls Remaining 4962
Installed Version 1.32.1
Stage running
Available Repositories 1267
Downloaded Repositories 2

Home Assistant Cloud

MANAGE

Logged In false
Reach Certificate Server ok
Reach Authentication Server ok
Reach Home Assistant Cloud ok

Dashboards

MANAGE

Dashboards 1
Resources 0
Views 1
Mode storage

Recorder

Oldest Run Start Time 17 August 2023 at 05:17
Current Run Start Time 26 August 2023 at 10:55
Estimated Database Size (MiB) 9.51 MiB
Database Engine sqlite
Database Version 3.34.1

There are only processors and memory !I can’t search device /dev/video0 or /dev/video1,so can’t add it.

I have enabled Advanced Mode.

Did you try video0 or video1 ?

In the youtube’s video,the auther can find a place to search.

“Add-ons, Backups & Supervisor” – “system” – “Host” – “Hardware” , search videox

In my homeassistant ,there is no place i can type video to search!I can search nothing!
How about in your latest version homeassistant?

I can, but I don’t run HA Core, but HA Supervised. Could be a function of Supervisor.

camera:
  - platform: ffmpeg
    name: usb camera1
    input: /dev/video0
  - platform: ffmpeg
    name: usb camera2
    input: /dev/input/video0

None of them can work!

Do a ls -l /dev/video* to check permissions

ls -al /dev/video0
crw-rw----+ 1 root video 81, 0 Aug 26 16:53 /dev/video0
ls -al /dev/video0
crw-rw----+ 1 root video 81, 0 Aug 26 16:53 /dev/video0

debian@debian:~$ sudo chmod 777 /dev/video0
debian@debian:~$ sudo chmod 777 /dev/video1
debian@debian:~$ sudo systemctl restart hass

It is no use,sitll can’t work!

add your hass user to the video group

https://wiki.debian.org/SystemGroups