Hey!
i want to create a rule to dehumidify a cellar with the script of “kisseler S.”. Therefore I wanted to use the outside humidity of openweathermap. Unfortunately, the item “localCurrentHumidity” always contains the unit “%”, which leads to an error when casting.
is the error due to the item or the script?
Failure Log:
Error during the execution of startup rule 'Taupunktberechnung
Außenbereich': Could not cast 76 % to
org.eclipse.smarthome.core.library.types.DecimalType; line 43, column 12, length 41
Item:
Number:Dimensionless localCurrentHumidity "Current atmospheric humidity [%d %unit%]" <humidity> { channel="openweathermap:weather-and-forecast:api:local:current#humidity" }
Rule:
val org.eclipse.xtext.xbase.lib.Functions$Function2<Double, Double, Double> getDewPoint = [
Double Temperature,
Double Humidity
|
var Double a
var Double b
var Double SDD
var Double DD
var Double v
var Double t = Temperature
var Double h = Humidity
if (t >= 0.0){ // T >= 0 °C
a = 7.5
b = 237.3
} else { // T < 0 °C über Wasser
a = 7.6
b = 240.7
}
SDD=(6.1078 * Math::pow(10.0, ((a*t)/(b+t))))
DD = (h/100.0*SDD)
v = Math::log10((DD/6.107))
return ((b*v)/(a-v))
]
rule "Taupunktberechnung Außenbereich" // calculation of outdoor dewpoint
when
Item Aussenbereich_Temperature changed or
Item localCurrentHumidity changed or
System started
then
if ((Aussenbereich_Temperature.state != NULL) && (localCurrentHumidity.state != NULL))
{
var t = (Aussenbereich_Temperature.state as DecimalType).doubleValue
var h = (localCurrentHumidity.state as DecimalType).doubleValue
// OutsideThermometerCombined.sendCommand(String::format("%.1f°C / %.0f%%", t, h))
Aussenbereich_Taupunkt.postUpdate(getDewPoint.apply(t, h))
}
end
rule "Taupunktberechnung Keller" // calculation of basement dewpoint
when
Item Keller_Temperature received update or
Item Keller_Humidity received update or
System started
then
if ((Keller_Temperature.state != NULL) && (Keller_Humidity.state != NULL))
{
var t = (Keller_Temperature.state as DecimalType).doubleValue
var h = (Keller_Humidity.state as DecimalType).doubleValue
// OutsideThermometerCombined.sendCommand(String::format("%.1f°C / %.0f%%", t, h))
Keller_Taupunkt.postUpdate(getDewPoint.apply(t, h))
}
end
rule "Taupunktdifferenz berechnen" // for statistics: dewpoint difference
when
Item Keller_Taupunkt changed or
Item Aussenbereich_Taupunkt changed
then
var dewpoint_keller = (Keller_Taupunkt.state as DecimalType).doubleValue
var dewpoint_aussen = (Aussenbereich_Taupunkt.state as DecimalType).doubleValue
Taupunkt_Differenz.postUpdate(dewpoint_keller - dewpoint_aussen)
end