Search in sources :

Example 1 with ButtonState

use of org.opencean.core.common.values.ButtonState in project openhab1-addons by openhab.

the class DimmerSteppingProfile method valueChanged.

@Override
public void valueChanged(ParameterAddress parameterAddress, Value valueObject) {
    ButtonState buttonState = (ButtonState) valueObject;
    Command command = null;
    if (buttonDownPressed(parameterAddress)) {
        switch(buttonState) {
            case PRESSED:
                startDimmerThread(IncreaseDecreaseType.INCREASE);
                buttonOPressedTime = System.currentTimeMillis();
                break;
            case RELEASED:
                stopDimmerThread();
                if (isLongOButtonReleased()) {
                    buttonOPressedTime = 0;
                } else {
                    command = OnOffType.ON;
                }
                break;
        }
    } else if (buttonUpPressed(parameterAddress)) {
        switch(buttonState) {
            case PRESSED:
                startDimmerThread(IncreaseDecreaseType.DECREASE);
                buttonIPressedTime = System.currentTimeMillis();
                break;
            case RELEASED:
                stopDimmerThread();
                if (isLongIButtonReleased()) {
                    buttonIPressedTime = 0;
                } else {
                    command = OnOffType.OFF;
                }
                break;
        }
    }
    postCommand(command);
}
Also used : Command(org.openhab.core.types.Command) ButtonState(org.opencean.core.common.values.ButtonState)

Example 2 with ButtonState

use of org.opencean.core.common.values.ButtonState in project openhab1-addons by openhab.

the class RollershutterProfile method valueChanged.

@Override
public void valueChanged(ParameterAddress parameterAddress, Value valueObject) {
    ButtonState buttonState = (ButtonState) valueObject;
    Command command = null;
    if (Parameter.O.name().equals(parameterAddress.getParameterId())) {
        switch(buttonState) {
            case PRESSED:
                if (belongsToLastShortButtonPress()) {
                    command = StopMoveType.STOP;
                    lastButtonShortPressTime = 0;
                    belongsToLastShortButtonPress = true;
                    buttonOPressedTime = System.currentTimeMillis();
                } else {
                    command = UpDownType.UP;
                    buttonOPressedTime = System.currentTimeMillis();
                }
                break;
            case RELEASED:
                if (isLongOButtonReleased()) {
                    command = StopMoveType.STOP;
                    buttonOPressedTime = 0;
                } else if (belongsToLastShortButtonPress) {
                    lastButtonShortPressTime = 0;
                    belongsToLastShortButtonPress = false;
                } else {
                    lastButtonShortPressTime = System.currentTimeMillis();
                }
                break;
        }
    } else if (Parameter.I.name().equals(parameterAddress.getParameterId())) {
        switch(buttonState) {
            case PRESSED:
                if (belongsToLastShortButtonPress()) {
                    command = StopMoveType.STOP;
                    lastButtonShortPressTime = 0;
                    belongsToLastShortButtonPress = true;
                    buttonIPressedTime = System.currentTimeMillis();
                } else {
                    command = UpDownType.DOWN;
                    buttonIPressedTime = System.currentTimeMillis();
                }
                break;
            case RELEASED:
                if (isLongIButtonReleased()) {
                    command = StopMoveType.STOP;
                    buttonIPressedTime = 0;
                } else if (belongsToLastShortButtonPress) {
                    lastButtonShortPressTime = 0;
                    belongsToLastShortButtonPress = false;
                } else {
                    lastButtonShortPressTime = System.currentTimeMillis();
                }
                break;
        }
    }
    logger.debug("Received new value {} for items {}", command, items);
    postCommand(command);
}
Also used : Command(org.openhab.core.types.Command) ButtonState(org.opencean.core.common.values.ButtonState)

Example 3 with ButtonState

use of org.opencean.core.common.values.ButtonState in project openhab1-addons by openhab.

the class DimmerOnOffProfile method valueChanged.

@Override
public void valueChanged(ParameterAddress parameterAddress, Value valueObject) {
    ButtonState buttonState = (ButtonState) valueObject;
    Command command = null;
    if (buttonDownPressed(parameterAddress)) {
        switch(buttonState) {
            case PRESSED:
                startDimmerThread(IncreaseDecreaseType.INCREASE);
                buttonOPressedTime = System.currentTimeMillis();
                break;
            case RELEASED:
                stopDimmerThread();
                if (isLongOButtonReleased()) {
                    buttonOPressedTime = 0;
                } else {
                    command = OnOffType.ON;
                }
                break;
        }
    } else if (buttonUpPressed(parameterAddress)) {
        switch(buttonState) {
            case PRESSED:
                startDimmerThread(IncreaseDecreaseType.DECREASE);
                buttonIPressedTime = System.currentTimeMillis();
                break;
            case RELEASED:
                stopDimmerThread();
                if (isLongIButtonReleased()) {
                    buttonIPressedTime = 0;
                } else {
                    command = OnOffType.OFF;
                }
                break;
        }
    }
    postCommand(command);
}
Also used : Command(org.openhab.core.types.Command) ButtonState(org.opencean.core.common.values.ButtonState)

Aggregations

ButtonState (org.opencean.core.common.values.ButtonState)3 Command (org.openhab.core.types.Command)3