Skip to content

Commit

Permalink
[fronius] Support multiple inverters in powerflow data (#15431)
Browse files Browse the repository at this point in the history
* [fronius] Support multiple inverters in powerflow data

---------

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
  • Loading branch information
jimtng authored Oct 19, 2023
1 parent 18ae9d4 commit fa94100
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 75 deletions.
18 changes: 10 additions & 8 deletions bundles/org.openhab.binding.fronius/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ The binding has no configuration options, all configuration is done at `bridge`,
| ------------------------------------ | ------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| `inverterdatachannelpac` | Number:Power | AC Power generated |
| `inverterdatachannelpdc` | Number:Power | DC Power calculated from DC voltage * DC current |
| `inverterdatachannelpdc2` | Number:Power | DC Power 2 calculated from DC voltage 2 * DC current 2 |
| `inverterdatachannelpdc3` | Number:Power | DC Power 3 calculated from DC voltage 3 * DC current 3 |
| `inverterdatachannelpdc2` | Number:Power | DC Power generated by MPPT tracker 2 |
| `inverterdatachannelpdc3` | Number:Power | DC Power generated by MPPT tracker 3 |
| `inverterdatachannelfac` | Number:Frequency | AC frequency |
| `inverterdatachanneliac` | Number:ElectricCurrent | AC current |
| `inverterdatachannelidc` | Number:ElectricCurrent | DC current |
| `inverterdatachannelidc2` | Number:ElectricCurrent | DC current 2 |
| `inverterdatachannelidc3` | Number:ElectricCurrent | DC current 3 |
| `inverterdatachannelidc2` | Number:ElectricCurrent | DC current of MPPT tracker 2 |
| `inverterdatachannelidc3` | Number:ElectricCurrent | DC current of MPPT tracker 3 |
| `inverterdatachanneluac` | Number:ElectricPotential | AC voltage |
| `inverterdatachanneludc` | Number:ElectricPotential | DC voltage |
| `inverterdatachanneludc2` | Number:ElectricPotential | DC voltage 2 |
| `inverterdatachanneludc3` | Number:ElectricPotential | DC voltage 3 |
| `inverterdatachanneludc2` | Number:ElectricPotential | DC voltage of MPPT tracker 2 |
| `inverterdatachanneludc3` | Number:ElectricPotential | DC voltage of MPPT tracker 3 |
| `inverterdatachanneldayenergy` | Number:Energy | Energy generated on current day |
| `inverterdatachannelyear` | Number:Energy | Energy generated in current year |
| `inverterdatachanneltotal` | Number:Energy | Energy generated overall |
Expand All @@ -85,8 +85,10 @@ The binding has no configuration options, all configuration is done at `bridge`,
| `powerflowchannelppv` | Number:Power | Solar Power (+ production) |
| `powerflowautonomy` | Number:Dimensionless | The current relative autonomy in % |
| `powerflowselfconsumption` | Number:Dimensionless | The current relative self consumption in % |
| `powerflowinverter1power` | Number:Power | Current power of inverter 1, null if not running (+ produce/export, - consume/import) |
| `powerflowinverter1soc` | Number:Dimensionless | Current state of charge of inverter 1 in percent |
| `powerflowinverterpower` | Number:Power | Current power of the inverter, null if not running (+ produce/export, - consume/import) |
| `powerflowinvertersoc` | Number:Dimensionless | Current state of charge of the battery connected to the inverter in percent. |
| `powerflowinverter1power` | Number:Power | Current power of inverter 1, null if not running (+ produce/export, - consume/import) - DEPRECATED |
| `powerflowinverter1soc` | Number:Dimensionless | Current state of charge of inverter 1 in percent - DEPRECATED |

### Channels for `meter` Thing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public class FroniusBindingConstants {
public static final String POWER_FLOW_AUTONOMY = "powerflowautonomy";
public static final String POWER_FLOW_SELF_CONSUMPTION = "powerflowselfconsumption";

public static final String POWER_FLOW_INVERTER_POWER = "powerflowinverterpower";
public static final String POWER_FLOW_INVERTER_SOC = "powerflowinvertersoc";

// For backwards compatibility
public static final String POWER_FLOW_INVERTER_1_POWER = "powerflowinverter1power";
public static final String POWER_FLOW_INVERTER_1_SOC = "powerflowinverter1soc";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,16 @@ protected State getValue(String channelId) {
return new QuantityType<>(site.getRelAutonomy(), Units.PERCENT);
case FroniusBindingConstants.POWER_FLOW_SELF_CONSUMPTION:
return new QuantityType<>(site.getRelSelfConsumption(), Units.PERCENT);
case FroniusBindingConstants.POWER_FLOW_INVERTER_POWER:
return new QuantityType<>(getInverter(config.deviceId).getP(), Units.WATT);
case FroniusBindingConstants.POWER_FLOW_INVERTER_SOC:
return new QuantityType<>(getInverter(config.deviceId).getSoc(), Units.PERCENT);

// Kept for backwards compatibility
case FroniusBindingConstants.POWER_FLOW_INVERTER_1_POWER:
return new QuantityType<>(getInverter("1").getP(), Units.WATT);
return new QuantityType<>(getInverter(1).getP(), Units.WATT);
case FroniusBindingConstants.POWER_FLOW_INVERTER_1_SOC:
return new QuantityType<>(getInverter("1").getSoc(), Units.PERCENT);
return new QuantityType<>(getInverter(1).getSoc(), Units.PERCENT);
default:
break;
}
Expand All @@ -165,8 +171,8 @@ protected State getValue(String channelId) {
* @param number The inverter object of the given index
* @return a PowerFlowRealtimeInverter object.
*/
private PowerFlowRealtimeInverter getInverter(final String number) {
return powerFlowResponse.getBody().getData().getInverters().get(number);
private PowerFlowRealtimeInverter getInverter(final int number) {
return powerFlowResponse.getBody().getData().getInverters().get(Integer.toString(number));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ thing-type.fronius.ohmpilot.label = Fronius Ohmpilot
thing-type.fronius.ohmpilot.description = Fronius Ohmpilot
thing-type.fronius.powerinverter.label = Fronius Symo Inverter
thing-type.fronius.powerinverter.description = Fronius Symo power inverter
thing-type.fronius.powerinverter.channel.powerflowchannelpakku.label = Charge / Discharge of Battery
thing-type.fronius.powerinverter.channel.powerflowchannelpgrid.label = Grid Power
thing-type.fronius.powerinverter.channel.powerflowchannelppv.label = Current Solar Yield
thing-type.fronius.powerinverter.channel.powerflowinverter1power.label = Power Flow (Inverter 1)
thing-type.fronius.powerinverter.channel.powerflowinverter1soc.label = State of Charge (Inverter 1)

# thing types config

Expand All @@ -56,23 +51,23 @@ channel-type.fronius.devicestatus_errorcode.description = Current device error c
channel-type.fronius.devicestatus_statuscode.label = Status Code
channel-type.fronius.devicestatus_statuscode.description = Current device status code
channel-type.fronius.fac.label = AC Frequency
channel-type.fronius.fac.description = AC frequency
channel-type.fronius.iac.label = AC Current
channel-type.fronius.iac.description = AC current
channel-type.fronius.idc.label = DC Current
channel-type.fronius.idc.description = DC current
channel-type.fronius.idc2.label = DC Current 2
channel-type.fronius.idc2.description = DC current 2
channel-type.fronius.idc2.description = DC current of MPPT tracker 2
channel-type.fronius.idc3.label = DC Current 3
channel-type.fronius.idc3.description = DC current 3
channel-type.fronius.inverter1Power.label = Inverter 1 Power
channel-type.fronius.inverter1Power.description = Inverter 1 Power
channel-type.fronius.inverter1Soc.label = Inverter 1 State of Charge
channel-type.fronius.inverter1Soc.description = Inverter 1 State of Charge
channel-type.fronius.idc3.description = DC current of MPPT tracker 3
channel-type.fronius.inverter1Power.label = Inverter 1 Power (DEPRECATED)
channel-type.fronius.inverter1Power.description = Inverter 1 Power - DEPRECATED. Please use inverterPower channel instead.
channel-type.fronius.inverter1Soc.label = Inverter 1 State of Charge (DEPRECATED)
channel-type.fronius.inverter1Soc.description = Inverter 1 State of Charge - DEPRECATED. Please use inverterSoc channel instead
channel-type.fronius.inverterPower.label = Inverter Power
channel-type.fronius.inverterPower.description = Current power of the inverter, `NULL` if not running (+ produce/export, - consume/import)
channel-type.fronius.inverterSoc.label = Battery State of Charge
channel-type.fronius.inverterSoc.description = Current state of charge of the battery connected to the inverter in percent
channel-type.fronius.meter_ac_current.label = AC Current
channel-type.fronius.meter_ac_voltage.label = AC Voltage
channel-type.fronius.meter_enable.label = Enabled
channel-type.fronius.meter_enable.description = Enabled
channel-type.fronius.meter_energy.label = Energy
channel-type.fronius.meter_location.label = Location
channel-type.fronius.meter_location.description = Meter Location Code
Expand All @@ -85,21 +80,21 @@ channel-type.fronius.ohmpilot_powerreal.description = Actual power consumption [
channel-type.fronius.ohmpilot_temperature.label = Temperature
channel-type.fronius.ohmpilot_temperature.description = Temperature of the PT1000
channel-type.fronius.pAkku.label = Battery Power
channel-type.fronius.pAkku.description = Battery Power ( + discharge, - charge )
channel-type.fronius.pAkku.description = Power from battery ( + discharge, - charge )
channel-type.fronius.pGrid.label = Grid Power
channel-type.fronius.pGrid.description = Grid Power ( + from grid, - to grid )
channel-type.fronius.pLoad.label = Load Power
channel-type.fronius.pLoad.description = Load Power ( + generator, - consumer )
channel-type.fronius.pLoad.description = Power from load ( + generator, - consumer )
channel-type.fronius.pPv.label = Solar Plant Power
channel-type.fronius.pPv.description = Current Solar Plant Power
channel-type.fronius.pPv.description = Power from solar plant
channel-type.fronius.pac.label = AC Power
channel-type.fronius.pac.description = AC power
channel-type.fronius.pac.description = AC power generated by the inverter
channel-type.fronius.pdc.label = DC Power
channel-type.fronius.pdc.description = DC power
channel-type.fronius.pdc.description = DC power generated by the inverter
channel-type.fronius.pdc2.label = DC Power 2
channel-type.fronius.pdc2.description = DC power 2
channel-type.fronius.pdc2.description = DC power generated by MPPT tracker 2
channel-type.fronius.pdc3.label = DC Power 3
channel-type.fronius.pdc3.description = DC power 3
channel-type.fronius.pdc3.description = DC power generated by MPPT tracker 3
channel-type.fronius.powerflow_rel_autonomy.label = Autonomy
channel-type.fronius.powerflow_rel_autonomy.description = The current relative autonomy in %, NULL if no smart meter is connected
channel-type.fronius.powerflow_rel_selfconsumption.label = Self Consumption
Expand All @@ -111,8 +106,8 @@ channel-type.fronius.uac.description = AC voltage
channel-type.fronius.udc.label = DC Voltage
channel-type.fronius.udc.description = DC voltage
channel-type.fronius.udc2.label = DC Voltage 2
channel-type.fronius.udc2.description = DC voltage 2
channel-type.fronius.udc2.description = DC voltage of MPPT tracker 2
channel-type.fronius.udc3.label = DC Voltage 3
channel-type.fronius.udc3.description = DC voltage 3
channel-type.fronius.udc3.description = DC voltage of MPPT tracker 3
channel-type.fronius.year_energy.label = Year Energy
channel-type.fronius.year_energy.description = Energy generated in current year
Loading

0 comments on commit fa94100

Please sign in to comment.