Fronius inverter integration

That works returns - but errors
{
“Body” : {
“Data” : {}
},
“Head” : {
“RequestArguments” : {
“DataCollection” : “”,
“DeviceClass” : “Inverter”,
“DeviceId” : “”,
“Scope” : “Device”
},
“Status” : {
“Code” : 6,
“Reason” : “CGI-Args: Invalid parameter ‘’ for attribute ‘DataCollection’ (use ‘3PInverterData’, ‘CommonInverterData’, ‘CumulationInverterData’, ‘MinMaxInverterData’)”,
“UserMessage” : “”
},
“Timestamp” : “2019-07-07T17:38:25+12:00”
}
}

Was able to get info using
/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceId=1&DataCollection=CommonInverterData

ie removed spaces
so mine ended up being id 1 to get info
what is the syntax for setting the id device: “1” - ?

Get the below error now so getting closer
Error while setting up platform fronius
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, in wait_for
return fut.result()
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/fronius/sensor.py”, line 73, in setup_platform
fronius_data.update()
File “/usr/src/homeassistant/homeassistant/util/init.py”, line 224, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/fronius/sensor.py”, line 176, in update
self._data = result[‘Data’]
KeyError: ‘Data’

Yep I get this

Have I missed something
`
platform: fronius

ip_address: 192.168.0.xxx
device: 1
monitored_conditions:
- ac_power
- ac_current
- ac_voltage
- ac_frequency
- dc_current
- dc_voltage
- day_energy
- year_energy
- total_energy`
is this the sensor?

Capture

Make sure you use the latest code as device has changed to device_id.

In configuration.yaml

under the ip_address line with the same indent put
device_id: 1

sensor
  - platform: fronius
    ip_address: 192.168.0.XXX
    device_id: 1

In your URL replace the URL encoded bit with an ampersand “&”

Thanks Kelvin,

Could you post the output from the URL in your browser please?

Sorry. What you’re mean with ampersand “&” ?
I added " around the IP
error

Error while setting up platform fronius
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/fronius/sensor.py", line 73, in setup_platform
    fronius_data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 224, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/fronius/sensor.py", line 176, in update
    self._data = result['Data']
KeyError: 'Data

output of /solar_api/v1/GetPowerFlowRealtimeData.fcgi?Scope=Device&DeviceId%20=1&%20DataCollection=CommonInverterData

{
   "Body" : {
      "Data" : {
         "Inverters" : {
            "1" : {
               "DT" : 76,
               "E_Day" : 20372,
               "E_Total" : 9561240,
               "E_Year" : 5230560.5,
               "P" : 0
            }
         },
         "Site" : {
            "E_Day" : 20372,
            "E_Total" : 9561240,
            "E_Year" : 5230560.5,
            "Meter_Location" : "unknown",
            "Mode" : "produce-only",
            "P_Akku" : null,
            "P_Grid" : null,
            "P_Load" : null,
            "P_PV" : 0,
            "rel_Autonomy" : null,
            "rel_SelfConsumption" : null
         },
         "Version" : "11"
      }
   },
   "Head" : {
      "RequestArguments" : {},
      "Status" : {
         "Code" : 0,
         "Reason" : "",
         "UserMessage" : ""
      },
      "Timestamp" : "2019-07-07T17:03:59+10:00"
   }
}```

Remove the "%20"s from your URL. They are breaking it.

http://IP_ADDRESS/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceId=1&DataCollection=CommonInverterData

This is different to the GetPowerFlowRealtimeData.
Is that what you would prefer in the component?

That is not the sensor.
I can’t really tell from that post what your config looks like without formatting.
To test try:

sensor
  - platform: fronius
    ip_address: 192.168.0.XXX
    device_id: 1

or again, try the correct test URL:

http://IP_ADDRESS/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceId=1&DataCollection=CommonInverterData

Here you go info from the URL, but still error in home assistant

{
   "Body" : {
      "Data" : {
         "DAY_ENERGY" : {
            "Unit" : "Wh",
            "Value" : 1183.0999999999999
         },
         "DeviceStatus" : {
            "ErrorCode" : 0,
            "LEDColor" : 2,
            "LEDState" : 0,
            "MgmtTimerRemainingTime" : -1,
            "StateToReset" : false,
            "StatusCode" : 7
         },
         "FAC" : {
            "Unit" : "Hz",
            "Value" : 49.979999999999997
         },
         "IAC" : {
            "Unit" : "A",
            "Value" : 5.6799999999999997
         },
         "IDC" : {
            "Unit" : "A",
            "Value" : 6.9199999999999999
         },
         "PAC" : {
            "Unit" : "W",
            "Value" : 1304
         },
         "TOTAL_ENERGY" : {
            "Unit" : "Wh",
            "Value" : 12549250
         },
         "UAC" : {
            "Unit" : "V",
            "Value" : 229.80000000000001
         },
         "UDC" : {
            "Unit" : "V",
            "Value" : 227.59999999999999
         },
         "YEAR_ENERGY" : {
            "Unit" : "Wh",
            "Value" : 2289530.75
         }
      }
   },
   "Head" : {
      "RequestArguments" : {
         "DataCollection" : "CommonInverterData",
         "DeviceClass" : "Inverter",
         "DeviceId" : "1",
         "Scope" : "Device"
      },
      "Status" : {
         "Code" : 0,
         "Reason" : "",
         "UserMessage" : ""
      },
      "Timestamp" : "2019-07-08T11:02:46+12:00"
   }
}

Thanks.

Please use the latest code.

It now also defaults to deviceID 1

Note that if you want to change device id the config is now:

device_id: 1

Will try now thanks

Tried but new error now
just using basic setting in sensor

 - platform: fronius
   ip_address: 192.168.0.##
Log Details (ERROR)
Mon Jul 08 2019 11:18:04 GMT+1200 (NZST)

fronius: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 377, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/fronius/sensor.py", line 141, in update
    self._state = round(self._data.latest_data[self._json_key].get("Value"), 3)
TypeError: 'NoneType' object is not subscriptable

That’s a bit confusing.

I have removed the rounding for the values, so please try again when you are ready.

Sorry still no luck

Log Details (ERROR)
Mon Jul 08 2019 11:38:04 GMT+1200 (NZST)

fronius: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 377, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/fronius/sensor.py", line 139, in update
    self._state = self._data.latest_data[self._json_key].get("Value") / 1000
TypeError: 'NoneType' object is not subscriptable

this what I getting after updating it too.
Mon Jul 08 2019 09:56:40 GMT+1000 (Australian Eastern Standard Time) Invalid config for [sensor.fronius]: [device] is an invalid option for [sensor.fronius]. Check: sensor.fronius->device. (See /config/sensors.yaml, line 22). Please check the docs at https://home-assistant.io/components/sensor.fronius/ Connection lost. Reconnecting…
URL works
`
{

“Body” : {
“Data” : {
“DAY_ENERGY” : {
“Unit” : “Wh”,
“Value” : 2220.5999999999999
},
“DeviceStatus” : {
“ErrorCode” : 0,
“LEDColor” : 2,
“LEDState” : 0,
“MgmtTimerRemainingTime” : -1,
“StateToReset” : false,
“StatusCode” : 7
},
“FAC” : {
“Unit” : “Hz”,
“Value” : 50
},
“IAC” : {
“Unit” : “A”,
“Value” : 5.3799999999999999
},
“IDC” : {
“Unit” : “A”,
“Value” : 3.9199999999999999
},
“PAC” : {
“Unit” : “W”,
“Value” : 1312
},
“TOTAL_ENERGY” : {
“Unit” : “Wh”,
“Value” : 9563460
},
“UAC” : {
“Unit” : “V”,
“Value” : 243.80000000000001
},
“UDC” : {
“Unit” : “V”,
“Value” : 346.80000000000001
},
“YEAR_ENERGY” : {
“Unit” : “Wh”,
“Value” : 5232781.5
}
}
},
“Head” : {
“RequestArguments” : {
“DataCollection” : “CommonInverterData”,
“DeviceClass” : “Inverter”,
“DeviceId” : “1”,
“Scope” : “Device”
},
“Status” : {
“Code” : 0,
“Reason” : “”,
“UserMessage” : “”
},
“Timestamp” : “2019-07-08T09:48:57+10:00”
}
}
`

Aaron, change device to device_id in your config (or just delete that line as it defaults to 1 now).

yep don’t trhanks but Stii the same as @Kelvin_Sudlow

Mon Jul 08 2019 10:02:57 GMT+1000 (Australian Eastern Standard Time) fronius: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 377, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/fronius/sensor.py", line 141, in update self._state = self._data.latest_data[self._json_key].get("Value") TypeError: 'NoneType' object is not subscriptable

I don’t now much about code but was look at the rest sensors its it has .fcgi at the end.

Capture