platform: serial serial_port: /dev/ttyS0 name: "moisture_scale_serial" value_template: >- {% if value | contains('S') %} {% set temp_value = value | regex_findall_index('\d+\.\d+(?= lb)') | float %} {% if value | contains('-') %} {% set temp_value = temp_value * -1 %} {% endif %} {{ ((temp_value * 50 - (0.5 if temp_value > 0 else -0.5)) | int | float / 50) }} {% else %} {{ states("sensor.sheller_scale") }} {% endif %}