Search in sources :

Example 1 with Data

use of org.openhab.binding.modbus.e3dc.internal.modbus.Data in project openhab-addons by openhab.

the class E3DCWallboxThingHandler method handle.

public void handle(AsyncModbusReadResult result) {
    if (dataRead != ReadWriteSuccess.SUCCESS) {
        dataRead = ReadWriteSuccess.SUCCESS;
        updateStatus();
    }
    dataParser.handle(result);
    Optional<Data> wbArrayOpt = dataParser.parse(DataType.WALLBOX);
    if (wbArrayOpt.isPresent()) {
        WallboxArray wbArray = (WallboxArray) wbArrayOpt.get();
        OptionalInt wallboxId = getWallboxId(config);
        if (wallboxId.isPresent()) {
            Optional<WallboxBlock> blockOpt = wbArray.getWallboxBlock(wallboxId.getAsInt());
            if (blockOpt.isPresent()) {
                WallboxBlock block = blockOpt.get();
                synchronized (this) {
                    currentBitSet = block.getBitSet();
                }
                updateState(wbAvailableChannel, block.wbAvailable);
                updateState(wbSunmodeChannel, block.wbSunmode);
                updateState(wbChargingAbortedChannel, block.wbChargingAborted);
                updateState(wbChargingChannel, block.wbCharging);
                updateState(wbJackLockedChannel, block.wbJackLocked);
                updateState(wbJackPluggedChannel, block.wbJackPlugged);
                updateState(wbSchukoOnChannel, block.wbSchukoOn);
                updateState(wbSchukoPluggedChannel, block.wbSchukoPlugged);
                updateState(wbSchukoLockedChannel, block.wbSchukoLocked);
                updateState(wbSchukoRelay16Channel, block.wbSchukoRelay16);
                updateState(wbRelay16Channel, block.wbRelay16);
                updateState(wbRelay32Channel, block.wbRelay32);
                updateState(wb1phaseChannel, block.wb1phase);
            } else {
                logger.debug("Unable to get ID {} from WallboxArray", wallboxId);
            }
        } else {
            logger.debug("Wallbox ID {} not valid", wallboxId);
        }
    } else {
        logger.debug("Unable to get {} from Bridge", DataType.WALLBOX);
    }
}
Also used : Data(org.openhab.binding.modbus.e3dc.internal.modbus.Data) OptionalInt(java.util.OptionalInt) WallboxBlock(org.openhab.binding.modbus.e3dc.internal.dto.WallboxBlock) WallboxArray(org.openhab.binding.modbus.e3dc.internal.dto.WallboxArray)

Example 2 with Data

use of org.openhab.binding.modbus.e3dc.internal.modbus.Data in project openhab-addons by openhab.

the class DataBlockTest method testValidEmergency.

@Test
public void testValidEmergency() {
    Optional<Data> dataOpt = mc.parse(DataType.EMERGENCY);
    assertTrue(dataOpt.isPresent());
    EmergencyBlock b = (EmergencyBlock) dataOpt.get();
    assertEquals(EmergencyBlock.EP_NOT_SUPPORTED, b.epStatus.toFullString(), "EMS Status");
    assertEquals(OnOffType.OFF, b.batteryChargingLocked, "Battery charging locked");
    assertEquals(OnOffType.OFF, b.batteryDischargingLocked, "Battery discharging locked");
    assertEquals(OnOffType.OFF, b.epPossible, "EP possible");
    assertEquals(OnOffType.OFF, b.weatherPredictedCharging, "Weather Predicted charging");
    assertEquals(OnOffType.OFF, b.regulationStatus, "Regulation Status");
    assertEquals(OnOffType.OFF, b.chargeLockTime, "Charge Lock Time");
    assertEquals(OnOffType.OFF, b.dischargeLockTime, "Discharge Lock Time");
}
Also used : EmergencyBlock(org.openhab.binding.modbus.e3dc.internal.dto.EmergencyBlock) Data(org.openhab.binding.modbus.e3dc.internal.modbus.Data) Test(org.junit.jupiter.api.Test)

Example 3 with Data

use of org.openhab.binding.modbus.e3dc.internal.modbus.Data in project openhab-addons by openhab.

the class DataBlockTest method testValidPowerBlock.

@Test
public void testValidPowerBlock() {
    Optional<Data> dataOpt = mc.parse(DataType.POWER);
    assertTrue(dataOpt.isPresent());
    PowerBlock b = (PowerBlock) dataOpt.get();
    assertEquals("242 W", b.pvPowerSupply.toString(), "PV Supply");
    assertEquals("14 W", b.gridPowerSupply.toString(), "Grid Supply");
    assertEquals("0 W", b.gridPowerConsumpition.toString(), "Grid Consumption");
    assertEquals("303 W", b.batteryPowerSupply.toString(), "Battery Supply");
}
Also used : PowerBlock(org.openhab.binding.modbus.e3dc.internal.dto.PowerBlock) Data(org.openhab.binding.modbus.e3dc.internal.modbus.Data) Test(org.junit.jupiter.api.Test)

Example 4 with Data

use of org.openhab.binding.modbus.e3dc.internal.modbus.Data in project openhab-addons by openhab.

the class InfoTest method testInvalidBlockSize.

@Test
public void testInvalidBlockSize() {
    byte[] infoBlock = new byte[] { -29, -36, 1, 2, 0, -120, 69, 51, 47, 68, 67, 32, 71, 109, 98, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 49, 48, 32, 69, 32, 65, 73, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 78, 73, 78, 73, 84, 73, 65, 76, 73, 90, 69, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 49, 48, 95, 50, 48, 50, 48, 95, 48 };
    Parser mc = new Parser(DataType.INFO);
    mc.setArray(infoBlock);
    Optional<Data> infoOpt = mc.parse(DataType.INFO);
    InfoBlock b = (InfoBlock) infoOpt.get();
    // block still valid but data maybe corrupted => logged in warnings
    assertTrue(infoOpt.isPresent());
    assertNotNull(b);
}
Also used : InfoBlock(org.openhab.binding.modbus.e3dc.internal.dto.InfoBlock) Data(org.openhab.binding.modbus.e3dc.internal.modbus.Data) Parser(org.openhab.binding.modbus.e3dc.internal.modbus.Parser) Test(org.junit.jupiter.api.Test)

Example 5 with Data

use of org.openhab.binding.modbus.e3dc.internal.modbus.Data in project openhab-addons by openhab.

the class DataBlockTest method testValidPowerBlockNegativePVSupply.

@Test
public void testValidPowerBlockNegativePVSupply() {
    Optional<Data> dataOpt = mcNegativePVSupply.parse(DataType.POWER);
    assertTrue(dataOpt.isPresent());
    PowerBlock b = (PowerBlock) dataOpt.get();
    assertEquals("-330 W", b.pvPowerSupply.toString(), "PV Supply");
    assertEquals("14 W", b.gridPowerSupply.toString(), "Grid Supply");
    assertEquals("0 W", b.gridPowerConsumpition.toString(), "Grid Consumption");
    assertEquals("303 W", b.batteryPowerSupply.toString(), "Battery Supply");
}
Also used : PowerBlock(org.openhab.binding.modbus.e3dc.internal.dto.PowerBlock) Data(org.openhab.binding.modbus.e3dc.internal.modbus.Data) Test(org.junit.jupiter.api.Test)

Aggregations

Data (org.openhab.binding.modbus.e3dc.internal.modbus.Data)9 Test (org.junit.jupiter.api.Test)7 InfoBlock (org.openhab.binding.modbus.e3dc.internal.dto.InfoBlock)3 PowerBlock (org.openhab.binding.modbus.e3dc.internal.dto.PowerBlock)2 WallboxArray (org.openhab.binding.modbus.e3dc.internal.dto.WallboxArray)2 WallboxBlock (org.openhab.binding.modbus.e3dc.internal.dto.WallboxBlock)2 OptionalInt (java.util.OptionalInt)1 EmergencyBlock (org.openhab.binding.modbus.e3dc.internal.dto.EmergencyBlock)1 StringBlock (org.openhab.binding.modbus.e3dc.internal.dto.StringBlock)1 Parser (org.openhab.binding.modbus.e3dc.internal.modbus.Parser)1