Search in sources :

Example 1 with State

use of com.tinkerforge.BrickletDualRelay.State in project openhab1-addons by openhab.

the class MDualRelayImpl method fetchSwitchState.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated NOT
     */
@Override
public void fetchSwitchState() {
    OnOffValue switchValue = OnOffValue.UNDEF;
    try {
        State state = getMbrick().getTinkerforgeDevice().getState();
        if (relayNum == 1) {
            switchValue = (state.relay1) ? OnOffValue.ON : OnOffValue.OFF;
        } else {
            switchValue = (state.relay2) ? OnOffValue.ON : OnOffValue.OFF;
        }
        setSwitchState(switchValue);
    } catch (TimeoutException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
    } catch (NotConnectedException e) {
        TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
    }
    setSwitchState(switchValue);
}
Also used : OnOffValue(org.openhab.binding.tinkerforge.internal.types.OnOffValue) NotConnectedException(com.tinkerforge.NotConnectedException) State(com.tinkerforge.BrickletDualRelay.State) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

State (com.tinkerforge.BrickletDualRelay.State)1 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1 OnOffValue (org.openhab.binding.tinkerforge.internal.types.OnOffValue)1