Search in sources :

Example 1 with ControlModes

use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.climate.constants.ControlModes in project smarthome by eclipse.

the class ZoneTemperatureControlHandler method configChanged.

@Override
public synchronized void configChanged(TemperatureControlStatus tempControlStatus) {
    if (tempControlStatus != null && tempControlStatus.getIsConfigured()) {
        ControlModes controlMode = ControlModes.getControlMode(tempControlStatus.getControlMode());
        ControlStates controlState = ControlStates.getControlState(tempControlStatus.getControlState());
        if (controlMode != null && controlState != null) {
            logger.debug("config changed: {}", tempControlStatus.toString());
            if (controlMode.equals(ControlModes.OFF) && currentChannelID != null) {
                currentChannelID = null;
                loadChannel();
            } else if (controlMode.equals(ControlModes.PID_CONTROL) && (currentChannelID == null || !currentChannelID.contains(DsChannelTypeProvider.TEMPERATURE_CONTROLLED)) && !controlState.equals(ControlStates.EMERGENCY)) {
                currentChannelID = DsChannelTypeProvider.getOutputChannelTypeID(FunctionalColorGroupEnum.BLUE, OutputModeEnum.TEMPRETURE_PWM);
                loadChannel();
                currentValue = tempControlStatus.getNominalValue();
                updateState(currentChannelID, new DecimalType(currentValue.doubleValue()));
            } else if (!controlMode.equals(ControlModes.PID_CONTROL) && !controlMode.equals(ControlModes.OFF)) {
                currentChannelID = DsChannelTypeProvider.getOutputChannelTypeID(FunctionalColorGroupEnum.BLUE, OutputModeEnum.HEATING_PWM);
                loadChannel();
                currentValue = tempControlStatus.getControlValue();
                updateState(currentChannelID, new PercentType(fixPercent(currentValue.intValue())));
                if (controlState.equals(ControlStates.EMERGENCY)) {
                    updateStatus(ThingStatus.ONLINE, ThingStatusDetail.COMMUNICATION_ERROR, "The communication with temperation sensor fails. Temperature control state emergency (temperature control though the control value) is active.");
                }
            }
            // TODO: in case of control-mode zone-follower it is maybe useful to add the followed zone-id, but this
            // info is not in the control-status
            Map<String, String> properties = editProperties();
            properties.put("controlDSUID", tempControlStatus.getControlDSUID());
            properties.put("controlMode", controlMode.getKey());
            properties.put("controlState", controlState.getKey());
            updateProperties(properties);
        }
    } else {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "digitalSTROM temperature control is for this zone not configured in.");
    }
}
Also used : ControlStates(org.eclipse.smarthome.binding.digitalstrom.internal.lib.climate.constants.ControlStates) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType) PercentType(org.eclipse.smarthome.core.library.types.PercentType) ControlModes(org.eclipse.smarthome.binding.digitalstrom.internal.lib.climate.constants.ControlModes)

Aggregations

ControlModes (org.eclipse.smarthome.binding.digitalstrom.internal.lib.climate.constants.ControlModes)1 ControlStates (org.eclipse.smarthome.binding.digitalstrom.internal.lib.climate.constants.ControlStates)1 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)1 PercentType (org.eclipse.smarthome.core.library.types.PercentType)1