Search in sources :

Example 11 with PowerMaxState

use of org.openhab.binding.powermax.internal.state.PowerMaxState in project openhab1-addons by openhab.

the class PowerMaxSettingsMessage method handleMessage.

/**
     * {@inheritDoc}
     */
@Override
public PowerMaxState handleMessage() {
    super.handleMessage();
    PowerMaxState updatedState = new PowerMaxState();
    byte[] message = getRawData();
    int index = message[2] & 0x000000FF;
    int page = message[3] & 0x000000FF;
    int length = 0;
    if (getReceiveType() == PowerMaxReceiveType.SETTINGS) {
        length = message.length - 6;
        updatedState.setUpdateSettings(Arrays.copyOfRange(message, 2, 2 + 2 + length));
    } else if (getReceiveType() == PowerMaxReceiveType.SETTINGS_ITEM) {
        length = message[4] & 0x000000FF;
        byte[] data = new byte[length + 2];
        int i = 0;
        for (int j = 2; j <= 3; j++) {
            data[i++] = message[j];
        }
        for (int j = 0; j < length; j++) {
            data[i++] = message[j + 5];
        }
        updatedState.setUpdateSettings(data);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Received Powermax setting page {} index {} length {}", String.format("%02X (%d)", page, page), String.format("%02X (%d)", index, index), String.format("%02X (%d)", length, length));
    }
    return updatedState;
}
Also used : PowerMaxState(org.openhab.binding.powermax.internal.state.PowerMaxState)

Aggregations

PowerMaxState (org.openhab.binding.powermax.internal.state.PowerMaxState)11 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 PowerMaxBindingConfig (org.openhab.binding.powermax.PowerMaxBindingConfig)1 PowerMaxBindingProvider (org.openhab.binding.powermax.PowerMaxBindingProvider)1 PowerMaxEvent (org.openhab.binding.powermax.internal.connector.PowerMaxEvent)1 PowerMaxBaseMessage (org.openhab.binding.powermax.internal.message.PowerMaxBaseMessage)1 PowerMaxInfoMessage (org.openhab.binding.powermax.internal.message.PowerMaxInfoMessage)1 PowerMaxPanelSettings (org.openhab.binding.powermax.internal.state.PowerMaxPanelSettings)1 PowerMaxPanelType (org.openhab.binding.powermax.internal.state.PowerMaxPanelType)1 PowerMaxZoneSettings (org.openhab.binding.powermax.internal.state.PowerMaxZoneSettings)1 DateTimeType (org.openhab.core.library.types.DateTimeType)1 State (org.openhab.core.types.State)1