Template sensor data types

I can’t find a list of different available data types for the template sensor. I have the following template derived from a Modbus output, but the result is an int/ whole number. Does anyone have a reference to all the different available data types to choose from?

      - name: SMA Solar Power
        hub: SB5
        unit_of_measurement: kW
        slave: 3
        register: 30775
        count: 2
        data_type: uint
        scale: 0.001
        precision: 3

  - platform: template
    sensors:
      sma_solar_power_filtered:
        friendly_name: "Solar Power"
        unit_of_measurement: 'kW'
        value_template: >-
          {% if (states('sensor.SMA_Solar_Power') | int >= 20000) %}
            0
          {% else %}
            {{(states('sensor.SMA_Solar_Power') | int)}}
          {% endif %}  

You can use | float and | round(x) to round to the desired decimal place instead of | int.

1 Like