Having trouble using value_template with solaredge local

I just had a solar edge inverter installed last week and trying to add the local api component to Hassio.

If I add just:

sensor:
  - platform: solaredge_local
    name: SolarEdge
    ip_address: 192.168.0.172

I get the parameters, but in watt-hours instead of kWh.

I have looked through similar questions and tried all the solutions that I could find.

I now have:

sensor:
  - platform: solaredge_local
    name: SolarEdge
    ip_address: 192.168.0.172
    
sensors:
  platform: template
    sensors: # Line 153
      solaredge_current_power_template:
        value_template: '{{(states('sensor.solaredge_current_power') | float / 1000) | round(2)}}'

But keep get an “Error loading /config/configuration.yaml: mapping values are not allowed here
in “/config/configuration.yaml”, line 153, column 12” with line 153 being the bolded sensors line.

Any help would be appreciated. Thanks.

Is this a package? You should only have one sensor defined if so.

  - platform: template
    sensors:
      solaredge_current_power_template:
        value_template: '{{(states('sensor.solaredge_current_power') | float / 1000) | round(2)}}'

You need to use different quotes to encapsolate your value template. Notice how the coloring looks weird in your value template? Half is red, half is black? That’s an indication that the parser doesn’t know what’s a string and whats not.

sensor:
  - platform: solaredge_local
    name: SolarEdge
    ip_address: 192.168.0.172
    
sensors:
  platform: template
    sensors: # Line 153
      solaredge_current_power_template:
        value_template: "{{(states('sensor.solaredge_current_power') | float / 1000) | round(2)}}"

This should work. The only change is that the outside is using " and the inside is using '. Everything else in your template is good except that.

2 Likes

Still shows as invalid, will try again tomorrow, thanks.

Like @walrus_parka said, if this is in configuration.yaml, it should be

sensor:
  - platform: solaredge_local
    name: SolarEdge
    ip_address: 192.168.0.172
    
  - platform: template
    sensors: # Line 153
      solaredge_current_power_template:
        value_template: "{{(states('sensor.solaredge_current_power') | float / 1000) | round(2)}}"

ah yeah, didn’t notice the sensors: header.

I pasted it from the example at SolarEdge Local. How do I correct the component page?

Thanks for the help.

wow
 that’s a flub up. If i remember, i’ll look into the change in the morning.

@VDRainer @carbuthn

Left a comment. Must be a joke i think.

Hello,

I’m very new to HASS and the template part. But it looks very handy and usefull. I have the Solar Edge intergration with the API. I want to calculate the values from Wh to KWh. I found the template exemple on the solar edge intergration page but that gives a error. When i put the string in the template editor (dev tools) i get the right value but when i put it in my sensor.yaml and check my config i get the following error:

Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 24). Please check the docs at Sensor - Home Assistant

This is my configuration.yaml:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: doesn't matter
  longitude: doesn't matter
  # 'metric' for Metric, 'imperial' for Imperial
  unit_system: metric
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: doesn't matter
  customize: !include customize.yaml

##################Include#######################
group: !include groups.yaml
script: !include scripts.yaml
automation: !include automation.yaml
zone: !include zone.yaml
sensor: !include sensor.yaml
switch: !include switch.yaml
device_tracker: !include device_tracker.yaml

Line 24 is: zone: !include zone.yaml

This is my Sensor.yaml

##Sensor.yaml##

###Untapped##########
sensor:
#  - platform: untappd
#    username: !secret untappd_username
#    id: !secret untapped_id
#    secret: !secret untapped_secret

###Solaredge##########
# Example configuration.yaml entry for template platform
  - platform: template
    sensors:
      solaredge_energy_this_year_template:
        value_template: "{{(states('sensor.solaredge_energy_this_year') | float / 1000) | round(2)}}"

What i’m doing wrong?

Remove sensor from sensor.yaml. You have 2 section headers, when you combine the sensor: !include with the sensor.yaml you end up with this as your configuration:

sensor:
  sensor:
  - platform: ....

It should be this:

sensor:
- platform: ...

So remove:

##Sensor.yaml##

###Untapped##########
sensor: #<--------------------REMOVE THIS
#  - platform: untappd
#    username: !secret untappd_username
#    id: !secret untapped_id

Thank you very much. Now i don’t have that error. this make sense.
But i have to figure out why nothing is happend. the value is still the same in Wh and not in KWh.

The template will only update when sensor.solaredge_energy_this_year updates. If there isn’t any update, you won’t get a change.

hm oke. i will check it tommorow when the sun is shining and the values are updatet every 10 minutes

@Denman2103
Actually i have the same problem. Have you solve the Wh to kWh?

Im running Homeassistant 0.101.0
Lots of things is change in relations to the online manuals. Its hard to find solutions.

Greetings
Palermo

Hi,

The templates are working for me. i use the following code:

  - platform: template
    sensors:
      solaredge_energy_this_year_template:
        value_template: "{{(states('sensor.solaredge_energy_this_year') | float / 1000) | round(2)}}"
  - platform: template
    sensors:
      solaredge_energy_this_month_template:
        value_template: "{{(states('sensor.solaredge_energy_this_month') | float / 1000) | round(2)}}"
  - platform: template
    sensors:
      solaredge_lifetime_energy_template:
        value_template: "{{(states('sensor.solaredge_lifetime_energy') | float / 1000) | round(2)}}"
  - platform: template
    sensors:
      solaredge_energy_today_template:
        value_template: "{{(states('sensor.solaredge_energy_today') | float / 1000) | round(2)}}"
1 Like