Motioneye integration

No idea how to use curl, I run on HASSIO

I assume you mean HASSOS. Hassio no longer exists.

Presumably uoi have a computer other than your home assistant? curl is cross platform. Otherwise ssh into your hassos.

yes, that is right, what to do next?

I’m using the Core MotionEye integration. Occasionally when switches for Motion Detection or movies are toggled they switch back to the previous state in 30-60s. A few others have noticed the same thing in this thread but no solution is noted.

Has anyone fixed this issue?
Is this issue present in the more featured rich HACS custom integration?

I have the same problems sometimes the detection goes “ACTIVE” and motioneye starts the recording…

Is possible solve it?

I recently started using motionEye and I just wanted to understand if there was a reason everyone seems to still be opting to use input booleans and automations when there is now a method to have template binary sensors turn on via an event? I’ve set up the below via the motionEye integration and it is working perfectly for me - No need for any automations, just a template binary sensor…

template:
  - binary_sensor:
      name: HiLook Driveway Motion (motionEye)
      state: "true"
      device_class: motion
      auto_off: 10
    
    trigger:
      platform: event
      event_type: motioneye.motion_detected
      event_data:
        device_id: abcdefghijklmnop1234567

Hopefully this helps someone in the future or someone will come along and tell me why people haven’t opted for this method :wink:

EDIT: I’m aware that this functionality was only introduced in 2021.5 so the original guide was valid at the time of writing, just curious why people have not moved over to this method since then.

6 Likes

That’s a brilliant solution! I spent last three night to understand why motioneye doesn’t send mqtt commands. Now I changed to this approach and everything works flawlessy.

1 Like

I’m glad I could help! :smiley:

I couldn’t make it work having the binary_sensor following the template header.

template:
  - trigger:
      - platform: event
        event_type: motioneye.motion_detected
        event_data:
          device_id: !secret garage_camera_id

    binary_sensor:
      - name: Garage Motion
        auto_off: 10
        state: "true"
        device_class: motion

Just for completeness, as it took me ages to get it to work. device_id can be copied either from the end of the Web Hook URL in motioneye > Motion notification. That’s provided you’ve used the HA UI integration approach (i.e. not yaml integration).

Or you’ll find the device_id under the configured integrations, once added into HA. Look to the URL of your home assistant i.e. https://myhomeassistant.xyz:8123/config/devices/device/deviceid

Hope it helps.

That’s odd, I can’t see why having trigger or binary_sensor first would make a difference :thinking: Glad the swap fixed it though!
Apologies, I actually posted the info on the device_id on another thread but didn’t include the same information here :man_facepalming:

1 Like

That’s all good. The more info on this the better. Whilst searching for a solution, I really couldn’t find much up-to-date information on Motioneye by using the front-end integration.

Just as an aside, did you manage to split up the binary sensor config in your configuration.yaml, if you do split your files? I’ve tried several approaches and can’t get past the validator.

I’ve managed to split it with no issues - I’ve done the following:
configuration.yaml:

...
template: !include_dir_list templates/
...

Within the templates directory I have a folder for each template type eg. templates/binary_sensors and templates/sensors/ and then within those folders I have the templates in individual files - Using the Motioneye binary sensor as an example: templates/binary_sensors/driveway_motion.yaml and that file looks like my example above without template: at the top level ie.

binary_sensor:
  name: Driveway Motion (motionEye)
  state: "true"
  device_class: motion
  auto_off: 10

trigger:
  platform: event
  event_type: motioneye.motion_detected
  event_data:
    device_id: abcdefg12345
2 Likes

That does work! :wink: :partying_face:

I so wish this was better documented. I can’t be the only one struggling with this. Thank you for your help!

Really? Splitting up the configuration - Home Assistant

1 Like

I’m not sure if this will help anyone here, but I read in a post (Reddit I think) that you need to put a mask over the time/date stamp on the cameras for motion detection not to continuously detected as this can break the webhook and motion will not be reported properly in HA. I have done this with a notification automation and seems to work quite well.

Michael

I’ve exposed the web port of the MotionEye addon.

Once i deleted all my Motion eye integrations in HomeAssistant and then added one back pointing at that open port, it appears that events stopped triggering from the integrations.

All this is to try and get public url from “motioneye.file_stored” event so that i can get images into a homeassistant companion app notification. I’m not sure if this avenue makes sense but it’s the only way i can see to have the event correspond to data that is useful in a notification. (images need to be accessible from the internet from what i can tell)

I you are using the addon. you don’t need to expose anything for push notifications to work…

The trick is to use the correct paths…

alias: Front DoorBell Notify when activated
description: send
trigger:
  - platform: state
    to: "on"
    entity_id: binary_sensor.doorbell_button
    from: "off"
condition: []
  - entity_id: camera.doorcam
    data:
      filename: "{{ snapshot_create_file_path }}"
    action: camera.snapshot
  - action: notify.mobile_app_aceindy
    metadata: {}
    data:
      message: "{{ notification_title }}"
      title: "{{ notification_message }}"
      data: >-
        {% set android_data = {"image": "%s"} |
        format(snapshot_access_file_path) %} {% set ios_data = {"attachment":
        {"url": "%s", "content_type": "JPEG"}} |
        format(snapshot_access_file_path) %} {{ ios_data if is_ios else
        android_data }}
    alias: Send to Ace
variables:
  is_ios: true
  notification_title: The Doorbell was activated!
  notification_message: "{{ binary_sensor_name }} was activated!"
  snapshot_create_file_path: /config/www/tmp/snapshot_{{ states[camera].object_id }}.jpg
  snapshot_access_file_path: "{{ snapshot_create_file_path | replace('/config/www','/local') }}"
mode: single

As you can see, the snapshot_create_file_path is different from the snapshot_access_file_path :smiley:
One uses ‘/config/www’/, the other ‘//local’
Also note that IOS and Android require a different format to be able to show the snapshot :wink:

Thank you! I was losing it, my first time doing something myself in home assistant that isn’t gui based. I happened to have the same idea before i saw your post and went with the below. It looks like it’s doing something very similar. I honestly didn’t have high hopes that someone would have tried to help already, thank you again.

alias: Notify when Motion Detected
description: ""
trigger:
  - platform: event
    event_type: motioneye.file_stored
    event_data:
      file_type: "1"
condition: []
action:
  - service: notify.mobile_app_pixel_8a
    data:
      message: Motion Detected!
      data:
        image: >
          {% set path_parts = trigger.event.data.file_path.split('/') %}
          {{ "/media/local/motioneye/" + path_parts[-3] + "/" + path_parts[-2] + "/" + path_parts[-1] }}
mode: single

No problem @Esoteric ,

Mine actually originates from a blueprint (can’t remember which one, it is just that i resent blueprints)

And your images seem to originate from motioneye itself, while mine just takes a snapshot from within HA (could be any camera)

I am not sure if the share folder used by motioneye is useable to send notifications, i have the somewhere in the back of my mind it has to be the www folder :thinking: