A simple script to update motion state in Homeassistant via MQTT
- uses the binary_sensor component
- has autodiscovery
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
- copy over the binary from the host
./build/updatemqttmotion
to motioneyeos/data/updatemqttmotion
- make it executable
chmod +x /data/updatemqttmotion
- run it once to generate the default config
/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
}
- Go the hamburger menu to the left after logging in as admin
- Open the
Motion Notifications
tab - Enter
bash -c "/data/updatemqttmotion ON"
into the fieldRun A Command
- Enter
bash -c "/data/updatemqttmotion OFF"
into the fieldRun An End Command
- Enter
bash -c "/data/updatemqttmotion -cam=1 ON"
into the fieldRun A Command
- Enter
bash -c "/data/updatemqttmotion -cam=1 OFF"
into the fieldRun An End Command