See MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters
I’m not certain Stefan’s idea will work because if the JSONPATH doesn’t match anything it returns the whole JSON String. You want to return nothing if the device ID isn’t present. To achieve that use the REGEX filter first chained to the JSONPATH.
I could be wrong on that point though. I’ve never tried to chain two JSONPATHs together like this.