[Request] Fronius Inverter Support?

It's public. No registration required to get the code.

1 Like

What can I say IT Security habits LOL :stuck_out_tongue:

1 Like

Thanks mate, sorry total noob. I've installed the driver. Should i be detecting this as a lan device? Or setting up a http get in maker ? All my xiaomi zigbee devices just detected instantly after installing driver

You need to select virtual device then select the driver and type in your details.

Perfect mate its working! Now to see if i can get hubitat to start my dishwasher/washing machine when it reaches a certain output.

I found this smarthings driver for fronius with smart meter so im going to have a go at porting it

2 Likes

Excellent, if you get it going we can post it up for all with the other one.

Hi all, I just added "capability "Sensor"" to the driver so it can support HubiGraph here. You can find the updated driver here.

2 Likes

awesome mate will test this out

1 Like

How did you go with porting this one mate?

couldnt get it working but didnt spend long on it. unfortunately i have no idea what im doing. :frowning:

1 Like

@anon61068208 @jchurch when I click in the link I go to this page. No options for sign up and if I click in " There are public projects listed [here]" I can't find this project. Is there anotrher way to get this code? Thank you

Repo has been deleted. @jchurch was banned from here and on my hosted repository. You will have to contact Jason at oh-la labs for the code.

@Evilborg thanks for the tip, I got the driver. After insert the IP and port, save and click in refresh this log appears. Any idea what is going on? I am using port 80.

Again you need to talk to Jason about this device. This is his code not mine.

Hi All.
I have the fronius Symo + Smart meter working in my updated version of Tim Flinders / JChruch's fronius driver.
It also goes to 'sleep' overnight when the invertor shuts down. (Reduces to 30 min poll time)
I haven't gone as far as reading voltage and current (that the smart meter also supports), but if there's interest I might do it.
This is my first attempt at coding anything in groovy, so if you see some improvements, please share and be nice.

Thanks

/**
 *  Fronius Solar Inverter
 *
 *  Copyright 2015 Tim Flinders
 *
 *  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.
 *
 *  EDITED by jchurch to include runEvery15Minutes(refresh) - 02/20
 *  EDITED by jchurch and Markus to include ErrorCode information and clean up ported code for Hubitat slightly - 02/20
 *  EDITED by jchurch and Markus to include kWh conversation for energy stat - 02/21
 *  Updates by HardyM to give 1 min updates, reduce to 30 mins polls overnight, and also return data from Fronius SmartMeter to give Grid power and Load. 2021-07-25
 *  Dec 18,2021.  Added attribute access to pGrid and pLoad. (HardyM)
 Sourced from here
 https://github.com/jchurchward/Fronius-Solar-Inverter/blob/main/Fronius-solar-inverter-driver
 
 */
 
import groovy.json.JsonSlurper
 
preferences {
	input("inverterNumber", "number", title: "Inverter Number", description: "The Inverter Number", required: true, displayDuringSetup: true)
    input("destIp", "text", title: "IP", description: "The device IP", required: true, displayDuringSetup: true)
    input("destPort", "number", title: "Port", description: "The port you wish to connect", required: true, displayDuringSetup: true)
}

metadata {
	definition (name: "Fronius Solar Inverter", namespace: "TimFlinders", author: "Tim Flinders") {
	capability "Polling"
        capability "Power Meter"
        capability "Energy Meter"
        capability "Actuator"
        capability "Refresh"
        capability "Sensor"
        attribute "errorCode", "number"
        attribute "pGrid", "number"
        attribute "pLoad", "number"
	}
}

def initialize() {
	log.info "Fronius Inverter ${textVersion()} ${textCopyright()}"
    sendEvent(name: "power", value: 0	)
    sendEvent(name: "YearValue", value: 0 )
    sendEvent(name: "energy", value: 0 )
    sendEvent(name: "pGrid", value: 0 )
    sendEvent(name: "pLoad", value: 0 )
    sendEvent(name: "TotalValue", value: 0 )
    state.parseCallCounter=0
//    updated()
	poll()
}


// parse events into attributes
def parse(String description) {	
    def msg = parseLanMessage(description)

	def slurper = new JsonSlurper()
    def result = slurper.parseText(msg.body)
    def errorCode = result?.Body?.Data?."$inverterNumber"?.ErrorCode
    if(errorCode != null) {
        sendEvent(name: "errorCode", value: errorCode )
    } else {
        sendEvent(name: "errorCode", value: 0 )
            
        int yearValue = result.Body.Data.Site.E_Year
        int dayValue = result.Body.Data.Site.E_Day
        int totalValue = result.Body.Data.Site.E_Total
        int pGrid = result.Body.Data.Site.P_Grid
        int pLoad = result.Body.Data.Site.P_Load
        pLoad = -pLoad
        def pPV = result.Body.Data.Site.P_PV
        int power
        if (pPV == null) {
            power = 0
        } else {
            power = pPV
        }
        sendEvent(name: "power", value: power, unit: "W" )
        sendEvent(name: "energy", value: dayValue, unit: "Wh")
        sendEvent(name: "eYear", value: Math.round(yearValue/100)/10, unit: "kWH")
        sendEvent(name: "TotalEnergy", value: Math.round(totalValue/100)/10, unit: "kWH")
        sendEvent(name: "pGrid", value: pGrid, unit: "W")
        sendEvent(name: "pLoad", value: pLoad, unit: "W")
        //Keep track of when the last update came in
        if (state.parseCallCounter>0)
        {
            updated()    // reset the poll timer back to 1 min if we got an answer
            sendEvent(name: "Status", value: "Online")
        }
        state.parseCallCounter=0
    }
}

// handle commands
def poll() {
    if (state.parseCallCounter==null) {
        state.parseCallCounter=1
    } else {
        state.parseCallCounter++
    }
    if (state.parseCallCounter==3)
    {
        // Not getting Fronius's replies so could be sleeping.  Set the timer with 30 min interval
        sendEvent(name: "Status", value: "Not Responding")
        unschedule(refresh)
        schedule('0 */30 * ? * *', refresh)
    }
    callInvertor()
}


def callInvertor() {
	try
    {
	def hosthex = convertIPtoHex(destIp)
    def porthex = convertPortToHex(destPort)
    device.deviceNetworkId = "$hosthex:$porthex" 

    sendHubCommand(new hubitat.device.HubAction(
   	 		'method': 'GET',
    		'path': "/solar_api/v1/GetInverterInfo.cgi?Scope=System",
        	'headers': [ HOST: "$destIp:$destPort" ]
		))

    def hubAction = new hubitat.device.HubAction(
   	 		'method': 'GET',
    		'path': "/solar_api/v1/GetPowerFlowRealtimeData.fcgi",
        	'headers': [ HOST: "$destIp:$destPort" ]
		) 
    hubAction
    }
    catch (Exception e) {
        log.debug "Hit Exception $e on $hubAction"
    }
}

private def textVersion() {
    def text = "Version 1.0"
}

private def textCopyright() {
    def text = "Copyright Β© 2015 Tim Flinders"
}

private String convertIPtoHex(ipAddress) { 
    String hex = ipAddress.tokenize( '.' ).collect {  String.format( '%02X', it.toInteger() ) }.join()
    return hex
}

private String convertPortToHex(port) {
	String hexport = port.toString().format( '%04X', port.toInteger() )
    return hexport
}

def refresh(){
    poll()
}

def updated(){
    unschedule(refresh)
    schedule('0 */1 * ? * *', refresh)
    state.parseCallCounter=0
}

Hi, is there a way of using ”pGrid” value in a rule, in order to activate a socket when there is enough power produced? Thanks!

I think so. Sorry for the delay,
I think you need to make a variable in the rule machine where you can assign any parameter's value to the variable. Then use the variable in your rules.
See if that helps. If not - let me know and I'll experiment with it.

I can only set 2 types of data to a variable: sensor value (ENERGY METER and POWER METER are available from Fronius driver) or device attribute (energy, error code and power are available).
Any idea how I get to use pGrid?

ok. Looks like this works, but you need to add these two attribute lines near the top of the driver code. Add them immediately after the attribute "errorCode" line.
attribute "pGrid", "number"
attribute "pLoad", "number"
(I have updated the code in my original post with these mods)
Then, I would advise watch the driver until the next update comes through and the attribute values display.
Following this, I could select these attributes (like pGrid) in a rule for assigning values or creating conditions.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.