aha. cool.
I don’t have that tab ;-((
Ask your installer to enable that. If you cannot reach him, call Solaredge until you find an operator kind enough to activate it real time
+1 for me
Having this supported would be nice.
Added decimal rounding to avoid really long numbers. Let’s call it ver. 0.2
sensor:
- platform: jsonrest
resource: https://monitoringapi.solaredge.com/site/yourSiteID/currentPowerFlow.json?api_key=yourAPIkey
method: GET
name: SolarEdge jsonrest
scan_interval: 400
- platform: template
sensors:
grid_consumption:
value_template: '{{ states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["LOAD"].currentPower }}'
unit_of_measurement: 'kW'
grid_production:
value_template: '{{ states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["PV"].currentPower }}'
unit_of_measurement: 'kW'
grid_available:
value_template: '{{ states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["PV"].currentPower - states.sensor.solaredge_jsonrest.attributes.siteCurrentPowerFlow["LOAD"].currentPower | round(2) }}'
unit_of_measurement: 'kW'
— edit—
no separate inverter data yet, but progress has been made (last month and last day are defined correctly, same output probably result of last month being only 1 day old??):
had to skip the jasonrest sensors, since their not working in my setup (yet)
----- end edit-----
thats wonderful!
I’ve managed to get my api key and site id. Filled these in in the sensor jsonrest, and seems to work. That is, i don’t get any authorization questions. Is that how its suppers to work?
the solarEdge sensor is On, the others still unknown, so that might be a definition issue. btw, i don’t have any meter installed yet that measures my consumption, so i will have to take that out i guess, unless that is somehow measured inside the Solar Edge system itself?
Also, i have 3 grids. would the definition of the grid_production and grid_available have to change compared to your settings?
—edit—
added the 2 examples @Kroontje provided above. They’re metering!
still, its not close to what my other meters are saying:
will check and find the peculiars, but thanks all for getting this far!
----edit—
some specifics: my threefaseinverter telemetry, im looking for the correct syntax to retrieve the L1DAta,L2Data and L3Data. Did you manage this @Kroontje?
the telemetry layout through http:
<data>
<count>24</count>
<telemetries>
<threePhaseInverterTelemetry>
<date>2016-12-05 11:04:58</date>
<totalActivePower>319.0</totalActivePower>
<dcVoltage>748.5</dcVoltage>
<groundFaultResistance>6900.03</groundFaultResistance>
<powerLimit>100.0</powerLimit>
<totalEnergy>444623.0</totalEnergy>
<temperature>22.6103</temperature>
<inverterMode>MPPT</inverterMode>
<L1Data>
<acCurrent>0.78125</acCurrent>
<acVoltage>226.016</acVoltage>
<acFrequency>49.9869</acFrequency>
<apparentPower>176.0</apparentPower>
<activePower>118.0</activePower>
<reactivePower>-130.0</reactivePower>
<cosPhi>1.0</cosPhi>
</L1Data>
<vL1To2>388.219</vL1To2>
<vL2To3>388.344</vL2To3>
<vL3To1>389.188</vL3To1>
<L2Data>
<acCurrent>0.648438</acCurrent>
<acVoltage>224.062</acVoltage>
<acFrequency>49.9879</acFrequency>
<apparentPower>170.0</apparentPower>
<activePower>118.0</activePower>
<reactivePower>-122.0</reactivePower>
<cosPhi>1.0</cosPhi>
</L2Data>
<L3Data>
<acCurrent>0.757812</acCurrent>
<acVoltage>223.141</acVoltage>
<acFrequency>49.9866</acFrequency>
<apparentPower>145.0</apparentPower>
<activePower>83.0</activePower>
<reactivePower>-148.0</reactivePower>
<cosPhi>1.0</cosPhi>
Cheers,
Marius
Seems a good solution. So I followed the instructions, copied the jsonrest.py right from the source in homeAssistant/custom_components/sensor/ and added the sensor configuration to my configuration.yaml file. Then I restarted homeAssistant. En then my log shows a long list of issues like this:
File "/usr/src/app/homeassistant/loader.py", line 104, in get_platform
return get_component(PLATFORM_FORMAT.format(domain, platform))
File “/usr/src/app/homeassistant/loader.py”, line 142, in get_component
module = importlib.import_module(path)
File “/usr/local/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 674, in exec_module
File “”, line 781, in get_code
File “”, line 741, in source_to_code
File “”, line 219, in _call_with_frames_removed
File “/config/custom_components/sensor/jsonrest.py”, line 156
self.data = None
^
TabError: inconsistent use of tabs and spaces in indentation
I can’t figure out what I am doing wrong… Anybody??
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
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?
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:
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
Then I’ve added the template sensors, rebooted, created group and voilà (still working on rounding issues )
If jsonrest is correcly loaded and you see output from that json call, it should just work 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 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
#*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:
![35](http://community-assets.home-assistant.io/original/3X/a/6/a6c914d075e4e54376ff90fc4cd2aeff0d27dbb0.jpg)
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)