]> git.basschouten.com Git - openhab-addons.git/commitdiff
[fronius] Support multiple inverters in powerflow data (#15431)
authorjimtng <2554958+jimtng@users.noreply.github.com>
Thu, 19 Oct 2023 16:55:00 +0000 (02:55 +1000)
committerGitHub <noreply@github.com>
Thu, 19 Oct 2023 16:55:00 +0000 (18:55 +0200)
* [fronius] Support multiple inverters in powerflow data

---------

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
bundles/org.openhab.binding.fronius/README.md
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/FroniusBindingConstants.java
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusSymoInverterHandler.java
bundles/org.openhab.binding.fronius/src/main/resources/OH-INF/i18n/fronius.properties
bundles/org.openhab.binding.fronius/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.fronius/src/main/resources/OH-INF/update/update.xml [new file with mode: 0644]

index eb08a7dd4352e05a6affa813b7439089aedc99b7..a56284811007c1cca5510fd9b6c6aef6e0194d28 100644 (file)
@@ -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                                                                                          |
@@ -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
 
index d307ba0e1ab2ac2d8659979603eb2b8f0c5963fe..46c2380145b494bc53ea23827da926a0fd4c5954 100644 (file)
@@ -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";
 
index 56cc8c25e90ac2f51319f0d7e13ce27f046ab330..1ffdddb502ec4a82cf274bdcb3f28d8998a6423f 100644 (file)
@@ -147,10 +147,16 @@ public class FroniusSymoInverterHandler extends FroniusBaseThingHandler {
                     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;
             }
@@ -165,8 +171,8 @@ public class FroniusSymoInverterHandler extends FroniusBaseThingHandler {
      * @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));
     }
 
     /**
index 30f6ae966c986e8377cef4d1a05c2562b14f8946..a35ced3a738139046c5a744963eb619fbb5410d3 100644 (file)
@@ -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
 
@@ -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
@@ -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
@@ -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
index 4d42e1dea8f1d7160bad74102722e568ed7fb397..bae2bc134330958037931c1ba7688061c17beeac 100644 (file)
                        <channel id="inverterdatachanneludc3" typeId="udc3"/>
                        <channel id="inverterdatadevicestatuserrorcode" typeId="devicestatus_errorcode"/>
                        <channel id="inverterdatadevicestatusstatuscode" typeId="devicestatus_statuscode"/>
-                       <channel id="powerflowchannelpgrid" typeId="pGrid">
-                               <label>Grid Power</label>
-                       </channel>
+                       <channel id="powerflowchannelpgrid" typeId="pGrid"/>
                        <channel id="powerflowchannelpload" typeId="pLoad"/>
-                       <channel id="powerflowchannelpakku" typeId="pAkku">
-                               <label>Charge / Discharge of Battery</label>
-                       </channel>
-                       <channel id="powerflowchannelppv" typeId="pPv">
-                               <label>Current Solar Yield</label>
-                       </channel>
+                       <channel id="powerflowchannelpakku" typeId="pAkku"/>
+                       <channel id="powerflowchannelppv" typeId="pPv"/>
                        <channel id="powerflowautonomy" typeId="powerflow_rel_autonomy"/>
                        <channel id="powerflowselfconsumption" typeId="powerflow_rel_selfconsumption"/>
-                       <channel id="powerflowinverter1power" typeId="inverter1Power">
-                               <label>Power Flow (Inverter 1)</label>
-                       </channel>
-                       <channel id="powerflowinverter1soc" typeId="inverter1Soc">
-                               <label>State of Charge (Inverter 1)</label>
-                       </channel>
+                       <channel id="powerflowinverterpower" typeId="inverterPower"/>
+                       <channel id="powerflowinvertersoc" typeId="inverterSoc"/>
+                       <channel id="powerflowinverter1power" typeId="inverter1Power"/>
+                       <channel id="powerflowinverter1soc" typeId="inverter1Soc"/>
                </channels>
 
+               <properties>
+                       <property name="thingTypeVersion">1</property>
+               </properties>
+
                <config-description>
                        <parameter name="deviceId" type="integer">
                                <label>Device ID</label>
        <channel-type id="pac">
                <item-type>Number:Power</item-type>
                <label>AC Power</label>
-               <description>AC power</description>
+               <description>AC power generated by the inverter</description>
                <state pattern="%f W" readOnly="true"></state>
        </channel-type>
        <channel-type id="pdc">
                <item-type>Number:Power</item-type>
                <label>DC Power</label>
-               <description>DC power</description>
+               <description>DC power generated by the inverter</description>
                <state pattern="%f W" readOnly="true"></state>
        </channel-type>
        <channel-type id="pdc2">
                <item-type>Number:Power</item-type>
                <label>DC Power 2</label>
-               <description>DC power 2</description>
+               <description>DC power generated by MPPT tracker 2</description>
                <state pattern="%f W" readOnly="true"></state>
        </channel-type>
        <channel-type id="pdc3">
                <item-type>Number:Power</item-type>
                <label>DC Power 3</label>
-               <description>DC power 3</description>
+               <description>DC power generated by MPPT tracker 3</description>
                <state pattern="%f W" readOnly="true"></state>
        </channel-type>
        <channel-type id="total_energy">
        <channel-type id="fac">
                <item-type>Number:Frequency</item-type>
                <label>AC Frequency</label>
-               <description>AC frequency</description>
                <state pattern="%.2f Hz" readOnly="true"></state>
        </channel-type>
 
        <channel-type id="iac">
                <item-type>Number:ElectricCurrent</item-type>
                <label>AC Current</label>
-               <description>AC current</description>
                <state pattern="%.2f A" readOnly="true"></state>
        </channel-type>
 
        <channel-type id="idc">
                <item-type>Number:ElectricCurrent</item-type>
                <label>DC Current</label>
-               <description>DC current</description>
                <state pattern="%.2f A" readOnly="true"></state>
        </channel-type>
        <channel-type id="idc2">
                <item-type>Number:ElectricCurrent</item-type>
                <label>DC Current 2</label>
-               <description>DC current 2</description>
+               <description>DC current of MPPT tracker 2</description>
                <state pattern="%.2f A" readOnly="true"></state>
        </channel-type>
        <channel-type id="idc3">
                <item-type>Number:ElectricCurrent</item-type>
                <label>DC Current 3</label>
-               <description>DC current 3</description>
+               <description>DC current of MPPT tracker 3</description>
                <state pattern="%.2f A" readOnly="true"></state>
        </channel-type>
        <channel-type id="uac">
        <channel-type id="udc2">
                <item-type>Number:ElectricPotential</item-type>
                <label>DC Voltage 2</label>
-               <description>DC voltage 2</description>
+               <description>DC voltage of MPPT tracker 2</description>
                <state pattern="%.1f V" readOnly="true"></state>
        </channel-type>
        <channel-type id="udc3">
                <item-type>Number:ElectricPotential</item-type>
                <label>DC Voltage 3</label>
-               <description>DC voltage 3</description>
+               <description>DC voltage of MPPT tracker 3</description>
                <state pattern="%.1f V" readOnly="true"></state>
        </channel-type>
 
        <channel-type id="pLoad">
                <item-type>Number:Power</item-type>
                <label>Load Power</label>
-               <description>Load Power ( + generator, - consumer )</description>
+               <description>Power from load ( + generator, - consumer )</description>
                <state pattern="%.2f %unit%" readOnly="true"></state>
        </channel-type>
        <channel-type id="pAkku">
                <item-type>Number:Power</item-type>
                <label>Battery Power</label>
-               <description>Battery Power ( + discharge, - charge )</description>
+               <description>Power from battery ( + discharge, - charge )</description>
                <state pattern="%.1f %unit%" readOnly="true"></state>
        </channel-type>
        <channel-type id="pPv">
                <item-type>Number:Power</item-type>
                <label>Solar Plant Power</label>
-               <description>Current Solar Plant Power</description>
+               <description>Power from solar plant</description>
                <state pattern="%.2f %unit%" readOnly="true"></state>
        </channel-type>
        <channel-type id="powerflow_rel_autonomy">
                <item-type>Number:Dimensionless</item-type>
                <label>Autonomy</label>
                <description>The current relative autonomy in %, NULL if no smart meter is connected</description>
-               <state pattern="%.1f %unit%" readOnly="true"></state>
+               <state pattern="%.1f %%" readOnly="true"></state>
        </channel-type>
        <channel-type id="powerflow_rel_selfconsumption">
                <item-type>Number:Dimensionless</item-type>
                <label>Self Consumption</label>
                <description>The current relative self consumption in %, NULL if no smart meter is connected</description>
-               <state pattern="%.1f %unit%" readOnly="true"></state>
+               <state pattern="%.1f %%" readOnly="true"></state>
        </channel-type>
-       <channel-type id="inverter1Power">
+       <channel-type id="inverterPower">
                <item-type>Number:Power</item-type>
-               <label>Inverter Power</label>
-               <description>Inverter 1 Power</description>
+               <label>Inverter Power</label>
+               <description>Current power of the inverter, `NULL` if not running (+ produce/export, - consume/import)</description>
                <state pattern="%.2f %unit%" readOnly="true"></state>
        </channel-type>
-       <channel-type id="inverter1Soc">
+       <channel-type id="inverterSoc">
                <item-type>Number:Dimensionless</item-type>
-               <label>Inverter 1 State of Charge</label>
-               <description>Inverter 1 State of Charge</description>
-               <state pattern="%.1f %unit%" readOnly="true"></state>
+               <label>Battery State of Charge</label>
+               <description>Current state of charge of the battery connected to the inverter in percent</description>
+               <state pattern="%.1f %%" readOnly="true"></state>
+       </channel-type>
+       <channel-type id="inverter1Power" advanced="true">
+               <item-type>Number:Power</item-type>
+               <label>Inverter 1 Power (DEPRECATED)</label>
+               <description>Inverter 1 Power - DEPRECATED. Please use inverterPower channel instead.</description>
+               <state pattern="%.2f %unit%" readOnly="true"></state>
+       </channel-type>
+       <channel-type id="inverter1Soc" advanced="true">
+               <item-type>Number:Dimensionless</item-type>
+               <label>Inverter 1 State of Charge (DEPRECATED)</label>
+               <description>Inverter 1 State of Charge - DEPRECATED. Please use inverterSoc channel instead</description>
+               <state pattern="%.1f %%" readOnly="true"></state>
        </channel-type>
 
 
        <channel-type id="meter_enable" advanced="true">
                <item-type>Number</item-type>
                <label>Enabled</label>
-               <description>Enabled</description>
                <state readOnly="true"></state>
        </channel-type>
        <channel-type id="meter_location" advanced="true">
diff --git a/bundles/org.openhab.binding.fronius/src/main/resources/OH-INF/update/update.xml b/bundles/org.openhab.binding.fronius/src/main/resources/OH-INF/update/update.xml
new file mode 100644 (file)
index 0000000..1da3e7c
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
+       xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">
+
+       <thing-type uid="fronius:powerinverter">
+               <instruction-set targetVersion="1">
+                       <add-channel id="powerflowinverterpower">
+                               <type>fronius:inverterPower</type>
+                       </add-channel>
+                       <add-channel id="powerflowinvertersoc">
+                               <type>fronius:inverterSoc</type>
+                       </add-channel>
+                       <update-channel id="powerflowinverter1power">
+                               <type>fronius:inverter1Power</type>
+                               <label>Inverter 1 Power (DEPRECATED)</label>
+                               <description>Inverter 1 Power - DEPRECATED. Please use inverterPower channel instead.</description>
+                       </update-channel>
+                       <update-channel id="powerflowinverter1soc">
+                               <type>fronius:inverter1Soc</type>
+                               <label>Inverter 1 State of Charge (DEPRECATED)</label>
+                               <description>Inverter 1 State of Charge - DEPRECATED. Please use inverterSoc channel instead</description>
+                       </update-channel>
+               </instruction-set>
+       </thing-type>
+
+</update:update-descriptions>