platform: tcp host: 192.168.1.22 port: 23 payload: "" name: "Moisture Scale" scan_interval: seconds: 1 value_template: >- {% if value | contains('S') %} {% set temp_value = value | regex_findall_index('\d+(?=, g)') | float %} {% if value | contains('-') %} {% set temp_value = temp_value * -1 %} {% endif %} {{ temp_value }} {% else %} {{ states("sensor.moisture_scale") }} {% endif %} unit_of_measurement: "g"