import java.util.ArrayList;
import java.util.Optional;
+import javax.measure.quantity.Energy;
+
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.modbus.e3dc.internal.E3DCConfiguration;
import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode;
import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint;
import org.openhab.core.io.transport.modbus.PollTask;
+import org.openhab.core.library.types.QuantityType;
+import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
private ChannelUID autarkyChannel;
private ChannelUID selfConsumptionChannel;
private ChannelUID batterySOCChannel;
+ private ChannelUID batteryChargedChannel;
+ private ChannelUID batteryUnchargedChannel;
private ChannelUID string1AmpereChannel;
private ChannelUID string1VoltChannel;
autarkyChannel = channelUID(thing, POWER_GROUP, AUTARKY_CHANNEL);
selfConsumptionChannel = channelUID(thing, POWER_GROUP, SELF_CONSUMPTION_CHANNEL);
batterySOCChannel = channelUID(thing, POWER_GROUP, BATTERY_STATE_OF_CHARGE_CHANNEL);
+ batteryChargedChannel = channelUID(thing, POWER_GROUP, BATTERY_CHARGED_CHANNEL);
+ batteryUnchargedChannel = channelUID(thing, POWER_GROUP, BATTERY_UNCHARGED_CHANNEL);
string1AmpereChannel = channelUID(thing, STRINGS_GROUP, STRING1_DC_CURRENT_CHANNEL);
string1VoltChannel = channelUID(thing, STRINGS_GROUP, STRING1_DC_VOLTAGE_CHANNEL);
updateState(autarkyChannel, block.autarky);
updateState(selfConsumptionChannel, block.selfConsumption);
updateState(batterySOCChannel, block.batterySOC);
+ if (config != null) {
+ if (config.batteryCapacity > 0) {
+ double soc = block.batterySOC.doubleValue();
+ QuantityType<Energy> charged = QuantityType.valueOf(soc * config.batteryCapacity / 100,
+ Units.KILOWATT_HOUR);
+ updateState(batteryChargedChannel, charged);
+ QuantityType<Energy> uncharged = QuantityType
+ .valueOf((100 - soc) * config.batteryCapacity / 100, Units.KILOWATT_HOUR);
+ updateState(batteryUnchargedChannel, uncharged);
+ }
+ }
} else {
logger.debug("Unable to get {} from provider {}", DataType.POWER, dataParser.toString());
}
channel-type.modbus.battery-power-supply-channel.description = Battery discharges and provides Power
channel-type.modbus.battery-soc-channel.label = Battery State Of Charge
channel-type.modbus.battery-soc-channel.description = Charge Level of your attached Battery in Percent
+channel-type.modbus.battery-charged-channel.label = Battery Charge
+channel-type.modbus.battery-charged-channel.description = Charged energy of battery
+channel-type.modbus.battery-uncharged-channel.label = Battery Open Capacity
+channel-type.modbus.battery-uncharged-channel.description = Open energy capacity of battery
channel-type.modbus.charge-lock-time-channel.label = Charge Lock Time Active
channel-type.modbus.charge-lock-time-channel.description = Charge Lock Time is currently active
channel-type.modbus.discharge-lock-time-channel.label = Discharge Lock Time Active
<description>Charge Level of your attached Battery in Percent</description>
<state pattern="%d %unit%" readOnly="true"/>
</channel-type>
+ <channel-type id="battery-charged-channel">
+ <item-type>Number:Energy</item-type>
+ <label>Battery Charge</label>
+ <description>Charged energy of battery</description>
+ <state pattern="%.3f %unit%" readOnly="true"/>
+ </channel-type>
+ <channel-type id="battery-uncharged-channel">
+ <item-type>Number:Energy</item-type>
+ <label>Battery Open Capacity</label>
+ <description>Open energy capacity of battery</description>
+ <state pattern="%.3f %unit%" readOnly="true"/>
+ </channel-type>
</thing:thing-descriptions>