Search in sources :

Example 1 with VTMode

use of org.openhab.binding.modbus.studer.internal.StuderParser.VTMode in project openhab-addons by openhab.

the class StuderHandler method handlePolledDataVarioTrack.

/**
 * This method is called each time new data has been polled from the VarioTrack slave
 * The register array is first parsed, then each of the channels are updated
 * to the new values
 */
protected void handlePolledDataVarioTrack(int registerNumber, DecimalType quantity) {
    switch(CHANNELS_VARIOTRACK.get(registerNumber)) {
        case CHANNEL_MODEL_VARIOTRACK:
            VTType type = StuderParser.getVTTypeByCode(quantity.intValue());
            if (type == VTType.UNKNOWN) {
                internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF);
            } else {
                internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(type.name()));
            }
            break;
        case CHANNEL_OPERATING_MODE:
            VTMode vtmode = StuderParser.getVTModeByCode(quantity.intValue());
            if (vtmode == VTMode.UNKNOWN) {
                internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF);
            } else {
                internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(vtmode.name()));
            }
            break;
        case CHANNEL_STATE_VARIOTRACK:
            OnOffType vtstate = StuderParser.getStateByCode(quantity.intValue());
            internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), vtstate);
            break;
        default:
            Unit<?> unit = UNIT_CHANNELS_VARIOTRACK.get(registerNumber);
            if (unit != null) {
                internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new QuantityType<>(quantity, unit));
            }
    }
}
Also used : VTType(org.openhab.binding.modbus.studer.internal.StuderParser.VTType) VTMode(org.openhab.binding.modbus.studer.internal.StuderParser.VTMode) StringType(org.openhab.core.library.types.StringType) OnOffType(org.openhab.core.library.types.OnOffType)

Aggregations

VTMode (org.openhab.binding.modbus.studer.internal.StuderParser.VTMode)1 VTType (org.openhab.binding.modbus.studer.internal.StuderParser.VTType)1 OnOffType (org.openhab.core.library.types.OnOffType)1 StringType (org.openhab.core.library.types.StringType)1