Solaredge Device Type?

Hi Gents,

I was wondering if you guys can post a screenshot, thanks in advance.

Scroll all the way down on the settings screen (after you’ve added Pollster). “Set for specific modes” is at the bottom.

Mine didn’t update for a few days. Not sure why, but just ran it in the simulator and then it updated it just fine. Weird.

I’m probably going to do some more work on this device type in the next few days - please let me know if you have any suggested changes / additions / requests, and I’ll see whether I can incorporate any.

1 Like

Is there anyway you can incorporate production from the solaredge vs. usage from an energy meter?

I was looking into using Rule Machine to refresh this only between sunrise and sunset, rather than Pollster. But I’ve also been looking over other device code and the ST APIs. Why not just use runEvery15Minutes() to call refresh(), and stop doing so after dusk; e.g., I see that in the new open-source ecobee3 device:

This thread contains somewhat similar code (although he’s using runIn()), and handles the dawn/dusk.

2 Likes

Thank you so much for sharing @djtucker,

I encountered a 500: Internal Server Error. I searched the community found one but that support solved his issue on the backend, I already sent an email to support. One thread also mentioned about issue with his github repository, I’m currently checking on it right now. Seeking help here as well. On side note, I added another device type using other device handler and it worked successfully.

Also another question what do you need to enter on “Device Network ID”

Oh No! Something Went Wrong!
Error
500: Internal Server Error
URI
/device/save
Reference Id
xxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxxxx
Date
Thu Jan 21 15:58:52 UTC 2016

There is a lot of additional platform instability at the moment - I have had various unexplained outages and IDE issues over the last few days, i.e. more than is normal for SmartThings. So its hard to know if the problem stems from the platform or from the DeviceType.

The Device Network ID is actually not important for this, as the code does not look for your device on the network - instead it is reading all its data from the Solaredge cloud via their API. You do have to put domething in, so I just called mine “Solaredge1”. In my mind it is probably better practice to call the device “Solaredge:My_Site_Id”

The network ID just needs to be unique on your hub, so any value is fine. My is just “SolarEdge”.

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.

  1. 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.
  2. 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. :slight_smile:

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

1 Like

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.

1 Like