Search in sources :

Example 6 with SensorEnum

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum in project smarthome by eclipse.

the class DeviceImpl method setDeviceSensorByEvent.

@Override
public void setDeviceSensorByEvent(EventItem event) {
    DeviceSensorValue devSenVal = new DeviceSensorValue(event.getProperties());
    if (devSenVal != null) {
        SensorEnum sensorType = devSenVal.getSensorType();
        if (!isEchoSensor(sensorType)) {
            logger.debug("Event is no echo, set values {} for sensorType {}", devSenVal, devSenVal.getSensorType());
            if (SensorEnum.isPowerSensor(sensorType) && getSensorDataReadingInitialized(sensorType)) {
                logger.debug("SensorJob was initialized, remove sensorjob for sensorType: {}", devSenVal.getSensorType());
                deviceStateUpdates.add(new DeviceStateUpdateImpl(sensorType, -1));
            }
            setDeviceSensorValue(devSenVal);
        } else {
            logger.debug("Event is echo remove sensorType {} from echoBox", devSenVal.getSensorType());
            sensorEchoBox.remove(devSenVal.getSensorType());
        }
    }
}
Also used : SensorEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum) DeviceStateUpdateImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl) DeviceSensorValue(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceSensorValue)

Example 7 with SensorEnum

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum in project smarthome by eclipse.

the class DeviceImpl method updateInternalDeviceState.

@Override
public synchronized void updateInternalDeviceState(DeviceStateUpdate deviceStateUpdate) {
    if (deviceStateUpdate != null) {
        logger.debug("internal set outputvalue");
        switch(deviceStateUpdate.getType()) {
            case DeviceStateUpdate.OUTPUT_DECREASE:
                deviceStateUpdate = new DeviceStateUpdateImpl(DeviceStateUpdate.OUTPUT_DECREASE, internalSetOutputValue(outputValue - getDimmStep()));
                break;
            case DeviceStateUpdate.OUTPUT_INCREASE:
                deviceStateUpdate = new DeviceStateUpdateImpl(DeviceStateUpdate.OUTPUT_INCREASE, internalSetOutputValue(outputValue + getDimmStep()));
                break;
            case DeviceStateUpdate.OUTPUT:
                internalSetOutputValue(deviceStateUpdate.getValueAsInteger());
                break;
            case DeviceStateUpdate.ON_OFF:
                if (deviceStateUpdate.getValueAsInteger() < 0) {
                    internalSetOutputValue(0);
                } else {
                    internalSetOutputValue(maxOutputValue);
                }
                break;
            case DeviceStateUpdate.OPEN_CLOSE:
                if (deviceStateUpdate.getValueAsInteger() < 0) {
                    internalSetOutputValue(0);
                } else {
                    internalSetOutputValue(maxSlatPosition);
                }
                break;
            case DeviceStateUpdate.OPEN_CLOSE_ANGLE:
                if (deviceStateUpdate.getValueAsInteger() < 0) {
                    internalSetAngleValue(0);
                } else {
                    internalSetAngleValue(maxSlatAngle);
                }
                break;
            case DeviceStateUpdate.SLAT_DECREASE:
                deviceStateUpdate = new DeviceStateUpdateImpl(DeviceStateUpdate.SLAT_DECREASE, internalSetOutputValue(slatPosition - getDimmStep()));
                break;
            case DeviceStateUpdate.SLAT_INCREASE:
                deviceStateUpdate = new DeviceStateUpdateImpl(DeviceStateUpdate.SLAT_INCREASE, internalSetOutputValue(slatPosition + getDimmStep()));
            case DeviceStateUpdate.SLATPOSITION:
                internalSetOutputValue(deviceStateUpdate.getValueAsInteger());
                break;
            case DeviceStateUpdate.SLAT_ANGLE_DECREASE:
                deviceStateUpdate = new DeviceStateUpdateImpl(DeviceStateUpdate.SLAT_ANGLE_DECREASE, internalSetAngleValue(slatAngle - DeviceConstants.ANGLE_STEP_SLAT));
                break;
            case DeviceStateUpdate.SLAT_ANGLE_INCREASE:
                deviceStateUpdate = new DeviceStateUpdateImpl(DeviceStateUpdate.SLAT_ANGLE_INCREASE, internalSetAngleValue(slatAngle + DeviceConstants.ANGLE_STEP_SLAT));
                break;
            case DeviceStateUpdate.SLAT_ANGLE:
                internalSetAngleValue(deviceStateUpdate.getValueAsInteger());
                break;
            case DeviceStateUpdate.UPDATE_CALL_SCENE:
                this.internalCallScene(deviceStateUpdate.getValueAsShort());
                return;
            case DeviceStateUpdate.UPDATE_UNDO_SCENE:
                this.internalUndoScene();
                return;
            default:
                if (deviceStateUpdate.isSensorUpdateType()) {
                    SensorEnum sensorType = deviceStateUpdate.getTypeAsSensorEnum();
                    setFloatSensorValue(sensorType, deviceStateUpdate.getValueAsFloat());
                }
                return;
        }
    }
    if (activeScene != null) {
        Integer[] sceneOutput = getStandartSceneOutput(activeScene.getSceneID());
        if (sceneOutput == null) {
            sceneOutput = sceneOutputMap.get(activeScene.getSceneID());
        }
        if (sceneOutput != null) {
            boolean outputChanged = false;
            if (isShade()) {
                if (isBlind() && sceneOutput[1] != slatAngle) {
                    logger.debug("Scene output angle: {} setted output value {}", sceneOutput[1], slatAngle);
                    outputChanged = true;
                }
                if (sceneOutput[0] != slatPosition) {
                    logger.debug("Scene output value: {} setted output value {}", sceneOutput[0], slatPosition);
                    outputChanged = true;
                }
            } else {
                if (sceneOutput[0] != outputValue) {
                    logger.debug("Scene output value: {} setted output value {}", sceneOutput[0], outputValue);
                    outputChanged = true;
                }
            }
            if (outputChanged) {
                logger.debug("Device output from Device with dSID {} changed deactivate scene {}", dsid.getValue(), activeScene.getID());
                activeScene.deviceSceneChanged((short) -1);
                lastScene = null;
                activeScene = null;
            }
        } else {
            lastScene = null;
        }
    }
    informListenerAboutStateUpdate(deviceStateUpdate);
}
Also used : SensorEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum) DeviceStateUpdateImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl)

Example 8 with SensorEnum

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum in project smarthome by eclipse.

the class DsChannelTypeProvider method getChannelTypes.

@Override
public Collection<ChannelType> getChannelTypes(Locale locale) {
    List<ChannelType> channelTypeList = new LinkedList<ChannelType>();
    for (String channelTypeId : supportedOutputChannelTypes) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, channelTypeId), locale));
    }
    for (SensorEnum sensorType : SensorEnum.values()) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(sensorType)), locale));
    }
    for (MeteringTypeEnum meteringType : MeteringTypeEnum.values()) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(meteringType, MeteringUnitsEnum.WH)), locale));
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(TOTAL_PRE, meteringType, MeteringUnitsEnum.WH)), locale));
    }
    for (DeviceBinarayInputEnum binaryInput : DeviceBinarayInputEnum.values()) {
        channelTypeList.add(getChannelType(new ChannelTypeUID(DigitalSTROMBindingConstants.BINDING_ID, buildIdentifier(BINARY_INPUT_PRE, binaryInput)), locale));
    }
    return channelTypeList;
}
Also used : MeteringTypeEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum) ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) SensorEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum) DeviceBinarayInputEnum(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.DeviceBinarayInputEnum) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) LinkedList(java.util.LinkedList)

Aggregations

SensorEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum)8 DeviceStateUpdateImpl (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl)3 LinkedList (java.util.LinkedList)2 DeviceBinarayInputEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.DeviceBinarayInputEnum)2 PercentType (org.eclipse.smarthome.core.library.types.PercentType)2 StringType (org.eclipse.smarthome.core.library.types.StringType)2 CachedSensorValue (org.eclipse.smarthome.binding.digitalstrom.internal.lib.climate.datatypes.CachedSensorValue)1 DeviceConsumptionSensorJob (org.eclipse.smarthome.binding.digitalstrom.internal.lib.sensorjobexecutor.sensorjob.impl.DeviceConsumptionSensorJob)1 MeteringTypeEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum)1 DeviceBinaryInput (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceBinaryInput)1 DeviceSensorValue (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceSensorValue)1 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)1 IncreaseDecreaseType (org.eclipse.smarthome.core.library.types.IncreaseDecreaseType)1 OnOffType (org.eclipse.smarthome.core.library.types.OnOffType)1 StopMoveType (org.eclipse.smarthome.core.library.types.StopMoveType)1 UpDownType (org.eclipse.smarthome.core.library.types.UpDownType)1 Channel (org.eclipse.smarthome.core.thing.Channel)1 ThingBuilder (org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder)1 ChannelType (org.eclipse.smarthome.core.thing.type.ChannelType)1 ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)1