Template sensor trouble [Solved]

Hi,

I am trying to display the solar power generated numbers displayed by Enphase sensor in kW instead of W. But I keep getting “0 Kwh” and not sure what I am doing wrong with the template below:

sensor enphase:
  - platform: enphase_envoy
    name: Solar Panels
    ip_address: !secret enphase_ip
    username: !secret enphase_user
    password: !secret enphase_password
    monitored_conditions:
      - production # this creates sensor.solar_panelsenvoy_current_energy_production
      - daily_production
      - seven_days_production
      - lifetime_production
      - consumption
      - daily_consumption
      - seven_days_consumption
      - lifetime_consumption
  - platform: template 
    sensors:
      s_production:
        friendly_name: "Test solar production sensor"
        value_template: "{{ (states.sensor.solar_panelsenvoy_current_energy_production | float /1000 ) | round(2) }}"
        unit_of_measurement: 'kWh'

Here is the output in the UI:
solar
Any pointers to fix this would be helpful.
Thanks.

  - platform: template 
    sensors:
      s_production:
        friendly_name: "Test solar production sensor"
        value_template: "{{ (states('sensor.solar_panelsenvoy_current_energy_production')|float/1000)|round(2) }}"
        unit_of_measurement: 'kWh'
1 Like

@anon43302295 thanks!! :smiley:

1 Like