Rest sensor value from selective JSON key

I’ve got a set of REST sensors setup using the rest integration to query my TADO via an API.

This is all working fine, but what I’m trying to do is set the value of a specific sensor based on whether a specific JSON key exists.

The problem is that the JSON key may not always be in the same order, so I have to select it using a JSON path expression.

The expression in question would be something like:

$…mobileDevices[?(@.name==‘Lindsey IPhone’)].name

Meaning, to use the .name value in the mobileDevices tree where name = “Lindsey IPhone”.

I’ve tried several ways of plugging this into the value_template for the REST sensor, but none work.

Any idea how to code this properly so that the value_template works and gets the value from the JSON? Ultimately, I then want to set a default so if the JSON is missing (which happens if a TADO device disconnects) then it sets the sensor value to NA or something, but for now I just want to figure out how to get the value from the JSON properly.

Thanks