Search in sources :

Example 6 with DeviceStateUpdateImpl

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

the class DeviceStatusManagerImpl method readOutputValue.

private void readOutputValue(Device device) {
    short outputIndex = DeviceConstants.DEVICE_SENSOR_OUTPUT;
    if (device.isShade()) {
        outputIndex = DeviceConstants.DEVICE_SENSOR_SLAT_POSITION_OUTPUT;
    }
    int outputValue = this.digitalSTROMClient.getDeviceOutputValue(connMan.getSessionToken(), device.getDSID(), null, null, outputIndex);
    if (outputValue != -1) {
        if (!device.isShade()) {
            device.updateInternalDeviceState(new DeviceStateUpdateImpl(DeviceStateUpdate.OUTPUT, outputValue));
        } else {
            device.updateInternalDeviceState(new DeviceStateUpdateImpl(DeviceStateUpdate.SLATPOSITION, outputValue));
            if (device.isBlind()) {
                outputValue = this.digitalSTROMClient.getDeviceOutputValue(connMan.getSessionToken(), device.getDSID(), null, null, DeviceConstants.DEVICE_SENSOR_SLAT_ANGLE_OUTPUT);
                device.updateInternalDeviceState(new DeviceStateUpdateImpl(DeviceStateUpdate.SLAT_ANGLE, outputValue));
            }
        }
    }
}
Also used : DeviceStateUpdateImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl)

Example 7 with DeviceStateUpdateImpl

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

the class DeviceImpl method internalCallScene.

@Override
public synchronized void internalCallScene(Short sceneNumber) {
    logger.debug("call Scene id {} dSID {}", sceneNumber, dsid.getValue());
    if (isDeviceWithOutput()) {
        activeSceneNumber = sceneNumber;
        informLastSceneAboutSceneCall(sceneNumber);
        if (!isShade()) {
            outputValueBeforeSceneCall = this.outputValue;
        } else {
            outputValueBeforeSceneCall = this.slatPosition;
            if (isBlind()) {
                slatAngleBeforeSceneCall = this.slatAngle;
            }
        }
        if (!checkSceneNumber(sceneNumber)) {
            if (containsSceneConfig(sceneNumber)) {
                if (doIgnoreScene(sceneNumber)) {
                    return;
                }
            } else {
                this.deviceStateUpdates.add(new DeviceStateUpdateImpl(DeviceStateUpdate.UPDATE_SCENE_CONFIG, new Short[] { sceneNumber, GeneralLibConstance.HIGHEST_READ_OUT_PRIORITY }));
            }
            if (sceneOutputMap.get(sceneNumber) != null) {
                if (!isShade()) {
                    updateInternalDeviceState(new DeviceStateUpdateImpl(DeviceStateUpdate.OUTPUT, sceneOutputMap.get(sceneNumber)[GeneralLibConstance.SCENE_ARRAY_INDEX_VALUE]));
                } else {
                    updateInternalDeviceState(new DeviceStateUpdateImpl(DeviceStateUpdate.SLATPOSITION, sceneOutputMap.get(sceneNumber)[GeneralLibConstance.SCENE_ARRAY_INDEX_VALUE]));
                    if (isBlind()) {
                        updateInternalDeviceState(new DeviceStateUpdateImpl(DeviceStateUpdate.SLAT_ANGLE, sceneOutputMap.get(sceneNumber)[GeneralLibConstance.SCENE_ARRAY_INDEX_ANGLE]));
                    }
                }
            } else {
                this.deviceStateUpdates.add(new DeviceStateUpdateImpl(DeviceStateUpdate.UPDATE_SCENE_OUTPUT, new Short[] { sceneNumber, GeneralLibConstance.HIGHEST_READ_OUT_PRIORITY }));
            }
        }
    }
}
Also used : DeviceStateUpdateImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl)

Example 8 with DeviceStateUpdateImpl

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

the class DeviceImpl method internalSetOff.

private void internalSetOff() {
    this.isOn = false;
    logger.debug("internal set OFF ");
    if (!checkPowerSensorRefreshPriorityNever(SensorEnum.ACTIVE_POWER)) {
        if (getSensorDataReadingInitialized(SensorEnum.ACTIVE_POWER)) {
            deviceStateUpdates.add(new DeviceStateUpdateImpl(SensorEnum.ACTIVE_POWER, -1));
            logger.debug("internal set sensor to 0");
        }
        setDsSensorValue(SensorEnum.ACTIVE_POWER, 0);
    }
    if (!checkPowerSensorRefreshPriorityNever(SensorEnum.OUTPUT_CURRENT)) {
        if (getSensorDataReadingInitialized(SensorEnum.OUTPUT_CURRENT)) {
            deviceStateUpdates.add(new DeviceStateUpdateImpl(SensorEnum.OUTPUT_CURRENT, -1));
        }
        setDsSensorValue(SensorEnum.OUTPUT_CURRENT, 0);
    }
    if (!checkPowerSensorRefreshPriorityNever(SensorEnum.POWER_CONSUMPTION)) {
        if (getSensorDataReadingInitialized(SensorEnum.POWER_CONSUMPTION)) {
            deviceStateUpdates.add(new DeviceStateUpdateImpl(SensorEnum.POWER_CONSUMPTION, -1));
        }
        setDsSensorValue(SensorEnum.POWER_CONSUMPTION, 0);
    }
}
Also used : DeviceStateUpdateImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl)

Example 9 with DeviceStateUpdateImpl

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl 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 10 with DeviceStateUpdateImpl

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

the class DeviceImpl method saveConfigSceneSpecificationIntoDevice.

@SuppressWarnings("null")
@Override
public void saveConfigSceneSpecificationIntoDevice(Map<String, String> propertries) {
    if (propertries != null) {
        String sceneSave;
        for (String key : propertries.keySet()) {
            if (key.startsWith(DigitalSTROMBindingConstants.DEVICE_SCENE)) {
                try {
                    short sceneID = Short.parseShort((String) key.subSequence(DigitalSTROMBindingConstants.DEVICE_SCENE.length(), key.length()));
                    sceneSave = propertries.get(key);
                    if (StringUtils.isNotBlank(sceneSave)) {
                        logger.debug("Find saved scene configuration for device with dSID {} and sceneID {}", dsid, key);
                        String[] sceneParm = sceneSave.replace(" ", "").split(",");
                        JSONDeviceSceneSpecImpl sceneSpecNew = null;
                        int sceneValue = -1;
                        int sceneAngle = -1;
                        for (int j = 0; j < sceneParm.length; j++) {
                            String[] sceneParmSplit = sceneParm[j].split(":");
                            switch(sceneParmSplit[0]) {
                                case "Scene":
                                    sceneSpecNew = new JSONDeviceSceneSpecImpl(sceneParmSplit[1]);
                                    break;
                                case "dontcare":
                                    sceneSpecNew.setDontcare(Boolean.parseBoolean(sceneParmSplit[1]));
                                    break;
                                case "localPrio":
                                    sceneSpecNew.setLocalPrio(Boolean.parseBoolean(sceneParmSplit[1]));
                                    break;
                                case "specialMode":
                                    sceneSpecNew.setSpecialMode(Boolean.parseBoolean(sceneParmSplit[1]));
                                    break;
                                case "sceneValue":
                                    sceneValue = Integer.parseInt(sceneParmSplit[1]);
                                    break;
                                case "sceneAngle":
                                    sceneAngle = Integer.parseInt(sceneParmSplit[1]);
                                    break;
                            }
                        }
                        if (sceneValue > -1) {
                            logger.debug("Saved sceneValue {}, sceneAngle {} for scene id {} into device with dsid {}", sceneValue, sceneAngle, sceneID, getDSID().getValue());
                            internalSetSceneOutputValue(sceneID, sceneValue, sceneAngle);
                            deviceStateUpdates.add(new DeviceStateUpdateImpl(DeviceStateUpdate.UPDATE_SCENE_OUTPUT, new Short[] { sceneID, (short) -1 }));
                        }
                        if (sceneSpecNew != null) {
                            logger.debug("Saved sceneConfig: [{}] for scene id {} into device with dsid {}", sceneSpecNew.toString(), sceneID, getDSID().getValue());
                            synchronized (sceneConfigMap) {
                                sceneConfigMap.put(sceneID, sceneSpecNew);
                            }
                            deviceStateUpdates.add(new DeviceStateUpdateImpl(DeviceStateUpdate.UPDATE_SCENE_CONFIG, new Short[] { sceneID, (short) -1 }));
                        }
                    }
                } catch (NumberFormatException e) {
                // ignore
                }
            }
        }
    }
}
Also used : DeviceStateUpdateImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl) JSONDeviceSceneSpecImpl(org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.JSONDeviceSceneSpecImpl)

Aggregations

DeviceStateUpdateImpl (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.DeviceStateUpdateImpl)13 SensorEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.SensorEnum)3 PercentType (org.eclipse.smarthome.core.library.types.PercentType)2 StringType (org.eclipse.smarthome.core.library.types.StringType)2 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 JSONDeviceSceneSpecImpl (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.impl.JSONDeviceSceneSpecImpl)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 RefreshType (org.eclipse.smarthome.core.types.RefreshType)1