mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[modbus.e3dc] battery capacity added (#15085)
* battery capacity added Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com> * i18n for channel additions Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com> --------- Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
This commit is contained in:
parent
a5c47aebee
commit
03c5243174
@ -53,6 +53,8 @@ public class E3DCBindingConstants {
|
||||
public static final String AUTARKY_CHANNEL = "autarky";
|
||||
public static final String SELF_CONSUMPTION_CHANNEL = "self-consumption";
|
||||
public static final String BATTERY_STATE_OF_CHARGE_CHANNEL = "battery-soc";
|
||||
public static final String BATTERY_CHARGED_CHANNEL = "battery-charged";
|
||||
public static final String BATTERY_UNCHARGED_CHANNEL = "battery-uncharged";
|
||||
|
||||
// Channels for Wallbox Block
|
||||
public static final String WB_AVAILABLE_CHANNEL = "wb-available";
|
||||
|
@ -22,8 +22,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@NonNullByDefault
|
||||
public class E3DCConfiguration {
|
||||
|
||||
/**
|
||||
* Data refresh interval
|
||||
*/
|
||||
public int refresh = 2000;
|
||||
public double batteryCapacity = -1;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ import static org.openhab.binding.modbus.e3dc.internal.modbus.E3DCModbusConstans
|
||||
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;
|
||||
@ -36,6 +38,8 @@ import org.openhab.core.io.transport.modbus.ModbusCommunicationInterface;
|
||||
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;
|
||||
@ -98,6 +102,8 @@ public class E3DCThingHandler extends BaseBridgeHandler {
|
||||
private ChannelUID autarkyChannel;
|
||||
private ChannelUID selfConsumptionChannel;
|
||||
private ChannelUID batterySOCChannel;
|
||||
private ChannelUID batteryChargedChannel;
|
||||
private ChannelUID batteryUnchargedChannel;
|
||||
|
||||
private ChannelUID string1AmpereChannel;
|
||||
private ChannelUID string1VoltChannel;
|
||||
@ -157,6 +163,8 @@ public class E3DCThingHandler extends BaseBridgeHandler {
|
||||
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);
|
||||
@ -360,6 +368,17 @@ public class E3DCThingHandler extends BaseBridgeHandler {
|
||||
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());
|
||||
}
|
||||
|
@ -37,6 +37,10 @@ channel-type.modbus.battery-power-supply-channel.label = Battery Discharge
|
||||
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
|
||||
|
@ -22,6 +22,10 @@
|
||||
<description>Refresh Rate of E3DC values in Milliseconds</description>
|
||||
<default>2000</default>
|
||||
</parameter>
|
||||
<parameter name="batteryCapacity" type="decimal">
|
||||
<label>Battery Capacity</label>
|
||||
<description>Capacity of the built in battery in kWh</description>
|
||||
</parameter>
|
||||
</config-description>
|
||||
</bridge-type>
|
||||
</thing:thing-descriptions>
|
||||
|
@ -20,6 +20,8 @@
|
||||
<channel id="autarky" typeId="autarky-channel"/>
|
||||
<channel id="self-consumption" typeId="self-consumption-channel"/>
|
||||
<channel id="battery-soc" typeId="battery-soc-channel"/>
|
||||
<channel id="battery-charged" typeId="battery-charged-channel"/>
|
||||
<channel id="battery-uncharged" typeId="battery-uncharged-channel"/>
|
||||
</channels>
|
||||
</channel-group-type>
|
||||
</thing:thing-descriptions>
|
||||
|
@ -75,4 +75,16 @@
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user