Sensor value in TCP request

I tried to setup TCP Sensor to send temperature sensor data. Here is sensor’s config:

  - platform: tcp
    host: narodmon.ru
    port: 8283
    payload: "#AA-BB-CC-11-22-33\n#T1#{{ states('sensor.outside_temperature')}}\n##"

Here is the data received by the server:

2017-11-01 00:08:33  2.132.80.179  TCP
#AA-BB-CC-11-22-33
#T1#{{ states('sensor.outside_temperature')}}
##

The sensor values are not sent to the server. What am I doing wrong? How do I send values from a sensor in this request?

Does it work any better as this:

#AA-BB-CC-11-22-33\n#T1#{{ states.sensor.outside_temperature.state }}\n##”

Unfortunately, this also does not work.
Data received by the server:

2017-11-01 14:14:47  2.132.237.218  TCP
#AA-BB-CC-11-22-33
#T1#{{ states.sensor.outside_temperature.state }}
##

Ah, maybe this is the wrong component - now that I look at it again.

I think the ‘TCP sensor’ component expects to receive info, not send it out.

Thanks for your reply. Maybe you know another way of sending data over TCP?

If you can make the connection at the command line, then there’s always the command-line switch (some scripts might be useful too).

1 Like