Using JSONata in a Change Node to split the payload string?

The flow I have watches all state_changed events and sends the payload to a switch. The switch filters out events based upon a custom attribute defined for various entities in HA.

My goal is to convert msg.payload from “sensor.whatever” to just “whatever”.

JSONata syntax should work if I use $substringAfter(str, chars) but I’m getting stuck on the data required in the str position.

I’ve tried $substringAfter(payload,".") but I get an error despite this testing correctly in other JSONata tools.

Not sure if I need to use payload or {{payload}} or ??? Any ideas?

Got it. The syntax is correct. The error was coming from the fact that payload was an object and not just the entity_id.

The correct statement is $substrinbAfter(payload.entity_id,".")