Search in sources :

Example 1 with RGBValues

use of com.tinkerforge.BrickletLEDStrip.RGBValues in project openhab1-addons by openhab.

the class LEDGroupImpl method fetchSwitchState.

/**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
@Override
public void fetchSwitchState() {
    if (ledList.getTrackingled() != null) {
        try {
            RGBValues rgbValues = tinkerforgeDevice.getRGBValues(ledList.getTrackingled(), (short) 1);
            short[] r = rgbValues.r;
            short[] g = rgbValues.g;
            short[] b = rgbValues.b;
            if (r[0] == 0 && g[0] == 0 && b[0] == 0) {
                setSwitchState(OnOffValue.OFF);
            } else {
                setSwitchState(OnOffValue.ON);
            }
        } catch (TimeoutException e) {
            TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_TIMEOUT_EXCEPTION, e);
        } catch (NotConnectedException e) {
            TinkerforgeErrorHandler.handleError(this, TinkerforgeErrorHandler.TF_NOT_CONNECTION_EXCEPTION, e);
        }
    } else {
        setSwitchState(OnOffValue.UNDEF);
    }
}
Also used : NotConnectedException(com.tinkerforge.NotConnectedException) RGBValues(com.tinkerforge.BrickletLEDStrip.RGBValues) TimeoutException(com.tinkerforge.TimeoutException)

Aggregations

RGBValues (com.tinkerforge.BrickletLEDStrip.RGBValues)1 NotConnectedException (com.tinkerforge.NotConnectedException)1 TimeoutException (com.tinkerforge.TimeoutException)1