Value template to extract one attribute

I curl a public sensor resulting giving this result:
{ “timestamp”: “2020-02-06T12:15:00+01:00”, “value”: 799.0, “trend”: 1, “stateMnwMhw”: “normal”, “stateNswHsw”: “normal” }
Now I struggle with extracting the value value.
Here my (not working) template:

  - platform: template
    sensors:
      pegel:
        value_template: "{{ states('sensor.rheinpegel.value') }}"

What’s wrong?

The first problem is you need to extract state as

{{ states('sensor.rheinpegel') }}

as there is no sensor sensor.rheinpegel.value, right?
the second problem is your state is most likely a sting, not a dictionary.
you might try something like this

value_template: >
  {% set state = states('sensor.rheinpegel') | from_json %}
  {{ state.get('value', 'unknown') }}
1 Like

Yes sensor.rheinpegel.value is unknown.

How would I check if a result is a string or a JSON dictionary?

sensor’s state is always a string, it’s by design. go to Developer tools - > templates and paste

state: {{ states('sensor.rheinpegel') }}
Is it a string: {{ states('sensor.rheinpegel') is string }}