Cool! You might want to post it over on this thread:
JSONATA is like XPath/XQuery for JSON... it's a worthwhile skill to develop I think especially for streamlining things.. the other thing to consider is building it into a subflow... you can use HE node deviceID's for dynamic stuff.