[SOLVED] Template working in dev tools but not value template

        value_template: >-
          {% if state_attr("sensor.smarter_kettle_status", "sensors")["base"] == "On" -%}
          on
          {%- else -%}
          off
          {%- endif %}

when pasted in developer tools template editor it correctly prints off/on but if used as value template for the sensor it always is off.

Any ideas?

Thanks

EDIT:
more compact solution:

'{{state_attr("sensor.smarter_kettle_status", "sensors")["base"] == "On"}}'

Seems to work with this template

        value_template: >-
          {% if state_attr("sensor.smarter_kettle_status", "sensors")["base"] == "On" -%}
          {{ true }}
          {%- else -%}
          {{ false }}
          {%- endif %} 

guess the binary sensor template really needs true/false instead of on/off

Binary sensors seem to always display “off” when the value_template evaluates to anything but “True”