Skip to content

Commit

Permalink
Merge pull request #60 from nilrog/gen24
Browse files Browse the repository at this point in the history
Support for Gen24 inverter
  • Loading branch information
safepay committed Aug 31, 2021
2 parents 5555504 + 284a27c commit 5c0c679
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This component simplifies the integration of a Fronius inverter and optional Pow
* rounds values to 2 decimal places
* converts yearly and total energy data to kWh or MWh (user-configurable)
* optionally sums values if you have more than one inverter
* supports the new Gen24 inverter (some sensors differs from Symo)

If you have a SmartMeter installed this component:
* optionally connects to PowerFlow API for 5 additional sensors
Expand Down Expand Up @@ -91,6 +92,7 @@ variable | required | type | default | description
-------- | -------- | ---- | ------- | -----------
``ip_address`` | yes | string | | The local IP address of your Fronius Inverter.
``name`` | no | string | ``Fronius`` | The preferred name of your Fronius Inverter.
``model`` | no | string | ``symo`` | Type of inverter from ``gen24, symo``
``always_log`` | no | boolean | ``True`` | Set to ``False`` if your Fronius Inverter shuts down when the sun goes down.
``scan_interval`` | no | string | 60 | The interval to query the Fronius Inverter for data.
``powerflow`` | no | boolean | ``False`` | Set to ``True`` if you have a PowerFlow meter (SmartMeter) to add ``grid_usage``, ``house_load``, ``panel_status``, ``rel_autonomy`` and ``rel_selfconsumption`` sensors.
Expand Down
2 changes: 1 addition & 1 deletion custom_components/fronius_inverter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"dependencies": [],
"codeowners": ["@safepay"],
"requirements": [],
"version": "v0.9.6"
"version": "v0.9.7"
}
30 changes: 27 additions & 3 deletions custom_components/fronius_inverter/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
from homeassistant.util import dt as dt_util
from homeassistant.helpers.sun import get_astral_event_date

_INVERTERRT = 'http://{}/solar_api/v1/GetInverterRealtimeData.cgi?Scope={}&DeviceId={}&DataCollection=CommonInverterData'
_INVERTERRT_URL = 'http://{}/solar_api/v1/GetInverterRealtimeData.cgi?Scope={}&DeviceId={}&DataCollection=CommonInverterData'
_POWERFLOW_URL = 'http://{}/solar_api/v1/GetPowerFlowRealtimeData.fcgi'
_METER_URL = 'http://{}/solar_api/v1/GetMeterRealtimeData.cgi?Scope={}&DeviceId={}'
#_INVERTERRT = 'http://{}{}?DeviceId={}&DataCollection=CommonInverterData'
#_INVERTERRT_URL = 'http://{}{}?DeviceId={}&DataCollection=CommonInverterData'
#_POWERFLOW_URL = 'http://{}PowerFlow'
_LOGGER = logging.getLogger(__name__)

ATTRIBUTION = "Fronius Inverter Data"

CONF_NAME = 'name'
CONF_IP_ADDRESS = 'ip_address'
CONF_MODEL = 'model'
CONF_DEVICE_ID = 'device_id'
CONF_SCOPE = 'scope'
CONF_UNITS = 'units'
Expand All @@ -50,6 +51,7 @@
SCOPE_TYPES = ['Device', 'System']
UNIT_TYPES = ['Wh', 'kWh', 'MWh']
POWER_UNIT_TYPES = ['W', 'kW', 'MW']
MODEL_TYPES = ['symo', 'gen24']

# Key: ['device', 'system', 'json_key', 'name', 'unit', 'convert_units', 'icon']
SENSOR_TYPES = {
Expand All @@ -76,9 +78,22 @@
'smartmeter_energy_ac_consumed': ['smartmeter', False, 'EnergyReal_WAC_Sum_Consumed', 'SmartMeter Energy AC Consumed', 'Wh', 'energy', 'mdi:solar-power'],
'smartmeter_energy_ac_sold': ['smartmeter', False, 'EnergyReal_WAC_Sum_Produced', 'SmartMeter Energy AC Sold', 'Wh', 'energy', 'mdi:solar-power']
}
# the gen24 inverter has different names for some sensors
SENSOR_TYPES_GEN24 = {
'smartmeter_current_ac_phase_one': ['smartmeter', False, 'ACBRIDGE_CURRENT_ACTIVE_MEAN_01_F32', 'SmartMeter Current AC Phase 1', 'A', False, 'mdi:solar-power'],
'smartmeter_current_ac_phase_two': ['smartmeter', False, 'ACBRIDGE_CURRENT_ACTIVE_MEAN_02_F32', 'SmartMeter Current AC Phase 2', 'A', False, 'mdi:solar-power'],
'smartmeter_current_ac_phase_three': ['smartmeter', False, 'ACBRIDGE_CURRENT_ACTIVE_MEAN_03_F32', 'SmartMeter Current AC Phase 3', 'A', False, 'mdi:solar-power'],
'smartmeter_voltage_ac_phase_one': ['smartmeter', False, 'SMARTMETER_VOLTAGE_01_F64', 'SmartMeter Voltage AC Phase 1', 'V', False, 'mdi:solar-power'],
'smartmeter_voltage_ac_phase_two': ['smartmeter', False, 'SMARTMETER_VOLTAGE_02_F64', 'SmartMeter Voltage AC Phase 2', 'V', False, 'mdi:solar-power'],
'smartmeter_voltage_ac_phase_three': ['smartmeter', False, 'SMARTMETER_VOLTAGE_03_F64', 'SmartMeter Voltage AC Phase 3', 'V', False, 'mdi:solar-power'],
'smartmeter_energy_ac_consumed': ['smartmeter', False, 'SMARTMETER_ENERGYACTIVE_CONSUMED_SUM_F64', 'SmartMeter Energy AC Consumed', 'Wh', 'energy', 'mdi:solar-power'],
'smartmeter_energy_ac_sold': ['smartmeter', False, 'SMARTMETER_ENERGYACTIVE_PRODUCED_SUM_F64', 'SmartMeter Energy AC Sold', 'Wh', 'energy', 'mdi:solar-power']
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_IP_ADDRESS): cv.string,
vol.Optional(CONF_MODEL, default="symo"):
vol.In(MODEL_TYPES),
vol.Optional(CONF_DEVICE_ID, default='1'): cv.string,
vol.Optional(CONF_NAME, default='Fronius'): cv.string,
vol.Optional(CONF_SCOPE, default='Device'):
Expand All @@ -100,6 +115,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=

session = async_get_clientsession(hass)
ip_address = config[CONF_IP_ADDRESS]
model = config[CONF_MODEL]
device_id = config.get(CONF_DEVICE_ID)
scope = config.get(CONF_SCOPE)
units = config.get(CONF_UNITS)
Expand All @@ -111,6 +127,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
scan_interval = config.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
always_log = config.get(CONF_ALWAYS_LOG)

if model == 'gen24':
_LOGGER.debug("GEN24 configured, updating sensor list")
# update sensors since gen24 has different names for some of them
for variable in SENSOR_TYPES:
if variable in SENSOR_TYPES_GEN24:
SENSOR_TYPES[variable] = SENSOR_TYPES_GEN24[variable]
_LOGGER.debug(SENSOR_TYPES)

fetchers = []
inverter_data = InverterData(session, ip_address, device_id, scope)
fetchers.append(inverter_data)
Expand Down Expand Up @@ -389,7 +413,7 @@ class InverterData(FroniusFetcher):

def _build_url(self):
"""Build the URL for the requests."""
url = _INVERTERRT.format(self._ip_address, self._scope, self._device_id)
url = _INVERTERRT_URL.format(self._ip_address, self._scope, self._device_id)
_LOGGER.debug("Fronius Inverter URL: %s", url)
return url

Expand Down

0 comments on commit 5c0c679

Please sign in to comment.