Please pretty please help with multiple TCP values in one go

Hi,
I’ve now spent an unproportional amount of time with this now but to no avail.
I have a heating system that I’ve built myself, and I have a ton of sensors coming out over a tcp port.
I can format the output in any way needed in order to get it in HA to eventually be feed in to node red to control everything with.

so to the problem:
I send a “*\n” to a tcp connection on my own hw, that one responds back (can be changed…)
15.999695;31.999390;28.300000;15.700000;

all these are different measurement points of various parameters, so I want to bring each value in as a separate sensor in HA. I can do this like below, but that suxx for many reasons, especially when I soon is going to have 50 sensors.

sensor:
  - platform: command_line
    name: heating_flow
    scan_interval: 5
    command: echo "*\n" | timeout 1 nc 192.168.0.88 5001
    value_template: "{{ value.split(';')[0] }}"
    unit_of_measurement: "l/min"
  - platform: command_line
    name: radiator_flow
    scan_interval: 5
    command: echo "*\n" | timeout 1 nc 192.168.0.88 5001
    value_template: "{{ value.split(';')[1] }}"
    unit_of_measurement: "l/min"

So instead I just want to do 1 TCP request, and preferably with the TCP sensor, ie

sensor:
  - platform: tcp
    name: tanksystem
    host: 192.168.0.88
    port: 5001
    timeout: 2
    payload: "*\n"
    value_template: "{{ value }}"
  - platform: template
    sensors:
      radiatorflow:
        friendly_name: Radiator flow
        value_template: "{{ states('tanksystem').split(';')[0] }}"
        unit_of_measurement: "l/min"
      heatingflow:
        friendly_name: Heating flow
        value_template: "{{ states('tanksystem').split(';')[1] }}"
        unit_of_measurement: "l/min"
etc 
etc..

the variable (or whatever you call it) heatingsystem looks just fine when I look at the entity in HA, but the radiatorflow can’t be rendered.

Please help me understand how I can do this, I tried the above but instead using value_json and instead printed a json over tcp ala

{
	"heatingsystem": {
		"flows": {
			"heater": 1,
			"radiator": 1
		},
		"temperatures": {
			"RadiatorOut": 1.43,
			"RadiatorIn": 3.23423,
			"TankTop": 4.2,
			"TankMid": 5,
			"TankBottom": 6
		}
	}
}

but I couldn’t for my life get the
'states(‘tanksystem’)[‘heatingsystem’][‘flows’][‘heater’] 'or
'states(‘tanksystem’).heatingsystem.flows.heater ’
or similar work.
if someone could point me to any way where it explains how to do this very simple task I would be extremly happy, and you may have saved a life or at least a ton of pulled hair…

states() requires an entity_id. tanksystem is not an entity_id, the domain is missing. it would be sensor.tanksystem

Yes this is the route you should go, and your syntax would have worked if you used the correct entity_id. Well, there is some things you’d need to adjust.

sensor:
  - platform: tcp
    name: tanksystem
    host: 192.168.0.88
    port: 5001
    timeout: 2
    payload: "*\n"
    value_template: "{{ value }}"
  - platform: template
    sensors:
      radiatorflow:
        friendly_name: Radiator flow
        value_template: "{{ (states('sensor.tanksystem') | from_json).heatingsystem.flows.radiator }}"
        unit_of_measurement: "l/min"

Just keep in mind that states are limited to 254 characters and your json is at 220. I’d suggest you modify the json to be shorter or use the rest integration instead so that you can put the json into the attributes which does not have the 254 character limit.

e.g. (140 characters)

{"flow": {"heater": 1, "radiator": 1}, "temperature": {"radiator": {"in": 3.23423,"out": 1.43},"tank":{"top": 4.2, "mid": 5, "bottom": 6}}}

accessing…

{{ (states('sensor.tanksystem') | from_json).flow.radiator }}
{{ (states('sensor.tanksystem') | from_json).flow.heater}}
{{ (states('sensor.tanksystem') | from_json).temperature.radiator.in }}
{{ (states('sensor.tanksystem') | from_json).temperature.radiator.out }}
etc