Search in sources :

Example 1 with ButtonState

use of com.tinkerforge.BrickletDualButton.ButtonState in project openhab1-addons by openhab.

the class DualButtonButtonImpl method fetchSensorValue.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSensorValue() {
    if (tactile || this.sensorValue == null || this.sensorValue == OnOffValue.UNDEF) {
        try {
            ButtonState buttonState = tinkerforgeDevice.getButtonState();
            OnOffValue newValue;
            if (position == DualButtonDevicePosition.LEFT) {
                newValue = getValue4State(buttonState.buttonL);
            } else {
                newValue = getValue4State(buttonState.buttonR);
            }
            setSensorValue(newValue);
            logger.trace("{} fetch value: {}", position, newValue);
        } catch (TimeoutException e) {
            TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
        } catch (NotConnectedException e) {
            TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
        }
    } else {
        // send current state to update the eventbus
        setSensorValue(getSensorValue());
    }
}
Also used : OnOffValue(org.openhab.binding.tinkerforge.internal.types.OnOffValue) NotConnectedException(com.tinkerforge.NotConnectedException) ButtonState(com.tinkerforge.BrickletDualButton.ButtonState) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

ButtonState (com.tinkerforge.BrickletDualButton.ButtonState)1 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 OnOffValue (org.openhab.binding.tinkerforge.internal.types.OnOffValue)1