SolarEdge solar panels support

Which hass version are you using? If I’m not wrong, this code requires > 0.57.1.

Just to be 100% sure, here’s a direct copy paste of my jsonrest.py
https://pastebin.com/AsV7FCA1
Try to first load the custom component and check for any errors, then start fiddling with config.

I can confirm it is still working properly on 0.59.1 (Hassio).

Anybody interested in having last day, month, year, lifetime as well?

sure, but those where rather simple to implement, only not both the jsonrest construction. Ive created them like this:

- platform: rest
  resource: !secret se_overview_resource
  value_template: '{{ value_json.overview.lastDayData.energy | float / 1000 | round(1) }}'
  name: 'SolarEdge Last Day'
  unit_of_measurement: 'kWh'
  scan_interval: 900

- platform: rest
  resource: !secret se_overview_resource
  value_template: '{{ value_json.overview.currentPower.power | round(1) }}'
  name: 'SolarEdge Production'
  unit_of_measurement: 'Wh'
  scan_interval: 900

- platform: rest
  resource: !secret se_overview_resource
  value_template: '{{ value_json.overview.lastMonthData.energy | float / 1000 | round(1) }}'
  name: 'SolarEdge Last Month'
  unit_of_measurement: 'kWh'
  scan_interval: 900

- platform: rest
  resource: !secret se_overview_resource
  value_template: '{{ value_json.overview.lastYearData.energy | float / 1000 | round(1) }}'
  name: 'SolarEdge Last Year'
  unit_of_measurement: 'kWh'
  scan_interval: 900

- platform: rest
  resource: !secret se_overview_resource
  value_template: '{{ value_json.overview.lifeTimeData.energy | float / 1000 |round(1) }}'
  name: 'SolarEdge LifeTime'
  unit_of_measurement: 'kWh'
  scan_interval: 900

Coulant get the jsonrest to show anything else but the On :wink:

Now if we could get the separate ThreePhaseInverter telemetry i posted above to show up, the would be way cool.
On the other hand, I’ve noticed that reading these through Mqtt provides live continous figures, opposed to the timed SolarEdge Api figures. Nice to have, but not as insightful. Ill keep them just in case its easier to use in future construction of automations. How do you use them?

And if you get the Jsonrest data to work please do post, maybe thats even better.
Cheers,
Marius

Here it is, my friend. I’m just trying to avoid individual API calls, and that’s the whole point for me in using jsonrest.

- platform: jsonrest
  resource: https://monitoringapi.solaredge.com/site/YOUR_SITE_CODE/overview.json?api_key=YOUR_API_KEY
  method: GET
  name: SolarEdge jsonrest_storic
  scan_interval: 3600

- platform: template
  sensors:
    grid_last_updated:
      value_template: '{{ states.sensor.solaredge_jsonrest_storic.attributes.overview.lastUpdateTime }}'
    grid_lifetime:
      value_template: '{{ states.sensor.solaredge_jsonrest_storic.attributes.overview.lifeTimeData.energy | float / 1000000 | round(2) }}'
      unit_of_measurement: 'MWh'
    grid_this_year:
      value_template: '{{ states.sensor.solaredge_jsonrest_storic.attributes.overview.lastYearData.energy | float / 1000 | round(1) }}'
      unit_of_measurement: 'kWh'
    grid_this_month:
      value_template: '{{ states.sensor.solaredge_jsonrest_storic.attributes.overview.lastMonthData.energy | float / 1000 | round(1) }}'
      unit_of_measurement: 'kWh'
    grid_today:
      value_template: '{{ states.sensor.solaredge_jsonrest_storic.attributes.overview.lastDayData.energy | float / 1000 | round(1) }}'
      unit_of_measurement: 'kWh'

My templating skills seem to suck as I’m not able to correctly round those numbers (it just seems to ignore my round(x), but anyway…

I’ll try to get the 3 phases telemetry as I do also have a 3 phases inverter. May I ask you what are the relevant values for L1/2/3?

1 Like

Cool, thanks!
relevant data would be the activePower. Check my picture of Zonnepanelen before.

Ive tried several api calls but they require http authorization, so still a nogo.

your solution doesn’t work (yet) on my installation though:

24

must require some further tweaking…

Cheers,
Marius

Is jsonrest correcly loaded? Are you running version >0.57.1?
If you visit
https://monitoringapi.solaredge.com/site/YOUR_SITE_CODE/overview.json?api_key=YOUR_API_KEY
do you get any output?

Not sure if it matters, but here’s my complete workflow to make this work (given that jsonrest is correcly installed)

I’ve added the jsonrest sensor under sensor in config and rebooted hass (with no errors). I then checked that the sensor was indeed working
06-12-2017 11_39_21-Home Assistant

Then I’ve added the template sensors, rebooted, created group and voilà (still working on rounding issues :sweat_smile:)
06-12-2017 11_40_42-Home Assistant

If jsonrest is correcly loaded and you see output from that json call, it should just work :slight_smile: Just check you’re not changing any sensor name, as you’d have to change the templates, too!

EDIT @Mariusthvdb
Almost forgot! As for the 3 phases monitoring, please tell me the api link you’re retrieving data from (just omit siteid and api)

yes, sure: {"overview":{"lastUpdateTime":"2017-12-06 12:52:30","lifeTimeData":{"energy":4843015.0},"lastYearData":{"energy":4348806.0},"lastMonthData":{"energy":6604.0},"lastDayData":{"energy":764.0},"currentPower":{"power":433.0},"measuredBy":"INVERTER"}}

the url for the equipment data is:

https://monitoringapi.solaredge.com/equipment/[site-id]/7E1A1D8E-43/data?startTime=2016-12-05%2011:00:00&endTime=2016-12-05%2013:00:00&api_key=[apikey]
as found in the api-pdf form SolarEdge.

and yes, the jsonrest sensor is created fine, as it shows On :wink: proving there is connection

maybe you can have a look.
Also, what interest me even more, is whether we can get the current power. Dynamically and continuously updating. not the aggregated per day or other timeslot.
Thanks,
M

see here for currentpower. I’ve solved rounding issues and will post updated code

only limited by update interval. You can also split it in different json calls, if you’re not able to setup jsonrest!

As promised and trying to be as simple as possible, here’s an updated version you can try out. V. 0.3 :rofl:

#*REQUIRES JSONREST CUSTOM COMPONENT
#**REQUIRES HOME ASSISTANT > 0.57.1
#***replace YOUR_SITE_ID and YOUR_API_KEY with yours

#We are creating two *jsonrest sensors* wich contain the whole JSON output, then we are going to extract data
#and put those data in other *template sensors*

###ACTUAL DATA --> contains what you are producing (and consuming if you've got an inverter module to do so) NOW
###AGGREGATED DATA ---> shows you these data aggregated by month, year, since beginning

###API LIMIT is 300 calls/day. Be sure the two calls do not exceed that. Time is in SECONDS. Example below is 240 calls/day.

#V. 0.3: corrected decimal roundings bug

sensor:
  ######### ACTUAL DATA ##########
  - platform: jsonrest
    resource: https://monitoringapi.solaredge.com/site/YOUR_SITE_ID/currentPowerFlow.json?api_key=YOUR_API_KEY
    method: GET
    name: SolarEdge jsonrest
    scan_interval: 400

  - platform: template
    sensors:
      grid_consuming_now:
        value_template: '{{ states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["LOAD"].currentPower }}'
        unit_of_measurement: 'kW'
      grid_producing_now:
        value_template: '{{ states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["PV"].currentPower }}'
        unit_of_measurement: 'kW'
      grid_available_now:
        value_template: '{{ (states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["PV"].currentPower - states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["LOAD"].currentPower | float) | round(2) }}'
        unit_of_measurement: 'kW'

  ######### AGGREGATED DATA ##########
  - platform: jsonrest
    resource: https://monitoringapi.solaredge.com/site/YOUR_SITE_ID/overview.json?api_key=YOUR_API_KEY
    method: GET
    name: SolarEdge jsonrest_storic
    scan_interval: 3600

  - platform: template
    sensors:
      grid_last_updated:
        value_template: '{{ states.sensor.solaredge_jsonrest_storic.attributes.overview.lastUpdateTime }}'
      grid_lifetime:
        value_template: '{{ (states.sensor.solaredge_jsonrest_storic.attributes.overview.lifeTimeData.energy | float / 1000000) | round(2) }}'
        unit_of_measurement: 'MWh'
      grid_this_year:
        value_template: '{{ (states.sensor.solaredge_jsonrest_storic.attributes.overview.lastYearData.energy | float / 1000) | round(1) }}'
        unit_of_measurement: 'kWh'
      grid_this_month:
        value_template: '{{ (states.sensor.solaredge_jsonrest_storic.attributes.overview.lastMonthData.energy | float / 1000) | round(1) }}'
        unit_of_measurement: 'kWh'
      grid_today:
        value_template: '{{ (states.sensor.solaredge_jsonrest_storic.attributes.overview.lastDayData.energy | float / 1000) | round(1) }}'
        unit_of_measurement: 'kWh'
  ##################################################
  
#It's a nice idea to save some db space and exclude the main two sensors logging (since we already have those data available
#as extracted template sensors)

took a little because of other bug hunting and setting up, but here goes:

53

35

measuring the panels, through my hub connected ModBUs over Mqtt (zonnepanelen), api calls and your jsonrest definitions.
Too bad the current flow isn’t possible in my setup.
Not sure if the api calls aren’t better given the max calls/day with the jsonrest .

Nice project!
Cheers,
Marius

Thanks! I use the latest hass version 0.59.2. Updated the jsonrest.py with the fresh download you offered.
I also checked that the url https://monitoringapi.solaredge.com/site//currentPowerFlow.json?api_key= (wich returns correct data, and now I see the indicators at the homescreen, but with no data in it. Then I checked the log, where I found these:

Could not render template grid_today: UndefinedError: ‘mappingproxy object’ has no attribute ‘overview’
22:42 components/sensor/template.py (ERROR)
Could not render template grid_production: UndefinedError: ‘dict object’ has no attribute ‘PV’
22:13 components/sensor/template.py (ERROR)
Could not render template grid_available: UndefinedError: ‘dict object’ has no attribute ‘PV’
22:13 components/sensor/template.py (ERROR)
Could not render template grid_consumption: UndefinedError: ‘dict object’ has no attribute ‘LOAD’
22:13 components/sensor/template.py (ERROR)

What would it mean?

it means the definitions are not valid for your setup, as in mine.
the combination of the object and attribute is not valid. check above in my screenshots, they will be similar?

Cheers,
Marius

Nope. I do not get the display items on the homescreen. Just the circles on top. When I look in the states overviews (< >) I see:
sensor.grid_available_now unknown unit_of_measurement: kW
friendly_name: grid_available_now
sensor.grid_consuming_now unknown unit_of_measurement: kW
friendly_name: grid_consuming_now
sensor.grid_last_updated unknown friendly_name: grid_last_updated
sensor.grid_lifetime unknown unit_of_measurement: MWh
friendly_name: grid_lifetime
sensor.grid_producing_now unknown unit_of_measurement: kW
friendly_name: grid_producing_now
sensor.grid_this_month unknown unit_of_measurement: kWh
friendly_name: grid_this_month
sensor.grid_this_year unknown unit_of_measurement: kWh
friendly_name: grid_this_year
sensor.grid_today unknown unit_of_measurement: kWh
friendly_name: grid_today

Sorry for my noobiness, but how can I define the object and attribute?

ive grouped the individual sensors (circles, called badges…) in a group SolarEdge Json, just so its easy to compare them with my already setup other sensors (also in a group)

you should at least be able to have the overview items, the producing now items are depending on your setup of extra hardware (measuring and outputting actual data)

Now I got it! The call to https://monitoringapi.solaredge.com/site/yourSiteID/currentPowerFlow.json?api_key=yourAPIkey does not return values in my account (Why??)… But this one: https://monitoringapi.solaredge.com/site/YOUR_SITE_CODE/overview.json?api_key=YOUR_API_KEY does return data. . No I will try to figure out the current power that is supplied.

How does this work? What kind of data did you store in the secrets file?

you have to enter your site id and api key.
read the whole thread and see the ways you can obtain these.

I did. Works for the other calls. And I do get a response: Empty []

same here,
you probably don’t have the piece of hardware required to be installed in or alongside the inverter for measuring the current power flow (by which i think is meant the own use of the delivered solar-power).

i read that from an attached modbus, and that gives me all current actual energy data, opposed to the limited api calls or jsonrest calls in the above setting.

Thanks. I do not have that extra module, but this is what I have settled instead. It gives me the same result as the solar-edge montoring site:

  - platform: jsonrest
    resource: !secret solarEdge_overview
    method: GET
    name: SolarEdge inverter
    scan_interval: 500

  - platform: template
    sensors:
      grid_today:
        friendly_name: "solar power today"
        value_template: '{{ (states.sensor.solaredge_inverter.attributes.overview.lastDayData.energy | float / 1000) | round(2) }}'
        unit_of_measurement: 'kWh'
      grid_now:
        friendly_name: "solar power now"
        value_template: '{{ (states.sensor.solaredge_inverter.attributes.overview.currentPower.power | float / 1000) | round(2) }}'
        unit_of_measurement: 'kW'

And i entered the siteid and api key in secrets.yaml file like this:

solarEdge_overview: https://monitoringapi.solaredge.com/site/<siteid>/overview.json?api_key=<apikey>

1 Like

HI,
yes i have that too, working fine.
Sometimes i get an over-quota error message, but can’t trace it for 100% certainty to the Solaredge.

DO you have any other sensors? there are many more options, but the ones i need most are with login credentials that wont be configured like above, and give unauthorized errors.
Most of all, i would like to have the separate Phase ( i have a 3 phase installation) sensors.

see below for a try to get that, maybe you can find the error, of make it work?

- platform: rest
  resource: !secret se_equipment_resource
  value_template: '{{ value_json.equipment.L1Data.activePower | float / 1000 |round(1) }}'
  name: 'SolarEdge L1 activePower'
  unit_of_measurement: 'Wh'
  scan_interval: 900

secrets:

se_equipment_resource: https://monitoringapi.solaredge.com/equipment/[siteid]/[serialnumber]/api_key=[apikey]

Check https://www.solaredge.com/sites/default/files/se_monitoring_api.pdf page 34

there is the full equipment overview, including all phases, but we can only read that with a date-range with a max span of one week in the url. like:

https://monitoringapi.solaredge.com/equipment/[site-id]/[serial-number]/data?startTime=2018-01-28%2011:00:00&endTime=2018-01-28%2013:00:00&api_key=[api-key]

the above works fine in a browser, and gives the full telemetry ea.

of course we can’t create a sensor with the hard coded date-range like this, so im looking for a way to have that created automatically and dynamically based on the current timestamp. Or maybe with an input selector?
Would you have suggestions doing so?
Ive asked the community template-wizards for help :wink: Dynamically create sensor based on current time?

Cheers,
Marius