Skip to content

Commit

Permalink
[fronius] Add support for Fronius Smart Meter (openhab#9209)
Browse files Browse the repository at this point in the history
* [fronius] Add support for Fronius Smart Meter
* [fronius] Use DTO, implement UoM
* [fronius] fix README.md
* [fronius] Add mandatory label for channel-type and fix property update
* [fronius] Store meterRealtimeBodyData instead of meterRealtimeResponse

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
  • Loading branch information
jimtng authored Dec 28, 2020
1 parent 9ea6c3d commit 8e93510
Show file tree
Hide file tree
Showing 11 changed files with 974 additions and 90 deletions.
122 changes: 92 additions & 30 deletions bundles/org.openhab.binding.fronius/README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,100 @@
# Fronius Binding

This binding uses the [Fronius Solar API V1](https://www.fronius.com/en/photovoltaics/products/all-products/system-monitoring/open-interfaces/fronius-solar-api-json-) to obtain data from a Fronius devices.
This binding uses the [Fronius Solar API V1](https://www.fronius.com/en/photovoltaics/products/all-products/system-monitoring/open-interfaces/fronius-solar-api-json-) to obtain data from Fronius devices.

It supports Fronius inverters and Fronius Smart Meter. Tested with a Fronius Symo 8.2-3-M and Fronius Smart Meter 63A.

## Supported Things

Support Fronius Galvo, Fronius Symo inverters 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)
| Thing Type | Description |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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) |

## Discovery

There is no discovery implemented. You have to create your things manually and specify the hostname or IP address of the Datalogger and the device id.

## Binding Configuration

The binding has no configuration options, all configuration is done at `bridge` or `powerinverter` level.
The binding has no configuration options, all configuration is done at `bridge`, `powerinverter` or `meter` level.

## Thing Configuration

### Bridge Thing Configuration

| Parameter | Description |
|-----------------|------------------------------------------------------ |
| hostname | The hostname or IP address of your Fronius Datalogger |
| refreshInterval | Refresh interval in seconds |
| Parameter | Description |
| ----------------- | ----------------------------------------------------- |
| `hostname` | The hostname or IP address of your Fronius Datalogger |
| `refreshInterval` | Refresh interval in seconds |

### Powerinverter Thing Configuration

| Parameter | Description |
|-----------------|------------------------------------------------------ |
| deviceId | The identifier of your device (Default: 1) |
| Parameter | Description |
| ---------- | ------------------------------------------ |
| `deviceId` | The identifier of your device (Default: 1) |

### Meter Thing Configuration

| Parameter | Description |
| ---------- | ----------------------------------------------- |
| `deviceId` | The identifier of your smart meter (Default: 0) |

## Channels

| Channel ID | Item Type | Description |
|------------|--------------|------------------------- |
| inverterdatachanneldayenergy | Number | Energy generated on current day |
| inverterdatachannelpac | Number | AC powery |
| inverterdatachanneltotal | Number | Energy generated overall |
| inverterdatachannelyear | Number | Energy generated in current year |
| inverterdatachannelfac | Number | AC frequency |
| inverterdatachanneliac | Number | AC current |
| inverterdatachannelidc | Number | DC current |
| inverterdatachanneluac | Number | AC voltage |
| inverterdatachanneludc | Number | DC voltage |
| inverterdatadevicestatuserrorcode | Number | Device error code |
| inverterdatadevicestatusstatuscode | Number | Device status code<br />`0` - `6` Startup<br />`7` Running <br />`8` Standby<br />`9` Bootloading<br />`10` Error |
| powerflowchannelpgrid | Number | Power + from grid, - to grid |
| powerflowchannelpload | Number | Power + generator, - consumer |
| powerflowchannelpakku | Number | Power + charge, - discharge |
### Channels for `powerinverter` Thing

| Channel ID | Item Type | Description |
| ------------------------------------ | --------- | ----------------------------------------------------------------------------------------------------------------- |
| `inverterdatachanneldayenergy` | Number | Energy generated on current day |
| `inverterdatachannelpac` | Number | AC power |
| `inverterdatachanneltotal` | Number | Energy generated overall |
| `inverterdatachannelyear` | Number | Energy generated in current year |
| `inverterdatachannelfac` | Number | AC frequency |
| `inverterdatachanneliac` | Number | AC current |
| `inverterdatachannelidc` | Number | DC current |
| `inverterdatachanneluac` | Number | AC voltage |
| `inverterdatachanneludc` | Number | DC voltage |
| `inverterdatadevicestatuserrorcode` | Number | Device error code |
| `inverterdatadevicestatusstatuscode` | Number | Device status code<br />`0` - `6` Startup<br />`7` Running <br />`8` Standby<br />`9` Bootloading<br />`10` Error |
| `powerflowchannelpgrid` | Number | Power + from grid, - to grid |
| `powerflowchannelpload` | Number | Power + generator, - consumer |
| `powerflowchannelpakku` | Number | Power + charge, - discharge |

### Channels for `meter` Thing

| Channel ID | Item Type | Description |
| ----------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enable` | Number | 1 = enabled, 0 = disabled |
| `location` | Number | 0 = grid interconnection point (primary meter)<br/> 1 = load (primary meter) <br />3 = external generator (secondary meters)(multiple)<br />256-511 = subloads (secondary meters)(unique). Refer to Fronius Solar API. |
| `currentacphase1` | Number:ElectricCurrent | AC Current on Phase 1 |
| `currentacphase2` | Number:ElectricCurrent | AC Current on Phase 2 |
| `currentacphase3` | Number:ElectricCurrent | AC Current on Phase 3 |
| `voltageacphase1` | Number:ElectricPotential | AC Voltage on Phase 1 |
| `voltageacphase2` | Number:ElectricPotential | AC Voltage on Phase 2 |
| `voltageacphase3` | Number:ElectricPotential | AC Voltage on Phase 3 |
| `powerrealphase1` | Number:Power | Real Power on Phase 1 |
| `powerrealphase2` | Number:Power | Real Power on Phase 2 |
| `powerrealphase3` | Number:Power | Real Power on Phase 3 |
| `powerfactorphase1` | Number | Power Factor on Phase 1 |
| `powerfactorphase2` | Number | Power Factor on Phase 2 |
| `powerfactorphase3` | Number | Power Factor on Phase 3 |
| `energyrealsumconsumed` | Number:Energy | Real Energy consumed |
| `energyrealsumproduced` | Number:Energy | Real Energy produced |
| |




## Properties

The `meter` thing has the following properties:

| Property | Description |
| -------- | ------------------------------ |
| `model` | The model name of the meter |
| `serial` | The serial number of the meter |

## Full Example

Expand All @@ -57,13 +103,14 @@ demo.things:
```
Bridge fronius:bridge:mybridge [hostname="192.168.66.148", refreshInterval=5] {
Thing powerinverter myinverter [deviceId=1]
Thing meter mymeter [deviceId=0]
}
```

demo.items:

```
Number AC_Powery { channel="fronius:powerinverter:mybridge:myinverter:inverterdatachannelpac" }
Number AC_Power { channel="fronius:powerinverter:mybridge:myinverter:inverterdatachannelpac" }
Number Day_Energy { channel="fronius:powerinverter:mybridge:myinverter:inverterdatachanneldayenergy" }
Number Total_Energy { channel="fronius:powerinverter:mybridge:myinverter:inverterdatachanneltotal" }
Number Year_Energy { channel="fronius:powerinverter:mybridge:myinverter:inverterdatachannelyear" }
Expand All @@ -77,6 +124,21 @@ Number StatusCode { channel="fronius:powerinverter:mybridge:myinverter:inverterd
Number Grid_Power { channel="fronius:powerinverter:mybridge:myinverter:powerflowchannelpgrid" }
Number Load_Power { channel="fronius:powerinverter:mybridge:myinverter:powerflowchannelpload" }
Number Battery_Power { channel="fronius:powerinverter:mybridge:myinverter:powerflowchannelpakku" }
```
Tested with a Fronius Symo 8.2-3-M
Number Meter_Enable { channel="fronius:meter:mybridge:mymeter:enable" }
Number Meter_Location { channel="fronius:meter:mybridge:mymeter:location" }
Number:ElectricCurrent Meter_CurrentPhase1 { channel="fronius:meter:mybridge:mymeter:currentacphase1" }
Number:ElectricCurrent Meter_CurrentPhase2 { channel="fronius:meter:mybridge:mymeter:currentacphase2" }
Number:ElectricCurrent Meter_CurrentPhase3 { channel="fronius:meter:mybridge:mymeter:currentacphase3" }
Number:Voltage Meter_VoltagePhase1 { channel="fronius:meter:mybridge:mymeter:voltageacphase1" }
Number:Voltage Meter_VoltagePhase2 { channel="fronius:meter:mybridge:mymeter:voltageacphase2" }
Number:Voltage Meter_VoltagePhase3 { channel="fronius:meter:mybridge:mymeter:voltageacphase3" }
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 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" }
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class FroniusBindingConstants {
// List of all Thing Type UIDs
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");

// List of all Channel ids
public static final String InverterDataChannelDayEnergy = "inverterdatachanneldayenergy";
Expand All @@ -46,8 +47,27 @@ public class FroniusBindingConstants {
public static final String PowerFlowpGrid = "powerflowchannelpgrid";
public static final String PowerFlowpLoad = "powerflowchannelpload";
public static final String PowerFlowpAkku = "powerflowchannelpakku";
public static final String MeterModel = "model";
public static final String MeterSerial = "serial";
public static final String MeterEnable = "enable";
public static final String MeterLocation = "location";
public static final String MeterCurrentAcPhase1 = "currentacphase1";
public static final String MeterCurrentAcPhase2 = "currentacphase2";
public static final String MeterCurrentAcPhase3 = "currentacphase3";
public static final String MeterVoltageAcPhase1 = "voltageacphase1";
public static final String MeterVoltageAcPhase2 = "voltageacphase2";
public static final String MeterVoltageAcPhase3 = "voltageacphase3";
public static final String MeterPowerPhase1 = "powerrealphase1";
public static final String MeterPowerPhase2 = "powerrealphase2";
public static final String MeterPowerPhase3 = "powerrealphase3";
public static final String MeterPowerFactorPhase1 = "powerfactorphase1";
public static final String MeterPowerFactorPhase2 = "powerfactorphase2";
public static final String MeterPowerFactorPhase3 = "powerfactorphase3";
public static final String MeterEnergyRealSumConsumed = "energyrealsumconsumed";
public static final String MeterEnergyRealSumProduced = "energyrealsumproduced";

// List of all Urls
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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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.FroniusSymoInverterHandler;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
Expand All @@ -42,6 +43,7 @@ public class FroniusHandlerFactory extends BaseThingHandlerFactory {
{
add(THING_TYPE_INVERTER);
add(THING_TYPE_BRIDGE);
add(THING_TYPE_METER);
}
};

Expand All @@ -58,6 +60,8 @@ protected ThingHandler createHandler(Thing thing) {
return new FroniusSymoInverterHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_BRIDGE)) {
return new FroniusBridgeHandler((Bridge) thing);
} else if (thingTypeUID.equals(THING_TYPE_METER)) {
return new FroniusMeterHandler(thing);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) 2010-2020 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 MeterRealtimeBody} is responsible for storing
* the "body" node of the JSON response
*
* @author Jimmy Tanagra - Initial contribution
*/
public class MeterRealtimeBodyDTO {
@SerializedName("Data")
private MeterRealtimeBodyDataDTO data;

public MeterRealtimeBodyDataDTO getData() {
if (data == null) {
data = new MeterRealtimeBodyDataDTO();
}
return data;
}

public void setData(MeterRealtimeBodyDataDTO data) {
this.data = data;
}
}
Loading

0 comments on commit 8e93510

Please sign in to comment.