Motioneye: Turn detection on / off from Home Assistant

Hi all,

can anybody tell me if it is possible to turn on / off the motion detection in motioneye from outside (i.e. Home Assistant)?

I intend to call a webhook and then create actions in HA / Node-RED when a motion is detected. But recording will of course still hapen in motioneye and I only want to record when the HA alarm is active. So I would need a way to enable / disable the motion detection or recording in motioneye from HA.

Thanks for any ideas!

After a more intensive Google search, I found somebody doing exactly this in domotics using motioneyes HTTP REST API.

https://www.domoticz.com/forum/viewtopic.php?t=22436
http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpAPI

I think this will do the job. Just wanted to let everybody know who might want to achieve the same.

You could use a switch in HASS to toggle the motion sensor in motion (and not in motioneye):

  - platform: command_line
    switches:
      camera_44:
        command_on: 'curl -k "http://192.168.2.204:7999/2/detection/start"'
        command_off: 'curl -k "http://192.168.2.204:7999/2/detection/pause"'
        command_state: 'curl -s "http://192.168.2.204:7999/2/detection/status"'
        value_template: '{{ "ACTIVE" in value }}'
        friendly_name: Motion Sensor Camera 44

Explained here!

2 Likes

Cool, thank you. Will definitely try that.

I know this threads old and answered, but where should this go in HA please?

A couple of monutes after asking, I got it working. :person_facepalming:

switch:
 - platform: command_line
   switches:
     camera_44:
       command_on: 'curl -k "http://192.168.5.5:7999/2/detection/start"'
       command_off: 'curl -k "http://192.168.5.5:7999/2/detection/pause"'
       command_state: 'curl -s "http://192.168.5.5:7999/2/detection/status"'
       value_template: '{{ "ACTIVE" in value }}'
       friendly_name: Motion sensor garden camera

…in configuration.yaml

and then I find it’s already got a switch under the cameras configuration :smile: