MotionEye config

I still have the same problem after adding the full path.

Shinobi looks pretty cool. Uses FFMPEG, which HA clearly supports. And that video is adorable. Not sure if it will run on a Pi though. That’s kind of my own fault. I need a grown-up computer.

OK. I had to reboot MotionEye for some reason because the MJPEG stream started messing up as well. Now the motion sensor works and I have my first working automation:

 - action:
   - alias: light.studio
     data:
     entity_id: light.studio
     service: light.turn_on
     alias: Turn on light when I enter studio
     id: '1499546682238'
   trigger:
   - entity_id: binary_sensor.studio_motion
     from: 'off'
     platform: state
     to: 'on'

MotionEye can do that out of the box:

image

1 Like

so what do i need for a command or webhook to send to google homeassistant text to speech alert? i have motioneyeos on a raspberry pi 2, i might just install motioneye on top of stretch with pihole though or something, but i also run another raspberry pi 3 with hassbian.

You can use the mqtt example from above. Then create an automation that reacts on that Change.

###MOTIONEYEOS CONFIG###
motion notifications run command:

curl -X POST -H "x-ha-access: PASSWORD" \
    -H "Content-Type: application/json" \
    -d '{"state": "on", "attributes": {"friendly_name": "downstairscam"}}' \
    http://remoteipaddress:8123/api/states/binary_sensor.downstairscam

motion notifications end command:

curl -X POST -H "x-ha-access: PASSWORD" \
    -H "Content-Type: application/json" \
    -d '{"state": "off", "attributes": {"friendly_name": "downstairscam"}}' \
    http://remoteipaddress:8123/api/states/binary_sensor.downstairscam

Of course i did it for both cams!
###HASS CONFIG####

Make sure and use the user login for motioneyeos not the admin
configuration.yaml:

camera :
  - platform: mjpeg
    name: UpstairsCamera
    mjpeg_url: http://camipaddress:8081
    username: username
    password: password

  - platform: mjpeg
    name: DownstairsCamera
    mjpeg_url: http://camipaddress:8082
    username: uername
    password: password

binary_sensor:
 - platform: mqtt
   name: "UpstairsCam"
   state_topic: "cameras/UpstairsCamera/motion"

 - platform: mqtt
   name: "DownstairsCam"
   state_topic: "cameras/DownstairsCamera/motion"

automation.yaml

- action:
  - data:
      entity_id: media_player.something_group
      message: Intruder Alert Downstairs!
    service: tts.google_say
  alias: motion downstairs
  condition: []
  id: '########'
  trigger:
  - entity_id: binary_sensor.downstairscam
    platform: state
    to: 'on'
- action:
  - data:
      entity_id: media_player.something_group
      message: Intruder Alert Upstairs!
    service: tts.google_say
  alias: motion upstairs
  condition: []
  id: '########'
  trigger:
  - entity_id: binary_sensor.upstairscam
    platform: state
    to: 'on'

thanks for all the help people!!

1 Like

i get invalid authentication request i i set password. i have special characters like % in it.

1 Like
curl -X POST -H --data-urlencode passwd=SPECIALPASSWORD \
    -H "Content-Type: application/json" \
    -d '{"state": "off", "attributes": {"friendly_name": "downstairscam"}}' \
    http://remoteipaddress:8123/api/states/binary_sensor.downstairscam
curl -X POST -H --data-urlencode passwd=SPECIALPASSWORD "x-ha-access: " \
    -H "Content-Type: application/json" \
    -d '{"state": "off", "attributes": {"friendly_name": "downstairscam"}}' \
    http://remoteipaddress:8123/api/states/binary_sensor.downstairscam
curl -X POST -H --data-urlencode  "x-ha-access: PASSWORD" \
    -H "Content-Type: application/json" \
    -d '{"state": "off", "attributes": {"friendly_name": "downstairscam"}}' \
    http://remoteipaddress:8123/api/states/binary_sensor.downstairscam

something like that maybe?

Let me try and give feedback… Thanks so far

unfortunately nothing of thisworked for me… authentication error… i might change the password?

hmmm idk that should work, strange. but yeah changing the password would definitely work.

How would the curl be called without password? I’ll remove it as hass is not exposed to the internet

PASSWORD

 curl -X POST -H --data-urlencode  "x-ha-access: PASSWORD" \
     -H "Content-Type: application/json" \
     -d '{"state": "off", "attributes": {"friendly_name": "downstairscam"}}' \
     http://remoteipaddress:8123/api/states/binary_sensor.downstairscam

NO PASSWORD:

curl -X POST -H --data-urlencode  "x-ha-access: " \
     -H "Content-Type: application/json" \
     -d '{"state": "off", "attributes": {"friendly_name": "downstairscam"}}' \
     http://remoteipaddress:8123/api/states/binary_sensor.downstairscam

NO DATA URLENCODE:

curl -X POST -H  "x-ha-access: " \
     -H "Content-Type: application/json" \
     -d '{"state": "off", "attributes": {"friendly_name": "downstairscam"}}' \
     http://remoteipaddress:8123/api/states/binary_sensor.downstairscam

i get an error when using requests with python to the resfulapi {"message":"invalid JSON specified"}, have you run into that issue before? i’m only asking because it appears youve been a member since 2016, where i have less time with home assistant!FIXED it was an issue with my python script not having the json values in quotes.

hey… ialready ran such a curl command but in another epoche :slight_smile: I am actually starting from scratch with my new intel NUC as my pi and setup seems a bit let’s say : Overkilled and played-to death :slight_smile: I will try your suggestion and will revert to you as soon as my system is running up again.

Cool i also do basically the same thing with a pir sensor connected to a raspberry pi.
configuration.yaml:

 binary_sensor:
     - platform: mqtt
       name: "MotionSensor"
       state_topic: “movement/motionsensor/motion”

python script: REVISED

import RPi.GPIO as GPIO
import time
import requests


GPIO.setmode(GPIO.BCM)

GPIO.setup(pinnumber, GPIO.IN) #PIR
#GPIO.setup(24, GPIO.OUT) #BUzzer
url = 'http://ipaddress:8123/api/states/binary_sensor.motionsensor'
headers = {'x-ha-access': 'password', 'content-type': 'application/json'}
data = '{"state": "on", "attributes": {"friendly_name": "MotionSensor"}}'

url1 = 'http://ipaddress:8123/api/states/binary_sensor.motionsensor'
headers1 = {'x-ha-access': 'password', 'content-type': 'application/json'}
data1 = '{"state": "off", "attributes": {"friendly_name": "MotionSensor"}}'
def sensor():
  try:
    time.sleep(2) # to stabilize sensor
    while True:
        if GPIO.input(pinnumber):
            #GPIO.output(24, True)
            #time.sleep(0.5) #Buzzer turns on for 0.5 sec
            #GPIO.output(24, False)
            #print("Motion Detected...")
            #localtime = time.asctime( time.localtime(time.time()) )
            #print(localtime)
            response = requests.post(url, headers=headers, data=data)
            #print(response.text)
            time.sleep(5) #to avoid multiple detection
            response1 = requests.post(url1, headers=headers1, data=data1)
            #print(response1.text)

        time.sleep(0.1) #loop delay, should be less than detection delay

  except:
    GPIO.cleanup()
    sensor()
sensor()

chmod +x script.py
i do a an autostart using sudo nano ~/.config/lxsession/LXDE-pi/autostart
then add @sudo python script.py at the bottom of the file.

Also check this out:

I was actually thinking of creating a motioneye component as part of my youtube Home Assistant channel (only 1 video as only started a few days ago).

I too use MotionEye and am sure there can be better/more ways to integrate than just having the cameras display (like I normally do).

Are there many users of Motioneye on here or do most people seem to stick with ZoneMinder?

John

i myself havent used zoneminder, but adding other components to motioneye rather than only cameras would be fantastic. im still trying to work on my script for my pir sensor so that it has a schedule too.

I must admit, I’ve tried Zoneminder, and the only thing I can say that I like over Motioneye was the ability to create zoned areas so that motion detection wasn’t even applied to certain parts of the images (property that you don’t own etc). There were, however more disadvantages than advantages in my option and so I switched back to Motioneye but obviously I am stuck with the same restriction of viewing cameras the same as everyone else.

have you tried anything like opencv or simple cv? that would also be great to integrate into motioneyeos.

this is installed as a python virtual environment so any system running python3 or 2.7 would work. You can also use this to access cameras remotely(since it currently isnt implemented into motioneyeos, that i know, of). So with that said even just integrating it into hassbian would be GREAT!! i mean then we could almost bypass motioneyeos all together :stuck_out_tongue:

I use motioneyeos

1 Like