Parse JSON from state

Hi everyone,

I’m once again struggling with some (basic) configuration.

I have set up some sensors on my remote Arduino which sends TCP over Ethernet. I receive the sensor data with:

  - platform: tcp
    port: 1000
    name: Multiple Sensors
    payload: "\n"

And I can retrieve the whole string with states.sensor.multiple_sensors.state, which returns me:


That’s all nice and great, but I want to access (let’s say) S_56. I thought that with states.sensor.multiple_sensors.attributes.S_56 I could. Nope. Returns nothing.

Upon further inspection I saw that states.sensor.multiple_sensors.attributes only has friendly_name and nothing more.

Also tried states.sensor.multiple_sensors.state.S_56. Nope.
And states.sensor.multiple_sensors.state["S_56"]. Nope.

I tried to read the sensor with (in hope it would parse to JSON) :

  - platform: tcp
    port: 1000
    name: Multiple Sensors
    payload: "\n"
    value_template: "{{ value_json }}"

which resulted in a “unknown” sensor value. I also tried value_json.S_56 directly. Nope. Gives unknown.

How can I read a value from this JSON? Until now I tried almost everything, I also googled pages and more pages.

My goal is to read every “S_” sensor and put those into template sensors. That way I only need to call the TCP sensor once, which saves bandwith and possible trouble.

Thanks in advance.

I believe

 value_template: '{{value.json.S_54}}'


Thanks for your answer, but value.json won’t work. The valid way to parse it into JSON is value_json, with an underscore.

So does

value_template: '{{value_json.S_54}}'


Unfortunately no…

This page indicates you might need:
value_template: '{{ value_json.S_54.value }}'