.stage does not exist on the data objects. There is .primary and .secondary. I note that the observation header has information in primaryName and secondaryName. Do you exoect these to ever change. If not just use .primary
Note, you won’t get value_json in template editor. It is special to internals of Home Assistant template engine when an integration passes json, like REST. I test by mocking up an extra line or two. e.g.
The code you shared goes into your configuration.yaml file. The template editor is used to test out Jinja templates. Templates are the code that is surrounded by curly brackets.