I use MotionEye installed in docker and currently integrating it with HA, what I got so far:
Video stream:
In MotionEye enable “video streaming” and you get MJPEG stream in port 8081 which you can set as camera component in HA or better set as “picture-glance” in Lovelace-UI and you’ll get live stream on frontend and because it’s not component it will not give connection errors like cameras usually do
Motion sensor:
In HA create binary sensor then in MotionEye enable “motion detection” and in “motion notifications” put two commands:
Run A Command:
curl -X POST -H “x-ha-access: PASSWORD” -H “Content-Type: application/json” -d ‘{“state”: “on”, “attributes”: {“friendly_name”: “Motion”,“device_class”: “motion”}}’ http://IP:8123/api/states/binary_sensor.motion
Run An End Command
curl -X POST -H “x-ha-access: PASSWORD” -H “Content-Type: application/json” -d ‘{“state”: “off”, “attributes”: {“friendly_name”: “Motion”,“device_class”: “motion”}}’ http://IP:8123/api/states/binary_sensor.motion
Switches (work in progress)
To send commands from HA to MotionEye need to enable API (default port 7999), find “motioneye.conf” and “motion.conf” files and edit these lines:
motioneye.conf:
motion_control_localhost false
motion.conf:
webcontrol_parms 1
webcontrol_localhost off
in HA:
command_shell:
start_motion_detect: “curl http://IP:7999/1/detection/start”
pause_motion_detect: “curl http://IP:7999/1/detection/pause”
Until here everything works.
Problem I’m having is to get status state from this address:
http://IP:7999/1/detection/status
it returns HTML type:
<!DOCTYPE html>
<html>
<head><title>Motion 4.1</title></head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<body>
<a href=/1/detection><– back</a><br><br><b>Camera 1</b> Detection status PAUSE
</body>
</html>
and I don’t know how to extract only one word from it, what need is only last word “PAUSE”