i get invalid authentication request i i set password. i have special characters like % in it.
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 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 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
I use motioneyeos
I have used ZoneMinder for the last 2 years and am happy with it for my purposes. I have not used MotionEye.
Please help troubleshooting mosquitto problem, I’m using Hassio and MotionEye in Docker from here:
Binary sensor working if triggered manually from HA or from terminal, but when setting commands in “Motion Notification” nothing happenes, also tried with /usr/bin/mosquitto_pub
commands:
mosquitto_pub -h 10.0.0.10 -t cameras/1/motion -m ON
mosquitto_pub -h 10.0.0.10 -t cameras/1/motion -m OFF
configuration.yaml:
mqtt:
broker: 10.0.0.10
port: 1883
binary_sensor:
- platform: mqtt
name: "Motion"
state_topic: "cameras/1/motion"
payload_on: "ON"
payload_off: "OFF"
device_class: "motion"
Either command not sent because mosquitto_pub not found, or it’s sent but not received because network configuration, is there log I can check?
SOLVED: mosquitto-clients package was missing in docker
I tried all of you approaches, but nothing works… there’s nothing being published on the topic althought there’s motion and the camera is recording…
any help?
hey there, I have the same setup as you (hassio, motioneye in a seperate docker) and am also trying to get the MQTT notifications to work.
I already installed the client inside the motioneye docker container, but I cannot get it to publish messages.
mosquitto_pub -h 192.168.XXX.XXX -u XX -P XX -t cameras/XIAOFANG/motion -m ON
I subscribed to the topic in one terminal window, publish to that topic in another one with the command from motioneye interface, works perfect. When I send the same command via motion activation or from the motion docker shell: nothing.
Am I missing something?
edit: I maybe should add: my binary sensor for that topic is working fine with the “manual” publishes
edit2: i did get it to work with the curl scripts, but i would rather go the MQTT way to be honest…
Hi , i want to try motionEye + MQTT. What camera I need?
mosquitto_pub -h 192.168.XXX.XXX -u XX -P XX -t cameras/XIAOFANG/motion -m ON
works like a charm HassOS