#MQTT & Scrypted
1 messages · Page 1 of 1 (latest)
yeah
MQTT & Scrypted
I'm not sure which "listener" part you're referring to
Were you already using mosquitto in HA?
so when u setup Mqtt in ha’s integrations, you have a listener and a publish option.
and then u have mosquitos broker
ik the broker works because I’m using ring-mqtt
oh, those are just for debugging
Ohhhh I see.
you can public your own MQTT message, or listen to see what's being published to HA's broker
in scrypted, open your camera and go to the extensions tab/section. make sure mqtt is checked
Right, it is.
user/pass will be whatever mqtt user you created
i'm figuring out what it expects for the URL. presumably mqtt://YOUR_IP with some path after to indicate device info
yup
idk if this is the same when I setup ring Mqtt the url was just “Mqtt://user@pass:ip/“
or whatever it was
ah yes
oh duh clicking in it in scrypted even gives an example
yeah lol
mqtt://XXX/scrypted/cam01/motion
so far i'm only getting Settings, applicationInfo, and online
If you're on Windows I recommend MQTT Explorer to connect to the HA broker and see everything that's being published to it
Ohh okay! I’ll give that a try rq
Oh I know why I'm not getting motion. The camera itself doesn't have any kind of motion detector. My camera actually sends motion/sound events over MQTT to Scrypted
So once you get your camera in Scrypted publishing to HA, maybe you'll get lucky and a motion message will just pop in
sweeet
All you need to do then is define a sensor in your configuration.yaml: https://rc.home-assistant.io/integrations/binary_sensor.mqtt/
Whatever you tell Scrypted to use in its MQTT section
I do recommend making it scrypted/whatever
But if motionDetected is already a part of the MQTT message I'd personally just make it "scrypted/cam01" or whatever cam name
yeah
alright, so its in home assistant but the status is saying "Unavailable"
oh do I need the payload?
Yeah, looks like you'll need "payload_on" and "payload_off" to match whatever Scrypted sends
The full example from the HA docs is good to reference:
# Example configuration.yaml entry
mqtt:
binary_sensor:
- name: "Window Contact Sensor"
state_topic: "home-assistant/window/contact"
payload_on: "ON"
availability:
- topic: "home-assistant/window/availability"
payload_available: "online"
payload_not_available: "offline"
qos: 0
device_class: opening
value_template: "{{ value_json.state }}"
yeah thats what im currently referencing off of.
I'd probably skip the availability portion and just use expire_after
for the payload since mqtt is sending it as true/false, would that replace the online/offline?
mqtt:
binary_sensor:
- name: "Camera Motion"
state_topic: "scrypted/camname"
expire_after: 60
payload_on: true
payload_off: false
device_class: "motion"
something like that
assuming scrypted sends motion events at least every 60s
right
Oh it does have an online property
Which HA should automatically handle it seems: payload_available string (Optional, default: online)
right
I'd start with that and see if it works
so after putting everything in, its still showing as unavailable.
Post your full YAML
mqtt:
binary_sensor:
- name: "Bird Cam Motion Sensor"
state_topic: "scrypted/bird-cam/motion"
expire_after: 60
payload_on: true
payload_off: false
device_class: "motion"
And post the mqtt:// URL from scrypted
wdym?
Where you typed in the broker URL/user/pass in scrypted
mqtt://IP/scrypted/bird-cam/motion
ive been reediting some stuff
everything is matching
Ah okay so you put the /motion in the path itself
So everything about that camera--motion, online state, etc.--is under the motion path
That's what I meant here
So your actual payload_on with it configured how it is now should be scrypted/bird-cam/motion/motionDetected
OH
Remove /motion from MQTT and change your state_topic in HA
scrypted/bird-cam/motionDetected
that makes a lot of sense
Are you using MQTT explorer? If you click on the topic you're trying to subscribe to it'll show you the full path in the Topic section in the top right
yeah I see it
So to confirm, motionDetected is an actual topic right?
yes
What's its value?
"true"
No curly brackets or anything? Just, verbatim, "true"?
Interesting, I'd think it'd at least be JSON
Eh, try it like this and see if it works:
mqtt:
binary_sensor:
- name: "Bird Cam Motion Sensor"
state_topic: "scrypted/bird-cam/motionDetected"
expire_after: 60
payload_on: true
payload_off: false
device_class: "motion"
k
Assuming you've updated your mqtt URL in scrypted already
mqtt://IP/scrypted/bird-cam
I feel like I'm missing something about how it's being published to MQTT
Can you paste a screenshot of MQTT Explorer with the motionDetected topic selected to imgur?
So yeah it's literally just a value of "true"
yeah
wdym?
Uhh might've had my own MQTT Explorer up and gotten confused for a sec nvm
Which we'd expect after 60 sec the way it's configured
ohh
Try using the Publish section of MQTT Explorer that you've got expanded in that screenshot. Change it to raw and send a true
See if HA changes state
it did not
How are you reloading configuration.yaml after you change it?
the developer, check the config, then the button restart
Uhh running out of ideas
Try putting double quotes around true and false in the yaml config
Maybe it's seeing them as strings instead of bools
!
hm
weird
so it went to detected, then it went to unavailable, then trying to do motion again it didnt update
maybe was a fluke
sending a raw in mqtt explorer updated it
Maybe remove expire_after for testing purposes
k
while im waiting, if I set the motion duration to 60 in scrypted, do I need the expire after?
Where do you set that? I've only got one camera in scrypted and it uses MQTT for motion, so I'm not familiar with cams it supports directly
so my wyze cam has a built in motion sensor, however their api they removed access to it for third party, but for me, I enabled opencv motion detection
Ah I gotcha
The HA expires_after isn't for when scrypted is functioning properly--it's for detecting when scrypted dies and stops sending messages
oh?
The scrypted motion duration is basically how long it will allow gaps in motion but still consider it one long motion event
So if you set the scrypted motion duration to 60s it won't send anything to HA as long as there's any motion at least once every 60s
Since no state change
Normally you'd set the scrypted motion duration to like 5-10s
hm.
HA expire_after is harder, since HA not hearing from scrypted might be because scrypted died, or because there's just been no motion
right
but in my case, im going to assume its just personal preference? because its working as is.
Yeah, just preference
ah okay!
For some reason your scrypted isn't sending an online topic or you could use that in HA
yeah idk-
For the availability settings in the MQTT sensor
Probably because im using OpenCV not pamdiff
Beyond that, you could either just not use the expires_after option, or set it to something like 6-12 hrs
All it does is change the sensor in HA to unavailable if it doesn't hear from scrypted in that time