Template Sensor Not Showing a Value

Hi All,

I’m trying to create a sensor based on the value of another and I’m not seeing a result. Instead I’m just seeing a value of unavailable in the Developer Tools / States. Can someone please point me in the right direction.

  - sensor:
      - name: "Solaredge Grid To House"
        unit_of_measurement: "W"
        state_class: 'measurement'
        device_class: 'power'
        state: >
          {% set m_ac_power = states('sensor.solaredge_m_ac_power') %}
          {% if m_ac_power < 0 %}
            {{ m_ac_power | abs }}
          {% else %}
          {% endif %}


States are strings. You cant compare strings to numbers. So convert your sensor state to a number.

        state: >
          {% set m_ac_power = states('sensor.solaredge_m_ac_power')|float(0) %}
          {{ m_ac_power | abs if m_ac_power < 0 else 0 }}

Yeah, just realized I needed to cast it as a float or integer :-), about to update the post.
Thanks for the response.