Illumination template sensor not working

Hi all,

I’ve installed a new weather station giving me lots of data including the sun radiation. Before I had a weather station giving me the sun illumination. Now I would like to translate the radiation to illumination so I created a sensor template:

  - platform: template
        friendly_name: Sun illumination
        value_template: "{% set illumination = (states('sensor.solar_radiation')|float / 0.0079)|round(1) %}"
        icon_template: "mdi:sun-wireless"
        unit_of_measurement: "lux"

However this sensor stays unavailable:

When I enter the value code in Developer tools-Template I do get a correct value. What is going wrong here?

        value_template: "{{ (states('sensor.solar_radiation')|float(0) / 0.0079)|round(1) }}"
  • The posted Template Sensor example is in legacy format so it only accepts value_template, not state.

  • Template Sensors defined in modern format accept state, not value_template.

  • One cannot combine options from both formats.

1 Like

Thanks for the very quick replies.

1 Like