Search in sources :

Example 1 with Luminance

use of org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Luminance in project openhab1-addons by openhab.

the class EpsonProjectorBinding method queryDataFromDevice.

private State queryDataFromDevice(String deviceId, EpsonProjectorCommandType commmandType, Class<? extends Item> itemType) {
    DeviceConfig device = deviceConfigCache.get(deviceId);
    if (device == null) {
        logger.error("Could not find device '{}'", deviceId);
        return null;
    }
    EpsonProjectorDevice remoteController = device.getConnection();
    if (remoteController == null) {
        logger.error("Could not find device '{}'", deviceId);
        return null;
    }
    try {
        if (remoteController.isConnected() == false) {
            remoteController.connect();
        }
        switch(commmandType) {
            case AKEYSTONE:
                int autoKeystone = remoteController.getAutoKeystone();
                return new DecimalType(autoKeystone);
            case ASPECT_RATIO:
                AspectRatio aspectRatio = remoteController.getAspectRatio();
                return new StringType(aspectRatio.toString());
            case BACKGROUND:
                Background background = remoteController.getBackground();
                return new StringType(background.toString());
            case BRIGHTNESS:
                int brightness = remoteController.getBrightness();
                return new DecimalType(brightness);
            case COLOR:
                Color color = remoteController.getColor();
                return new StringType(color.toString());
            case COLOR_MODE:
                ColorMode colorMode = remoteController.getColorMode();
                return new StringType(colorMode.toString());
            case COLOR_TEMP:
                int ctemp = remoteController.getColorTemperature();
                return new DecimalType(ctemp);
            case CONTRAST:
                int contrast = remoteController.getContrast();
                return new DecimalType(contrast);
            case DENSITY:
                int density = remoteController.getDensity();
                return new DecimalType(density);
            case DIRECT_SOURCE:
                int directSource = remoteController.getDirectSource();
                return new DecimalType(directSource);
            case ERR_CODE:
                int err = remoteController.getError();
                return new DecimalType(err);
            case ERR_MESSAGE:
                String errString = remoteController.getErrorString();
                return new StringType(errString);
            case FLESH_TEMP:
                int fleshColor = remoteController.getFleshColor();
                return new DecimalType(fleshColor);
            case GAIN_BLUE:
                int gainBlue = remoteController.getGainBlue();
                return new DecimalType(gainBlue);
            case GAIN_GREEN:
                int gainGreen = remoteController.getGainGreen();
                return new DecimalType(gainGreen);
            case GAIN_RED:
                int gainRed = remoteController.getGainRed();
                return new DecimalType(gainRed);
            case GAMMA:
                Gamma gamma = remoteController.getGamma();
                return new StringType(gamma.toString());
            case GAMMA_STEP:
                logger.warn("Get '{}' not implemented!", commmandType.toString());
                return null;
            case HKEYSTONE:
                int hKeystone = remoteController.getHorizontalKeystone();
                return new DecimalType(hKeystone);
            case HPOSITION:
                int hPosition = remoteController.getHorizontalPosition();
                return new DecimalType(hPosition);
            case HREVERSE:
                Switch hReverse = remoteController.getHorizontalReverse();
                return hReverse == Switch.ON ? OnOffType.ON : OnOffType.OFF;
            case KEY_CODE:
                break;
            case LAMP_TIME:
                int lampTime = remoteController.getLampTime();
                return new DecimalType(lampTime);
            case LUMINANCE:
                Luminance luminance = remoteController.getLuminance();
                return new StringType(luminance.toString());
            case MUTE:
                Switch mute = remoteController.getMute();
                return mute == Switch.ON ? OnOffType.ON : OnOffType.OFF;
            case OFFSET_BLUE:
                int offsetBlue = remoteController.getOffsetBlue();
                return new DecimalType(offsetBlue);
            case OFFSET_GREEN:
                int offsetGreen = remoteController.getOffsetGreen();
                return new DecimalType(offsetGreen);
            case OFFSET_RED:
                int offsetRed = remoteController.getOffsetRed();
                return new DecimalType(offsetRed);
            case POWER:
                PowerStatus powerStatus = remoteController.getPowerStatus();
                if (powerStatus == PowerStatus.ON) {
                    return OnOffType.ON;
                } else {
                    return OnOffType.OFF;
                }
            case POWER_STATE:
                PowerStatus powerStatus1 = remoteController.getPowerStatus();
                return new StringType(powerStatus1.toString());
            case SHARP:
                logger.warn("Get '{}' not implemented!", commmandType.toString());
                return null;
            case SOURCE:
                Source source = remoteController.getSource();
                return new StringType(source.toString());
            case SYNC:
                int sync = remoteController.getSync();
                return new DecimalType(sync);
            case TINT:
                int tint = remoteController.getTint();
                return new DecimalType(tint);
            case TRACKING:
                int tracking = remoteController.getTracking();
                return new DecimalType(tracking);
            case VKEYSTONE:
                int vKeystone = remoteController.getVerticalKeystone();
                return new DecimalType(vKeystone);
            case VPOSITION:
                int vPosition = remoteController.getVerticalPosition();
                return new DecimalType(vPosition);
            case VREVERSE:
                Switch vReverse = remoteController.getVerticalReverse();
                return vReverse == Switch.ON ? OnOffType.ON : OnOffType.OFF;
            default:
                logger.warn("Unknown '{}' command!", commmandType);
                return null;
        }
    } catch (EpsonProjectorException e) {
        logger.warn("Couldn't execute command '{}', {}", commmandType.toString(), e);
    } catch (Exception e) {
        logger.warn("Couldn't create state of type '{}'", itemType);
        return null;
    }
    return null;
}
Also used : Background(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Background) StringType(org.openhab.core.library.types.StringType) Color(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Color) ColorMode(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.ColorMode) Source(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Source) ConfigurationException(org.osgi.service.cm.ConfigurationException) AspectRatio(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.AspectRatio) Gamma(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Gamma) Luminance(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Luminance) Switch(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Switch) PowerStatus(org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.PowerStatus) DecimalType(org.openhab.core.library.types.DecimalType)

Aggregations

AspectRatio (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.AspectRatio)1 Background (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Background)1 Color (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Color)1 ColorMode (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.ColorMode)1 Gamma (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Gamma)1 Luminance (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Luminance)1 PowerStatus (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.PowerStatus)1 Source (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Source)1 Switch (org.openhab.binding.epsonprojector.internal.EpsonProjectorDevice.Switch)1 DecimalType (org.openhab.core.library.types.DecimalType)1 StringType (org.openhab.core.library.types.StringType)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1