I am getting the same error message. Were you able to figure out a way around this?
Oh No! Something Went Wrong!
Error:500: Internal Server ErrorURI:/device/save
Reference Id:c5e8ad97-9ce6-41e7-9a03-c7e35856aeb2
Date:Thu Jan 21 20:17:30 UTC 2016
More data I thought worth mentioning. I can create a device, but as soon as I select the Type of “SolarEdge System” and try to update the device, I get the error. Could something be wrong with the Type that I created? Below is the code I am using for the IDE
/**
- Solaredge Solar Energy Monitoring System
- Copyright 2015 David Tucker based on original code from by Carlos Santiago, Ronald Gouldner
- Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at:
-
http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
- on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
- for the specific language governing permissions and limitations under the License.
*/
preferences {
section("Enter Configuration data for your Solaredge Inverter") {
input("uri", "text", title: "Solaredge Monitor API URL", description: "https://monitoringapi.solaredge.com", required: false)
input("siteId", "text", title: "Site Id", required: true)
input("apiKey", "text", title: "API Key (get this from your Solar PV installer)", required: true)
}
}
metadata {
definition (name: “Solaredge System”, namespace: “strelitzia123”, author: “David Tucker”) {
capability "Power Meter"
capability "Energy Meter"
capability “Refresh”
//capability “Polling”
attribute "energy_today", "string"
attribute "energy_month", "number"
attribute "energy_year", "number"
attribute "energy_lifetime", "number"
attribute "production_level", "number"
fingerprint deviceId: "Solaredge"
}
simulator {
// TODO: define status and reply messages here
}
tiles {
valueTile("solar", "device.power") {
state("solarPower", label: '${currentValue}\nSolar', unit:"W", backgroundColors: [
[value: 2, color: "#32CD32"],
[value: 1, color: "#000000"],
]
)
}
valueTile("energy_today", "device.energy_today") {
state("energy_today", label: '${currentValue}\nToday', unit:"KWh", backgroundColors: [
[value: 1, color: "#bc2323"],
[value: 2, color: "#d04e00"],
[value: 5, color: "#f1d801"],
[value: 10, color: "#90d2a7"],
[value: 15, color: "#44b621"],
[value: 20, color: "#1e9cbb"],
[value: 25, color: "#153591"]
]
)
}
valueTile("energy_month", "device.energy_month") {
state("energy_month", label: '${currentValue}\nMonth', unit:"KWh", backgroundColors: [
[value: 30, color: "#bc2323"],
[value: 60, color: "#d04e00"],
[value: 150, color: "#f1d801"],
[value: 300, color: "#90d2a7"],
[value: 450, color: "#44b621"],
[value: 600, color: "#1e9cbb"],
[value: 750, color: "#153591"]
]
)
}
valueTile("energy_year", "device.energy_year") {
state("energy_year", label: '${currentValue}\nYear', unit:"MWh")
}
valueTile("energy_lifetime", "device.energy_lifetime") {
state("energy_lifetime", label: '${currentValue}\nLifetime', unit:"MWh")
}
valueTile("productionLevel", "device.production_level") {
state("productionLevel", label: '${currentValue}%\nProduction', unit:"%", backgroundColor: "#0000FF")
}
standardTile("refresh", "device.energy_today", inactiveLabel: false, decoration: "flat") {
state "default", action:"polling.poll", icon:"st.secondary.refresh"
}
main (["solar"])
details(["solar",
// “productionLevel”, // TODO coding for production level %
“energy_today”, “energy_month”, “energy_year”, “energy_lifetime”,“refresh”])
}
}
def installed() {
log.debug “Installing Solaredge Monitoring…”
refresh()
}
def updated() {
log.debug “Updating Solaredge Monitoring…”
refresh()
}
// parse events into attributes
def parse(String description) {
log.debug “Parsing ‘${description}’”
}
def poll() {
//refresh()
}
def refresh() {
log.debug "Executing ‘refresh’"
energyRefresh()
}
def energyRefresh() {
log.debug “Executing ‘energyToday’”
def cmd = “${settings.uri}/site/${settings.siteId}/overview?api_key=${settings.apiKey}”;
log.debug “Sending request cmd[${cmd}]”
httpGet(cmd) {resp ->
if (resp.data) {
log.debug “${resp.data}”
def currentsolarPower = 0
currentsolarPower = resp.data.overview.currentPower.power
log.debug "currentsolarPower :${currentsolarPower}"
def energyToday = resp.data.overview.lastDayData.energy/1000
log.debug "energyToday :${energyToday}"
log.debug "${resp.data.overview.lastMonthData.energy}"
def energyMonth = resp.data.overview.lastMonthData.energy/1000
log.debug "energyMonth :${energyMonth}"
def energyYear = resp.data.overview.lastYearData.energy/1e6
log.debug "energyYear :${energyYear}"
def energyLifetime = resp.data.overview.lifeTimeData.energy/1e6
log.debug "energyLifetime :${energyLifetime}"
delayBetween(
[sendEvent(name: 'power', value: (currentsolarPower))
,sendEvent(name: 'energy_today', value: (String.format("%5.2f", energyToday)))
,sendEvent(name: 'energy_month', value: (String.format("%5.2f", energyMonth)))
,sendEvent(name: 'energy_year', value: (String.format("%5.2f", energyYear)))
,sendEvent(name: 'energy_lifetime', value: (String.format("%5.2f", energyLifetime)))
]
)
}
}
}
Please edit your post and put code brackets around it like this
Ignore the extra spaces
[ code ]
I’m code
[ / code ]
From as best as I can tell this is the same device type I’m using.
Sorry I am a newbie. Thanks for clarifying. Code is below.
/**
* Solaredge Solar Energy Monitoring System
*
* Copyright 2015 David Tucker based on original code from by Carlos Santiago, Ronald Gouldner
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
preferences {
section("Enter Configuration data for your Solaredge Inverter") {
input("uri", "text", title: "Solaredge Monitor API URL", description: "https://monitoringapi.solaredge.com", required: false)
input("siteId", "text", title: "Site Id", required: true)
input("apiKey", "text", title: "API Key (get this from your Solar PV installer)", required: true)
}
}
metadata {
definition (name: "Solaredge System", namespace: "strelitzia123", author: "David Tucker") {
capability "Power Meter"
capability "Energy Meter"
capability "Refresh"
//capability "Polling"
attribute "energy_today", "string"
attribute "energy_month", "number"
attribute "energy_year", "number"
attribute "energy_lifetime", "number"
attribute "production_level", "number"
fingerprint deviceId: "Solaredge"
}
simulator {
// TODO: define status and reply messages here
}
tiles {
valueTile("solar", "device.power") {
state("solarPower", label: '${currentValue}\nSolar', unit:"W", backgroundColors: [
[value: 2, color: "#32CD32"],
[value: 1, color: "#000000"],
]
)
}
valueTile("energy_today", "device.energy_today") {
state("energy_today", label: '${currentValue}\nToday', unit:"KWh", backgroundColors: [
[value: 1, color: "#bc2323"],
[value: 2, color: "#d04e00"],
[value: 5, color: "#f1d801"],
[value: 10, color: "#90d2a7"],
[value: 15, color: "#44b621"],
[value: 20, color: "#1e9cbb"],
[value: 25, color: "#153591"]
]
)
}
valueTile("energy_month", "device.energy_month") {
state("energy_month", label: '${currentValue}\nMonth', unit:"KWh", backgroundColors: [
[value: 30, color: "#bc2323"],
[value: 60, color: "#d04e00"],
[value: 150, color: "#f1d801"],
[value: 300, color: "#90d2a7"],
[value: 450, color: "#44b621"],
[value: 600, color: "#1e9cbb"],
[value: 750, color: "#153591"]
]
)
}
valueTile("energy_year", "device.energy_year") {
state("energy_year", label: '${currentValue}\nYear', unit:"MWh")
}
valueTile("energy_lifetime", "device.energy_lifetime") {
state("energy_lifetime", label: '${currentValue}\nLifetime', unit:"MWh")
}
valueTile("productionLevel", "device.production_level") {
state("productionLevel", label: '${currentValue}%\nProduction', unit:"%", backgroundColor: "#0000FF")
}
standardTile("refresh", "device.energy_today", inactiveLabel: false, decoration: "flat") {
state "default", action:"polling.poll", icon:"st.secondary.refresh"
}
main (["solar"])
details(["solar",
// "productionLevel", // TODO coding for production level %
"energy_today", "energy_month", "energy_year", "energy_lifetime","refresh"])
}
}
def installed() {
log.debug "Installing Solaredge Monitoring..."
refresh()
}
def updated() {
log.debug "Updating Solaredge Monitoring..."
refresh()
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
}
def poll() {
//refresh()
}
def refresh() {
log.debug "Executing 'refresh'"
energyRefresh()
}
def energyRefresh() {
log.debug "Executing 'energyToday'"
def cmd = "${settings.uri}/site/${settings.siteId}/overview?api_key=${settings.apiKey}";
log.debug "Sending request cmd[${cmd}]"
httpGet(cmd) {resp ->
if (resp.data) {
log.debug "${resp.data}"
def currentsolarPower = 0
currentsolarPower = resp.data.overview.currentPower.power
log.debug "currentsolarPower :${currentsolarPower}"
def energyToday = resp.data.overview.lastDayData.energy/1000
log.debug "energyToday :${energyToday}"
log.debug "${resp.data.overview.lastMonthData.energy}"
def energyMonth = resp.data.overview.lastMonthData.energy/1000
log.debug "energyMonth :${energyMonth}"
def energyYear = resp.data.overview.lastYearData.energy/1e6
log.debug "energyYear :${energyYear}"
def energyLifetime = resp.data.overview.lifeTimeData.energy/1e6
log.debug "energyLifetime :${energyLifetime}"
delayBetween(
[sendEvent(name: 'power', value: (currentsolarPower))
,sendEvent(name: 'energy_today', value: (String.format("%5.2f", energyToday)))
,sendEvent(name: 'energy_month', value: (String.format("%5.2f", energyMonth)))
,sendEvent(name: 'energy_year', value: (String.format("%5.2f", energyYear)))
,sendEvent(name: 'energy_lifetime', value: (String.format("%5.2f", energyLifetime)))
]
)
}
}
}
So in the IDE on the right hand side there is a simulator.
- In the devices section of the IDE go to your SolarEdge device and click on it and go to the preferences and make sure all of the fields are filled in.
- Go to the device handlers and click on the SolarEdge DH. On the right hand side is the simulator. Select your location and click go. Then select the SolarEdge device and tell it to run. See if it populates there then also watch the logs on the bottom of the screen and see what you can see in there. If you see something of relevance post it back in here.
Brad,
No fix yet, but support asked where I got the customed code, and I provided this thread. I’ll update you as soon as I get a reply from them.
Jason,
Maybe I am missing something. But my device of SolarEdge is not attached to the type of my SolarEdge DH. Because I cannot save my device as this type, it fails. So running the simulator doesn’t really do any good, right? Just for giggles, I went ahead and ran the simulator twice. Once as a virtual and got these errors:
57ee36ab-ed39-4b98-8b30-47a3b756920b 1:15:40 PM: error java.lang.SecurityException: Endpoint null/site/null/overview?api_key=null is blacklisted. @ line 138
57ee36ab-ed39-4b98-8b30-47a3b756920b 1:15:40 PM: debug Sending request cmd[null/site/null/overview?api_key=null]
57ee36ab-ed39-4b98-8b30-47a3b756920b 1:15:40 PM: debug Executing ‘energyToday’
57ee36ab-ed39-4b98-8b30-47a3b756920b 1:15:40 PM: debug Executing ‘refresh’
57ee36ab-ed39-4b98-8b30-47a3b756920b 1:15:40 PM: debug Installing Solaredge Monitoring…
1:15:29 PM: info Waiting on events…
1:15:29 PM: info For past logs for individual things go to the My Devices section, find the device and click on the Events link on the device information page.
1:15:29 PM: info This console provides live logging of your SmartThings.
On the second pass, I chose my SolarEdge Device, although this device is currently set as an ‘Acceleration Sensor Capability’. Below is the log for that. In both cases I see a java error. Not sure if this is my PC or the code in question.
524dc778-c4bd-4c4e-968b-5c84f65b8615 1:17:02 PM: error java.lang.SecurityException: Endpoint null/site/null/overview?api_key=null is blacklisted. @ line 138
524dc778-c4bd-4c4e-968b-5c84f65b8615 1:17:02 PM: debug Sending request cmd[null/site/null/overview?api_key=null]
524dc778-c4bd-4c4e-968b-5c84f65b8615 1:17:02 PM: debug Executing ‘energyToday’
524dc778-c4bd-4c4e-968b-5c84f65b8615 1:17:02 PM: debug Executing ‘refresh’
524dc778-c4bd-4c4e-968b-5c84f65b8615 1:17:02 PM: debug Updating Solaredge Monitoring…
I think I may have answered my own question after actually looking at the java error. I thought the API key would be entered on the mobile, but it appears from the error that the NULL value is being blocked by the SolarEdge servers. Is this accurate? Perhaps I should try plugging in my actual API_KEY value in the code?
Don’t plug it into the code. Just leave the code as it is.
If you can save your code and publish it. In the IDE go to My Devices
Click on your SolarEdge Device
In the device where it says preferences click on edit
Fill in the 3 fields with your information. Yes the URL does need to be filled in. Make sure that you have your siteID and API key. Once you have all of that give the simulator a whirl.
When I first tried installing this a few weeks ago, I kept getting an error on the initial setup and couldn’t get through it. I eventually commented out the call to refresh() inside installed(), because at that point the preferences weren’t set so there was no API key. After I did that, I was able to get it installed and configured.
There’s also a bug in the standardTile for “refresh”, where the action is incorrectly listed as polling.poll when it should be refresh.refresh:
- state "default", action:"polling.poll", icon:"st.secondary.refresh"
+ state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
With that, the refresh() tile now works when you press it. I also did some whitespace cleanup and changed Solaredge=>SolarEdge.
My version is here: https://github.com/loverso/SmartThingsDev/blob/master/devicetypes/strelitzia123/solaredge-system.src/solaredge-system.groovy
Nice work jlv have you considered merging your changes with @djtucker? I know that @bridaus committed a few changes to the original code. Love the community working together to take care of each other.
Jason,
Thanks for your help.
I was able to use the code that John provided and I deleted my Device HD and Device. Recreated the Device HD from Johns code and then tried to update my device, but it still failed. So I completely deleted my device and recreated without error. Now all I need to do is get my API_KEY and be on my way. This is AWESOME! Thanks.
Now I have a Aeon Labs Energy Monitor coming tonight which I am going to hook up to the Main panel. Hopefully I can then incorporate the two with the Rule Machine. Thanks everyone!
One last question…Do I need to use Pollster to refresh?
I use pollster to refresh so it does it every 10 mins. Like its mentioned above they do have a limit of 300 calls per day. I think that every 10 mins is sufficent and then I setup pollster to only run during the day.
With that Aeon energy meter make sure you pay attention to the arrows on the clamps that one goes up and one goes down. Most importantly be careful inside your breaker panel
Mine seemed like it was frozen and not showing the same data as the native solar app even after I hit refresh. I put @jlv code in and getting no values now…
Thanks @jlv for the code and thanks @TheFuzz4 for the instructions. I was able to add Device Type with no issues after using John’s code. I see data now after following Jason’s step.
Thanks @djtucker for starting the code as well!
This community is awesome!!!
Thanks Everyone! You guys rock!
@TheFuzz4 Technology First, Safety second, right? LOL
Folks I think I’m going to take a step back from this code now. I’m glad the first version has helped others in the community to make better use of their systems, but it is clear to me from lots of the discussion that I am way out of my depth with lots of the technicalities … I just hack around to find something that works, which is OK for me individually, but not really acceptable to inflict on to other innocent folks.
I am also really respectful of those other members of the community who have helped each other to get their devices working, something which it is clear I could not have done myself. It does however bother me that the inadequacies in my coding are causing problems that others are having to step in to fix.
I have just sown the seed, and if someone wants to nurture it and grow it into something bigger and far better than I could create, that is ok.
I think I am sooo close here. I got my API_KEY from SolarEdge directly. I got my site ID from my monitoring page. But when I plug these into the my device on the app, I try to click done and it appears to work, but then says “An unexpected error occurred”. Any ideas?
I was able to add my Site ID, API Key inside of my device on the portal. Now running the simulator and I get this:
30a9d00e-5832-4d51-816e-ba0e57098b1a 7:50:16 PM: error groovyx.net.http.HttpResponseException: Forbidden @ line 136
30a9d00e-5832-4d51-816e-ba0e57098b1a 7:50:15 PM: debug Sending request cmd[https://monitoringapi.solaredge.com/site/210615/overview?api_key=BIRJIFXJTZAPVLB6DRH84TO5RYRME0BN]
30a9d00e-5832-4d51-816e-ba0e57098b1a 7:50:15 PM: debug SolarEdge energyRefresh
30a9d00e-5832-4d51-816e-ba0e57098b1a 7:50:15 PM: debug zipcode 91224
30a9d00e-5832-4d51-816e-ba0e57098b1a 7:50:15 PM: debug SolarEdge refresh
30a9d00e-5832-4d51-816e-ba0e57098b1a 7:50:16 PM: error groovyx.net.http.HttpResponseException: Forbidden @ line 136
30a9d00e-5832-4d51-816e-ba0e57098b1a 7:50:15 PM: debug Sending request cmd[https://monitoringapi.solaredge.com/site/210615/overview?api_key=BIRJIFXJTZAPVLB6DRH84TO5RYRME0BN]
Looks Like 136 reads like this:
[/code]
def energyRefresh() {
log.debug “SolarEdge energyRefresh”
def cmd = "${settings.uri}/site/${settings.siteId}/overview?api_key=${settings.apiKey}";
** log.debug “Sending request cmd[${cmd}]”**
httpGet(cmd) {resp ->
if (resp.data) {
log.debug "${resp.data}"
[/code]