]> git.basschouten.com Git - openhab-addons.git/commitdiff
[fronius] Added Ohmpilot thing and channel realpowersum for thing meter (#11835)
authorHannes Spenger <hannes.spenger@gmx.at>
Tue, 8 Feb 2022 23:02:40 +0000 (00:02 +0100)
committerGitHub <noreply@github.com>
Tue, 8 Feb 2022 23:02:40 +0000 (00:02 +0100)
* Added support for fronius ohmpilot and added smart meter power sum.

Signed-off-by: urmet0 <hannes.spenger@gmail.com>
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/FroniusHandlerFactory.java
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeBodyDTO.java [new file with mode: 0644]
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeBodyDataDTO.java [new file with mode: 0644]
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeDetailsDTO.java [new file with mode: 0644]
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeResponseDTO.java [new file with mode: 0644]
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusMeterHandler.java
bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusOhmpilotHandler.java [new file with mode: 0644]
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

index fba833df02d2d05ab2f5c4bbaa5fcc4f25b3ba71..4effa0f877a0d341788c01662e136570949718b0 100644 (file)
@@ -10,7 +10,9 @@ It supports Fronius inverters and Fronius Smart Meter. Tested with a Fronius Sym
 | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
 | `bridge`        | The Bridge                                                                                                                                                                                                                            |
 | `powerinverter` | Fronius Galvo, Symo and other Fronius inverters in combination with the Fronius Datamanager 1.0 / 2.0 or Fronius Datalogger. You can add multiple inverters that depend on the same datalogger with different device ids. (Default 1) |
-| `meter`         | Fronius Smart Meter. You can add multiple smart meters with different device ids. (The default id = 0)                                                                                                                                |
+| `meter`         | Fronius Smart Meter. You can add multiple smart meters with different device ids. (The default id = 0)                                                                                                                                
+| `ohmpilot`      | Fronius Ohmpilot. (The default id = 0)     
+
 
 ## Discovery
 
@@ -18,7 +20,7 @@ There is no discovery implemented. You have to create your things manually and s
 
 ## Binding Configuration
 
-The binding has no configuration options, all configuration is done at `bridge`, `powerinverter` or `meter` level.
+The binding has no configuration options, all configuration is done at `bridge`, `powerinverter`, `meter` or `ohmpilot` level.
 
 ## Thing Configuration
 
@@ -41,6 +43,12 @@ The binding has no configuration options, all configuration is done at `bridge`,
 | ---------- | ----------------------------------------------- |
 | `deviceId` | The identifier of your smart meter (Default: 0) |
 
+### Ohmpilot Thing Configuration
+
+| Parameter  | Description                                     |
+| ---------- | ----------------------------------------------- |
+| `deviceId` | The identifier of your ohmpilot (Default: 0) |
+
 ## Channels
 
 ### Channels for `powerinverter` Thing
@@ -77,6 +85,7 @@ The binding has no configuration options, all configuration is done at `bridge`,
 | `powerrealphase1`       | Number:Power             | Real Power on Phase 1                                                                                                                                                                                                    |
 | `powerrealphase2`       | Number:Power             | Real Power on Phase 2                                                                                                                                                                                                    |
 | `powerrealphase3`       | Number:Power             | Real Power on Phase 3                                                                                                                                                                                                    |
+| `powerrealsum`          | Number:Power             | Real Power summed up                                                                                                                                                                                                    |
 | `powerfactorphase1`     | Number                   | Power Factor on Phase 1                                                                                                                                                                                                  |
 | `powerfactorphase2`     | Number                   | Power Factor on Phase 2                                                                                                                                                                                                  |
 | `powerfactorphase3`     | Number                   | Power Factor on Phase 3                                                                                                                                                                                                  |
@@ -85,16 +94,33 @@ The binding has no configuration options, all configuration is done at `bridge`,
 |                         |
 
 
+### Channels for `ohmpilot` Thing
+
+| Channel ID              | Item Type                | Description                                                                                                                                                                                                              |
+| ----------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `energyrealsumconsumed` | Number:Energy            | Real Energy consumed                                                                                                                                                                                                     |
+| `powerrealsum` | Number:Power            | Real Power                                                                                                                                                                                                     |
+| `temperaturechannel1` | Number:Temperature            | Temperature                                                                                                                                                                                                     |
+| `errorcode`  | Number    | Device error code                                                                                                 |
+| `statecode` | Number    | Device state code<br />`0` up and running <br />`1` keep minimum temperature <br />`2` legionella protection <br />`3` critical fault<br />`4` fault<br />`5` boost mode |
+|                         |
 
 
 ## Properties
 
-The `meter` thing has the following properties:
+### The `meter` thing has the following properties:
+
+| Property | Description                    |
+| -------- | ------------------------------ |
+| `modelId`  | The model name of the meter    |
+| `serialNumber` | The serial number of the meter |
+
+### The `ohmpilot` thing has the following property:
 
 | Property | Description                    |
 | -------- | ------------------------------ |
-| `model`  | The model name of the meter    |
-| `serial` | The serial number of the meter |
+| `modelId`  | The model name of the ohmpilot    |
+| `serialNumber` | The serial number of the ohmpilot |
 
 ## Full Example
 
@@ -104,6 +130,7 @@ demo.things:
 Bridge fronius:bridge:mybridge [hostname="192.168.66.148", refreshInterval=5] {
     Thing powerinverter myinverter [deviceId=1]
     Thing meter mymeter [deviceId=0]
+    Thing ohmpilot myohmpilot [deviceId=0]    
 }
 ```
 
@@ -136,9 +163,17 @@ Number:Voltage Meter_VoltagePhase3 { channel="fronius:meter:mybridge:mymeter:vol
 Number:Power Meter_PowerPhase1 { channel="fronius:meter:mybridge:mymeter:powerrealphase1" }
 Number:Power Meter_PowerPhase2 { channel="fronius:meter:mybridge:mymeter:powerrealphase2" }
 Number:Power Meter_PowerPhase3 { channel="fronius:meter:mybridge:mymeter:powerrealphase3" }
+Number:Power Meter_PowerSum    { channel="fronius:meter:mybridge:mymeter:powerrealsum" }
 Number Meter_PowerFactorPhase1 { channel="fronius:meter:mybridge:mymeter:powerfactorphase1" }
 Number Meter_PowerFactorPhase2 { channel="fronius:meter:mybridge:mymeter:powerfactorphase2" }
 Number Meter_PowerFactorPhase3 { channel="fronius:meter:mybridge:mymeter:powerfactorphase3" }
 Number:Energy Meter_EnergyConsumed { channel="fronius:meter:mybridge:mymeter:energyrealsumconsumed" }
 Number:Energy Meter_EnergyProduced { channel="fronius:meter:mybridge:mymeter:energyrealsumproduced" }
+
+Number:Energy Ohmpilot_EnergyConsumed { channel="fronius:ohmpilot:mybridge:myohmpilot:energyrealsumconsumed" }
+Number:Power Ohmpilot_PowerSum { channel="fronius:ohmpilot:mybridge:myohmpilot:powerrealsum" }
+Number:Temperature Ohmpilot_Temperature { channel="fronius:ohmpilot:mybridge:myohmpilot:temperaturechannel1" }
+Number Ohmpilot_State { channel="fronius:ohmpilot:mybridge:myohmpilot:statecode" }
+Number Ohmpilot_Errorcode { channel="fronius:ohmpilot:mybridge:myohmpilot:errorcode" }
+
 ```
index 86fa3cf6ba4dee5abce5702421cd9ab32fa8b618..2067ec250d9cbf6d5d2ef1aec232150fb512389c 100644 (file)
@@ -22,6 +22,7 @@ import org.openhab.core.thing.ThingTypeUID;
  * @author Thomas Rokohl - Initial contribution
  * @author Peter Schraffl - Added device status and error status channels
  * @author Thomas Kordelle - Added inverter power, battery state of charge and PV solar yield
+ * @author Hannes Spenger - Added ohmpilot & meter power sum
  */
 @NonNullByDefault
 public class FroniusBindingConstants {
@@ -32,6 +33,7 @@ public class FroniusBindingConstants {
     public static final ThingTypeUID THING_TYPE_INVERTER = new ThingTypeUID(BINDING_ID, "powerinverter");
     public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");
     public static final ThingTypeUID THING_TYPE_METER = new ThingTypeUID(BINDING_ID, "meter");
+    public static final ThingTypeUID THING_TYPE_OHMPILOT = new ThingTypeUID(BINDING_ID, "ohmpilot");
 
     // List of all Channel ids
     public static final String INVERTER_DATA_CHANNEL_DAY_ENERGY = "inverterdatachanneldayenergy";
@@ -49,8 +51,6 @@ public class FroniusBindingConstants {
     public static final String POWER_FLOW_P_LOAD = "powerflowchannelpload";
     public static final String POWER_FLOW_P_AKKU = "powerflowchannelpakku";
     public static final String POWER_FLOW_P_PV = "powerflowchannelppv";
-    public static final String METER_MODEL = "model";
-    public static final String METER_SERIAL = "serial";
     public static final String METER_ENABLE = "enable";
     public static final String METER_LOCATION = "location";
     public static final String METER_CURRENT_AC_PHASE_1 = "currentacphase1";
@@ -62,11 +62,17 @@ public class FroniusBindingConstants {
     public static final String METER_POWER_PHASE_1 = "powerrealphase1";
     public static final String METER_POWER_PHASE_2 = "powerrealphase2";
     public static final String METER_POWER_PHASE_3 = "powerrealphase3";
+    public static final String METER_POWER_SUM = "powerrealsum";
     public static final String METER_POWER_FACTOR_PHASE_1 = "powerfactorphase1";
     public static final String METER_POWER_FACTOR_PHASE_2 = "powerfactorphase2";
     public static final String METER_POWER_FACTOR_PHASE_3 = "powerfactorphase3";
     public static final String METER_ENERGY_REAL_SUM_CONSUMED = "energyrealsumconsumed";
     public static final String METER_ENERGY_REAL_SUM_PRODUCED = "energyrealsumproduced";
+    public static final String OHMPILOT_POWER_REAL_SUM = "powerrealsum";
+    public static final String OHMPILOT_ENERGY_REAL_SUM_CONSUMED = "energyrealsumconsumed";
+    public static final String OHMPILOT_ENERGY_SENSOR_TEMPERATURE_CHANNEL_1 = "temperaturechannel1";
+    public static final String OHMPILOT_ERROR_CODE = "errorcode";
+    public static final String OHMPILOT_STATE_CODE = "statecode";
 
     /*
      * part of POWERFLOW_REALTIME_DATA using Symo Gen24
@@ -86,4 +92,5 @@ public class FroniusBindingConstants {
     public static final String INVERTER_REALTIME_DATA_URL = "http://%IP%/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceId=%DEVICEID%&DataCollection=CommonInverterData";
     public static final String POWERFLOW_REALTIME_DATA = "http://%IP%/solar_api/v1/GetPowerFlowRealtimeData.fcgi";
     public static final String METER_REALTIME_DATA_URL = "http://%IP%/solar_api/v1/GetMeterRealtimeData.cgi?Scope=Device&DeviceId=%DEVICEID%&DataCollection=MeterRealtimeData";
+    public static final String OHMPILOT_REALTIME_DATA_URL = "http://%IP%/solar_api/v1/GetOhmPilotRealtimeData.cgi?Scope=Device&DeviceId=%DEVICEID%";
 }
index 21141997887cdbf78a2463952b758a8458d82b4c..15fea161047720a6840991120c30adb64b3b0233 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Set;
 
 import org.openhab.binding.fronius.internal.handler.FroniusBridgeHandler;
 import org.openhab.binding.fronius.internal.handler.FroniusMeterHandler;
+import org.openhab.binding.fronius.internal.handler.FroniusOhmpilotHandler;
 import org.openhab.binding.fronius.internal.handler.FroniusSymoInverterHandler;
 import org.openhab.core.thing.Bridge;
 import org.openhab.core.thing.Thing;
@@ -33,6 +34,7 @@ import org.osgi.service.component.annotations.Component;
  * handlers.
  *
  * @author Thomas Rokohl - Initial contribution
+ * @author Hannes Spenger - Added ohmpilot
  */
 @Component(service = ThingHandlerFactory.class, configurationPid = "binding.fronius")
 public class FroniusHandlerFactory extends BaseThingHandlerFactory {
@@ -44,6 +46,7 @@ public class FroniusHandlerFactory extends BaseThingHandlerFactory {
             add(THING_TYPE_INVERTER);
             add(THING_TYPE_BRIDGE);
             add(THING_TYPE_METER);
+            add(THING_TYPE_OHMPILOT);
         }
     };
 
@@ -62,6 +65,8 @@ public class FroniusHandlerFactory extends BaseThingHandlerFactory {
             return new FroniusBridgeHandler((Bridge) thing);
         } else if (thingTypeUID.equals(THING_TYPE_METER)) {
             return new FroniusMeterHandler(thing);
+        } else if (thingTypeUID.equals(THING_TYPE_OHMPILOT)) {
+            return new FroniusOhmpilotHandler(thing);
         }
         return null;
     }
diff --git a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeBodyDTO.java b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeBodyDTO.java
new file mode 100644 (file)
index 0000000..7e31ebd
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.fronius.internal.api;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The {@link OhmpilotRealtimeBody} is responsible for storing
+ * the "body" node of the JSON response
+ *
+ * @author Hannes Spenger - Initial contribution
+ */
+public class OhmpilotRealtimeBodyDTO {
+    @SerializedName("Data")
+    private OhmpilotRealtimeBodyDataDTO data;
+
+    public OhmpilotRealtimeBodyDataDTO getData() {
+        if (data == null) {
+            data = new OhmpilotRealtimeBodyDataDTO();
+        }
+        return data;
+    }
+
+    public void setData(OhmpilotRealtimeBodyDataDTO data) {
+        this.data = data;
+    }
+}
diff --git a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeBodyDataDTO.java b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeBodyDataDTO.java
new file mode 100644 (file)
index 0000000..db8057a
--- /dev/null
@@ -0,0 +1,87 @@
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.fronius.internal.api;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The {@link OhmpilotRealtimeBodyData} is responsible for storing
+ * the "data" node of the JSON response
+ *
+ * @author Hannes Spenger - Initial contribution
+ */
+public class OhmpilotRealtimeBodyDataDTO {
+    @SerializedName("Details")
+    private OhmpilotRealtimeDetailsDTO details;
+    @SerializedName("EnergyReal_WAC_Sum_Consumed")
+    private double energyRealWACSumConsumed;
+    @SerializedName("PowerReal_PAC_Sum")
+    private double powerPACSum;
+    @SerializedName("Temperature_Channel_1")
+    private double temperatureChannel1;
+    @SerializedName("CodeOfError")
+    private int errorCode;
+    @SerializedName("CodeOfState")
+    private int stateCode;
+
+    public OhmpilotRealtimeDetailsDTO getDetails() {
+        if (details == null) {
+            details = new OhmpilotRealtimeDetailsDTO();
+        }
+        return details;
+    }
+
+    public void setDetails(OhmpilotRealtimeDetailsDTO details) {
+        this.details = details;
+    }
+
+    public double getEnergyRealWACSumConsumed() {
+        return energyRealWACSumConsumed;
+    }
+
+    public void setEnergyRealWACSumConsumed(double energyRealWACSumConsumed) {
+        this.energyRealWACSumConsumed = energyRealWACSumConsumed;
+    }
+
+    public double getPowerPACSum() {
+        return powerPACSum;
+    }
+
+    public void setPowerPACSum(double powerPACSum) {
+        this.powerPACSum = powerPACSum;
+    }
+
+    public double getTemperatureChannel1() {
+        return temperatureChannel1;
+    }
+
+    public void setTemperatureChannel1(double temperatureChannel1) {
+        this.temperatureChannel1 = temperatureChannel1;
+    }
+
+    public int getErrorCode() {
+        return errorCode;
+    }
+
+    public void setErrorCode(int errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public int getStateCode() {
+        return stateCode;
+    }
+
+    public void setStateCode(int stateCode) {
+        this.stateCode = stateCode;
+    }
+}
diff --git a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeDetailsDTO.java b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeDetailsDTO.java
new file mode 100644 (file)
index 0000000..e99df5f
--- /dev/null
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.fronius.internal.api;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The {@link OhmpilotRealtimeDetails} is responsible for storing
+ * the "body" node of the JSON response
+ *
+ * @author Hannes Spenger - Initial contribution
+ */
+public class OhmpilotRealtimeDetailsDTO {
+    @SerializedName("Hardware")
+    private String hardware;
+    @SerializedName("Manufacturer")
+    private String manufacturer;
+    @SerializedName("Model")
+    private String model;
+    @SerializedName("Serial")
+    private String serial;
+    @SerializedName("Software")
+    private String software;
+
+    public String getHardware() {
+        return hardware;
+    }
+
+    public void setHardware(String hardware) {
+        this.hardware = hardware;
+    }
+
+    public String getManufacturer() {
+        return manufacturer;
+    }
+
+    public void setManufacturer(String manufacturer) {
+        this.manufacturer = manufacturer;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public String getSerial() {
+        return serial;
+    }
+
+    public void setSerial(String serial) {
+        this.serial = serial;
+    }
+
+    public String getSoftware() {
+        return software;
+    }
+
+    public void setSoftware(String software) {
+        this.software = software;
+    }
+}
diff --git a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeResponseDTO.java b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/api/OhmpilotRealtimeResponseDTO.java
new file mode 100644 (file)
index 0000000..f41e742
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.fronius.internal.api;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * The {@link OhmpilotRealtimeResponse} is responsible for storing
+ * the response from the GetOhmPilotRealtimeData api
+ *
+ * @author Hannes Spenger - Initial contribution
+ */
+public class OhmpilotRealtimeResponseDTO extends BaseFroniusResponse {
+    @SerializedName("Body")
+    private OhmpilotRealtimeBodyDTO body;
+
+    public OhmpilotRealtimeBodyDTO getBody() {
+        if (body == null) {
+            body = new OhmpilotRealtimeBodyDTO();
+        }
+        return body;
+    }
+
+    public void setBody(OhmpilotRealtimeBodyDTO body) {
+        this.body = body;
+    }
+}
index 36167079c17a93de59728fe0faff060a4585e882..32bafbf7a1c357230d71c7a38049c77d352bdfb8 100644 (file)
@@ -29,6 +29,7 @@ import org.openhab.core.thing.Thing;
  *
  * @author Jimmy Tanagra - Initial contribution
  * @author Thomas Kordelle - Actually constants should be all upper case.
+ * @author Hannes Spenger - Added getValue for power sum
  */
 public class FroniusMeterHandler extends FroniusBaseThingHandler {
 
@@ -98,6 +99,8 @@ public class FroniusMeterHandler extends FroniusBaseThingHandler {
                 return new QuantityType<>(meterRealtimeBodyData.getPowerRealPPhase2(), Units.WATT);
             case FroniusBindingConstants.METER_POWER_PHASE_3:
                 return new QuantityType<>(meterRealtimeBodyData.getPowerRealPPhase3(), Units.WATT);
+            case FroniusBindingConstants.METER_POWER_SUM:
+                return new QuantityType<>(meterRealtimeBodyData.getPowerRealPSum(), Units.WATT);
             case FroniusBindingConstants.METER_POWER_FACTOR_PHASE_1:
                 return meterRealtimeBodyData.getPowerFactorPhase1();
             case FroniusBindingConstants.METER_POWER_FACTOR_PHASE_2:
@@ -122,8 +125,8 @@ public class FroniusMeterHandler extends FroniusBaseThingHandler {
 
         Map<String, String> properties = editProperties();
 
-        properties.put(FroniusBindingConstants.METER_MODEL, meterRealtimeBodyData.getDetails().getModel());
-        properties.put(FroniusBindingConstants.METER_SERIAL, meterRealtimeBodyData.getDetails().getSerial());
+        properties.put(Thing.PROPERTY_MODEL_ID, meterRealtimeBodyData.getDetails().getModel());
+        properties.put(Thing.PROPERTY_SERIAL_NUMBER, meterRealtimeBodyData.getDetails().getSerial());
 
         updateProperties(properties);
     }
diff --git a/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusOhmpilotHandler.java b/bundles/org.openhab.binding.fronius/src/main/java/org/openhab/binding/fronius/internal/handler/FroniusOhmpilotHandler.java
new file mode 100644 (file)
index 0000000..a0ec420
--- /dev/null
@@ -0,0 +1,137 @@
+/**
+ * Copyright (c) 2010-2022 Contributors to the openHAB project
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ */
+package org.openhab.binding.fronius.internal.handler;
+
+import java.util.Map;
+
+import org.openhab.binding.fronius.internal.FroniusBaseDeviceConfiguration;
+import org.openhab.binding.fronius.internal.FroniusBindingConstants;
+import org.openhab.binding.fronius.internal.FroniusBridgeConfiguration;
+import org.openhab.binding.fronius.internal.api.OhmpilotRealtimeBodyDataDTO;
+import org.openhab.binding.fronius.internal.api.OhmpilotRealtimeResponseDTO;
+import org.openhab.core.library.types.DecimalType;
+import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.unit.Units;
+import org.openhab.core.thing.Thing;
+
+/**
+ * The {@link FroniusOhmpilotHandler} is responsible for updating the data, which are
+ * sent to one of the channels.
+ *
+ * @author Hannes Spenger - Initial contribution
+ *
+ */
+public class FroniusOhmpilotHandler extends FroniusBaseThingHandler {
+
+    private OhmpilotRealtimeBodyDataDTO ohmpilotRealtimeBodyData;
+    private FroniusBaseDeviceConfiguration config;
+
+    public FroniusOhmpilotHandler(Thing thing) {
+        super(thing);
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Fronius Ohmpilot";
+    }
+
+    @Override
+    public void refresh(FroniusBridgeConfiguration bridgeConfiguration) {
+        updateData(bridgeConfiguration, config);
+        updateChannels();
+        updateProperties();
+    }
+
+    @Override
+    public void initialize() {
+        config = getConfigAs(FroniusBaseDeviceConfiguration.class);
+        super.initialize();
+    }
+
+    /**
+     * Update the channel from the last data retrieved
+     *
+     * @param channelId the id identifying the channel to be updated
+     * @return the last retrieved data
+     */
+    @Override
+    protected Object getValue(String channelId) {
+        if (ohmpilotRealtimeBodyData == null) {
+            return null;
+        }
+
+        final String[] fields = channelId.split("#");
+        if (fields.length < 1) {
+            return null;
+        }
+        final String fieldName = fields[0];
+
+        switch (fieldName) {
+            case FroniusBindingConstants.OHMPILOT_POWER_REAL_SUM:
+                return new QuantityType<>(ohmpilotRealtimeBodyData.getPowerPACSum(), Units.WATT);
+            case FroniusBindingConstants.OHMPILOT_ENERGY_REAL_SUM_CONSUMED:
+                return new QuantityType<>(ohmpilotRealtimeBodyData.getEnergyRealWACSumConsumed(), Units.WATT_HOUR);
+            case FroniusBindingConstants.OHMPILOT_ENERGY_SENSOR_TEMPERATURE_CHANNEL_1:
+                return new QuantityType<>(ohmpilotRealtimeBodyData.getTemperatureChannel1(), Units.KELVIN);
+            case FroniusBindingConstants.OHMPILOT_STATE_CODE:
+                return new DecimalType(ohmpilotRealtimeBodyData.getStateCode());
+            case FroniusBindingConstants.OHMPILOT_ERROR_CODE:
+                return new DecimalType(ohmpilotRealtimeBodyData.getErrorCode());
+
+            default:
+                break;
+        }
+
+        return null;
+    }
+
+    private void updateProperties() {
+        if (ohmpilotRealtimeBodyData == null) {
+            return;
+        }
+
+        Map<String, String> properties = editProperties();
+
+        properties.put(Thing.PROPERTY_MODEL_ID, ohmpilotRealtimeBodyData.getDetails().getModel());
+        properties.put(Thing.PROPERTY_SERIAL_NUMBER, ohmpilotRealtimeBodyData.getDetails().getSerial());
+
+        updateProperties(properties);
+    }
+
+    /**
+     * Get new data
+     */
+    private void updateData(FroniusBridgeConfiguration bridgeConfiguration, FroniusBaseDeviceConfiguration config) {
+        OhmpilotRealtimeResponseDTO ohmpilotRealtimeResponse = getOhmpilotRealtimeData(bridgeConfiguration.hostname,
+                config.deviceId);
+        if (ohmpilotRealtimeResponse == null) {
+            ohmpilotRealtimeBodyData = null;
+        } else {
+            ohmpilotRealtimeBodyData = ohmpilotRealtimeResponse.getBody().getData();
+        }
+    }
+
+    /**
+     * Make the OhmpilotRealtimeData request
+     *
+     * @param ip address of the device
+     * @param deviceId of the device
+     * @return {OhmpilotRealtimeResponse} the object representation of the json response
+     */
+    private OhmpilotRealtimeResponseDTO getOhmpilotRealtimeData(String ip, int deviceId) {
+        String location = FroniusBindingConstants.OHMPILOT_REALTIME_DATA_URL.replace("%IP%",
+                (ip != null ? ip.trim() : ""));
+        location = location.replace("%DEVICEID%", Integer.toString(deviceId));
+        return collectDataFormUrl(OhmpilotRealtimeResponseDTO.class, location);
+    }
+}
index 8a605c9cb4b4dd43f5cdbcf52dac203994905788..a01821504074bf699f7a2797788653f2b0536131 100644 (file)
@@ -20,9 +20,12 @@ thing-type.fronius.meter.channel.powerfactorphase3.label = Power Factor Phase 3
 thing-type.fronius.meter.channel.powerrealphase1.label = Real Power Phase 1
 thing-type.fronius.meter.channel.powerrealphase2.label = Real Power Phase 2
 thing-type.fronius.meter.channel.powerrealphase3.label = Real Power Phase 3
+thing-type.fronius.meter.channel.powerrealsum.label = Real Power Sum
 thing-type.fronius.meter.channel.voltageacphase1.label = AC Voltage Phase 1
 thing-type.fronius.meter.channel.voltageacphase2.label = AC Voltage Phase 2
 thing-type.fronius.meter.channel.voltageacphase3.label = AC Voltage Phase 3
+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
@@ -39,6 +42,8 @@ thing-type.config.fronius.bridge.refreshInterval.label = Refresh Interval
 thing-type.config.fronius.bridge.refreshInterval.description = Specifies the refresh interval in seconds.
 thing-type.config.fronius.meter.deviceId.label = Device ID
 thing-type.config.fronius.meter.deviceId.description = Specific device identifier
+thing-type.config.fronius.ohmpilot.deviceId.label = Device ID
+thing-type.config.fronius.ohmpilot.deviceId.description = Specific device identifier
 thing-type.config.fronius.powerinverter.deviceId.label = Device ID
 thing-type.config.fronius.powerinverter.deviceId.description = Specific device identifier
 
@@ -69,6 +74,12 @@ channel-type.fronius.meter_location.label = Location
 channel-type.fronius.meter_location.description = Meter Location Code
 channel-type.fronius.meter_powerfactor.label = Power Factor
 channel-type.fronius.meter_powerreal.label = Power
+channel-type.fronius.ohmpilot_energy.label = Real Energy Consumed
+channel-type.fronius.ohmpilot_energy.description = Total consumed energy [Wh]
+channel-type.fronius.ohmpilot_powerreal.label = Real Power Sum
+channel-type.fronius.ohmpilot_powerreal.description = Actual power consumption [W]
+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.pGrid.label = Grid Power
index fb61c75112900c541f3a413de6f512a13ba94fc7..f9b1c2e859c97d456b62d10eb6a744c02c82ff30 100644 (file)
@@ -89,6 +89,9 @@
                        <channel id="powerrealphase3" typeId="meter_powerreal">
                                <label>Real Power Phase 3</label>
                        </channel>
+                       <channel id="powerrealsum" typeId="meter_powerreal">
+                               <label>Real Power Sum</label>
+                       </channel>
                        <channel id="powerfactorphase1" typeId="meter_powerfactor">
                                <label>Power Factor Phase 1</label>
                        </channel>
                        </channel>
                </channels>
 
-               <properties>
-                       <property name="model"/>
-                       <property name="serial"/>
-               </properties>
+               <config-description>
+                       <parameter name="deviceId" type="integer">
+                               <label>Device ID</label>
+                               <description>Specific device identifier</description>
+                               <default>0</default>
+                       </parameter>
+               </config-description>
+       </thing-type>
+
+       <!-- Ohmpilot Thing Type -->
+       <thing-type id="ohmpilot">
+               <supported-bridge-type-refs>
+                       <bridge-type-ref id="bridge"/>
+               </supported-bridge-type-refs>
+               <label>Fronius Ohmpilot</label>
+               <description>Fronius Ohmpilot</description>
+
+               <channels>
+                       <channel id="powerrealsum" typeId="ohmpilot_powerreal"/>
+                       <channel id="energyrealsumconsumed" typeId="ohmpilot_energy"/>
+                       <channel id="temperaturechannel1" typeId="ohmpilot_temperature"/>
+                       <channel id="statecode" typeId="devicestatus_statuscode"/>
+                       <channel id="errorcode" typeId="devicestatus_errorcode"/>
+               </channels>
 
                <config-description>
                        <parameter name="deviceId" type="integer">
        <channel-type id="meter_ac_current">
                <item-type>Number:ElectricCurrent</item-type>
                <label>AC Current</label>
-               <description></description>
                <state pattern="%.2f %unit%" readOnly="true"></state>
        </channel-type>
        <channel-type id="meter_ac_voltage">
                <item-type>Number:ElectricPotential</item-type>
                <label>AC Voltage</label>
-               <description></description>
                <state pattern="%.2f %unit%" readOnly="true"></state>
        </channel-type>
        <channel-type id="meter_powerreal">
                <item-type>Number:Power</item-type>
                <label>Power</label>
-               <description></description>
                <state pattern="%.2f %unit%" readOnly="true"></state>
        </channel-type>
        <channel-type id="meter_powerfactor">
                <item-type>Number</item-type>
                <label>Power Factor</label>
-               <description></description>
                <state pattern="%.2f" readOnly="true"></state>
        </channel-type>
        <channel-type id="meter_energy">
                <item-type>Number:Energy</item-type>
                <label>Energy</label>
-               <description></description>
                <state pattern="%.2f %unit%" readOnly="true"></state>
        </channel-type>
 
+       <channel-type id="ohmpilot_powerreal">
+               <item-type>Number:Power</item-type>
+               <label>Real Power Sum</label>
+               <description>Actual power consumption [W]</description>
+               <state pattern="%.2f %unit%" readOnly="true"></state>
+       </channel-type>
+       <channel-type id="ohmpilot_energy">
+               <item-type>Number:Energy</item-type>
+               <label>Real Energy Consumed</label>
+               <description>Total consumed energy [Wh]</description>
+               <state pattern="%.2f %unit%" readOnly="true"></state>
+       </channel-type>
+       <channel-type id="ohmpilot_temperature">
+               <item-type>Number:Temperature</item-type>
+               <label>Temperature</label>
+               <description>Temperature of the PT1000</description>
+               <state pattern="%.2f %unit%" readOnly="true"></state>
+       </channel-type>
+
+
+
 </thing:thing-descriptions>