Template sensor not appearing

Hi there

I’m new to HA and currently trying add my SolarEdge site into the UI. By default the unit is W or Wh but I’d like to have kW and kWh, the SolarEdge page on the HA site gives some indications but I believe the example is incorrect as copy pasting throws an error.

Anyway, here’s what I currently have, unfortunately the template sensor is not showing up, I’m not sure where to look if there’s any logging that could explain what is going wrong. (Config validation was OK).

sensor:
platform: template
sensors:
    solaredge_energy_this_year_template:
            friendly_name: 'SolarEdge This Year'
            unit_of_measurement: 'kWh'
            value_template: "{{(states('sensor.solaredge_energy_this_year.state') | float / 1000) | round(2)}}"


sensor:
  # Weather prediction
  - platform: yr
 - platform: solaredge
api_key: <snip>
site_id: <snip>
monitored_conditions:
        - current_power
        - energy_today
        - energy_this_month
        - energy_this_year
        - lifetime_energy

A few things…

  • Assuming this is a direct copy from your config, you can’t have multiple definitions/iterations of sensor:
  • You need to watch your indentations which are crucial in HA. There are a few indentation issues with your code
  • Either use '{{states("sensor.sensorname")}}' or '{{states.sensor.sensorname.state}}' with a preference for the first one which will handle when your sensor has an unknown state instead of throwing an error

Try this:

sensor:
  # Weather prediction
  - platform: yr
  - platform: solaredge
    api_key: <snip>
    site_id: <snip>
    monitored_conditions:
        - current_power
        - energy_today
        - energy_this_month
        - energy_this_year
        - lifetime_energy
  - platform: template
    sensors:
      solaredge_energy_this_year_template:
            friendly_name: 'SolarEdge This Year'
            unit_of_measurement: 'kWh'
            value_template: "{{(states('sensor.solaredge_energy_this_year') | float / 1000) | round(2)}}"

Check your config as there may still be indentation errors (typing from phone)

Thanks for the clarification! It works great now.

Cheers