A simple script to update motion state in Homeassistant via MQTT
Its meant to be used by motioneye
Install on a Raspberry Pi running motioneyeos
curl https://github.com/manzari/message-hass-motioneyeos/releases/latest/download/message-hass --output /data/message-hass \
&& chmod +x /data/message-hass
env GOOS=linux GOARCH=arm GOARM=5 \
go build -o ./build/message-hass
./build/updatemqttmotion
to motioneyeos /data/updatemqttmotion
chmod +x /data/updatemqttmotion
/data/updatemqttmotion
Edit the file /data/etc/hass.json
to suit your needs
{
"Host": "192.168.178.33:1883",
"User": "user",
"Pass": "70p53cr37",
"Dump": false,
"Retain": false,
"BaseTopic": "homeassistant",
"Cameras": [
{
"DeviceName": "entrance_camera_motion",
"DeiceFriendlyName": "Entrance Motion",
"DeviceClass": "motion"
}
],
"AutoConfig": true
}
Motion Notifications
tabbash -c "/data/updatemqttmotion ON"
into the field Run A Command
bash -c "/data/updatemqttmotion OFF"
into the field Run An End Command
bash -c "/data/updatemqttmotion -cam=1 ON"
into the field Run A Command
bash -c "/data/updatemqttmotion -cam=1 OFF"
into the field Run An End Command