use of org.eclipse.smarthome.binding.digitalstrom.internal.lib.climate.datatypes.CachedSensorValue in project smarthome by eclipse.
the class BaseSensorValues method addSensorValue.
/**
* Adds a sensor value through the digitalSTROM-API response as {@link JsonObject}. The boolean outdoor has to be
* set to indicate that it is an outdoor or indoor value (needed to choose the right sensor type).
*
* @param jObject must not be null
* @param outdoor (true = outdoor; false = indoor)
*/
protected void addSensorValue(JsonObject jObject, boolean outdoor) {
if (jObject.get(JSONApiResponseKeysEnum.TEMPERATION_VALUE.getKey()) != null) {
SensorEnum sensorType = SensorEnum.TEMPERATURE_INDOORS;
if (outdoor) {
sensorType = SensorEnum.TEMPERATURE_OUTDOORS;
}
addSensorValue(new CachedSensorValue(sensorType, jObject.get(JSONApiResponseKeysEnum.TEMPERATION_VALUE.getKey()).getAsFloat(), jObject.get(JSONApiResponseKeysEnum.TEMPERATION_VALUE_TIME.getKey()).getAsString()));
}
if (jObject.get(JSONApiResponseKeysEnum.HUMIDITY_VALUE.getKey()) != null) {
SensorEnum sensorType = SensorEnum.RELATIVE_HUMIDITY_INDOORS;
if (outdoor) {
sensorType = SensorEnum.RELATIVE_HUMIDITY_OUTDOORS;
}
addSensorValue(new CachedSensorValue(sensorType, jObject.get(JSONApiResponseKeysEnum.HUMIDITY_VALUE.getKey()).getAsFloat(), jObject.get(JSONApiResponseKeysEnum.HUMIDITY_VALUE_TIME.getKey()).getAsString()));
}
if (jObject.get(JSONApiResponseKeysEnum.CO2_CONCENTRATION_VALUE.getKey()) != null) {
addSensorValue(new CachedSensorValue(SensorEnum.CARBON_DIOXIDE, jObject.get(JSONApiResponseKeysEnum.CO2_CONCENTRATION_VALUE.getKey()).getAsFloat(), jObject.get(JSONApiResponseKeysEnum.CO2_CONCENTRATION_VALUE_TIME.getKey()).getAsString()));
}
if (jObject.get(JSONApiResponseKeysEnum.BRIGHTNESS_VALUE.getKey()) != null) {
SensorEnum sensorType = SensorEnum.BRIGHTNESS_INDOORS;
if (outdoor) {
sensorType = SensorEnum.BRIGHTNESS_OUTDOORS;
}
addSensorValue(new CachedSensorValue(sensorType, jObject.get(JSONApiResponseKeysEnum.BRIGHTNESS_VALUE.getKey()).getAsFloat(), jObject.get(JSONApiResponseKeysEnum.BRIGHTNESS_VALUE_TIME.getKey()).getAsString()));
}
}
Aggregations