JSON Type is empty when coming from Detection Sensor

Hi,

So I set up a Mosquitto MQTT Broker and set up my Meshtastic device to connect to it, using MQTT Explorer to intercept and read the communication. I set up one Meshtastic Device with a simple switch connected to a GPIO pulling it low, using the settings under Detection Sensor. A very useful thing (that should definently expose more than one GPIO too). I have setup Friendly name to “motion”. When pushing the button a message shows up on the other device " Motion Detected". But when intercepting the MQTT package, the JSON string does not contain any consistant unique data that can be pulled from it. On the last segment, it just says Type:“”. The “motion detected” part is coming under C and is scrambled with strange symbols around the text. I have tried with and without ASCII-bell activated but it makes no difference. When there is no specific part in the JSON for this activity it is unusable. At least it should have Friendly name in it or Type:“detection”.
I hope there is a fix for this. All other messages like telemetry and gps have defined like “location” and “telemetry” in JSON, but the Detection Sensor has nothing. The rest of the JSON is either sender info, and other info that always changes.

T-Beam V1 with latest Beta firmware.

Please help. :slight_smile:

This was not yet implemented as shown here.
I just opened PR #3043 to add this. It will show Type:"detection" and it will have a “text” field with the message, e.g. “Motion detected”.

:slight_smile: Wow, that was fast and just perfect.
How/when will I be able to use this or upgrade firmware with this working?

You can download the artifacts that include this change listed here (scroll down a bit) or wait for the next firmware release.

Thanks for the response. I think I’ll have to wait since I don’t know how to compile this. I’m just glad you sawthis and fixed it. It will be very useful.

That link has .zip files which you can download for the correct board and then flash via the CLI. Otherwise, you can wait for the firmware release and flash via the Web Flasher.

SOLVED: put .bat files in Python Script folder. This was really not obvious.

Downloading the firmware and following the Flash via CLI guide was not straight forward. Everything installs and goes according to plan and the board is found. But at device-update.bat I get “bash: device-update.bat: command not found”
I have the device-update.bat file in the same folder as the firmware-file.


This is so great! Thank you for wonderful support! Loving these devices!

1 Like

Now I got it working and it is totally usable. But in a perfect world, maybe the message should not be a “text:” in JSON but rather “state”? Then it would not show up between messages and it would really be more unique and have its own feed.
It is likely that the local device connected to MPTT srrver receives a bunch of messages and then these notifications comes in that stream. I am sure there is a way to filter it, but the easiest and most robust way would be to not have the Friendly name +state as a “text” but rather something unique.

The Detection Sensor is all based on text to keep it simple in usage. Normally people want to see these messages in the usual stream.

You can filter on the type (normal text is type “text” while Detection Sensor is type “detection”).