[SOLVED] Error message in rule

Hello,

I’ll calculate the dew point (Taupunkt) with this rule:
when
Item Wetter_Burgstaedt_Temperature changed or
Item Wetter_Burgstaedt_Luftdruck changed
then
double temp = Wetter_Burgstaedt_Temperature.state
double feuchte = Wetter_Burgstaedt_Luftdruck.state

    double saettigungsDampfDruck = 6.112 * Math.pow(2.71828, (17.62 * temp)/(243.12 + temp))
    double tatsaechlicherdampfDruck = saettigungsDampfDruck / 100 * feuchte
    double taupunkt = 235 * Math.log(tatsaechlicherdampfDruck/6.11) / (17.1 - Math.log(tatsaechlicherdampfDruck/6.11))
    logInfo("rule1", "Regel Wetter: Temperatur: {}, Feuchte: {}, Taupunkt: {}", temp, feuchte, taupunkt)
    true
end

but I’ve got his errormessages:

2018-09-10 14:01:04.197 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'wetter.rules'                                             
2018-09-10 14:01:34.308 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'wetter.rules', using it anyway:
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
2018-09-10 14:01:34.375 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'wetter.rules'

Will this rule run with this errors or what is going wrong?

Thanks
Jens

rule xxx
when
  Item Wetter_Burgstaedt_Temperature changed or
  Item Wetter_Burgstaedt_Luftdruck changed
then
  val temp = Wetter_Burgstaedt_Temperature.state as Number
  val feuchte = Wetter_Burgstaedt_Luftdruck.state as Number
  val double saettigungsDampfDruck = 6.112 * Math.pow(2.71828, (17.62 * temp)/(243.12 + temp))
  val double tatsaechlicherdampfDruck = saettigungsDampfDruck / 100 * feuchte
  val double taupunkt = 235 * Math.log(tatsaechlicherdampfDruck/6.11) / (17.1 - Math.log(tatsaechlicherdampfDruck/6.11))
  logInfo("rule1", "Regel Wetter: Temperatur: {}, Feuchte: {}, Taupunkt: {}", temp, feuchte, taupunkt)
end

Thank you,

now the rule was loaded without errors…

Sincerely
:slight_smile: Jens

Try not to use primitive types in the rules DSL it seems that the parser struggles with it.

Change all your double to Number

rule xxx
when
  Item Wetter_Burgstaedt_Temperature changed or
  Item Wetter_Burgstaedt_Luftdruck changed
then
  val temp = Wetter_Burgstaedt_Temperature.state as Number
  val feuchte = Wetter_Burgstaedt_Luftdruck.state as Number
  val Number saettigungsDampfDruck = 6.112 * Math.pow(2.71828, (17.62 * temp)/(243.12 + temp))
  val Number tatsaechlicherdampfDruck = saettigungsDampfDruck / 100 * feuchte
  val Number taupunkt = 235 * Math.log(tatsaechlicherdampfDruck/6.11) / (17.1 - Math.log(tatsaechlicherdampfDruck/6.11))
  logInfo("rule1", "Regel Wetter: Temperatur: {}, Feuchte: {}, Taupunkt: {}", temp, feuchte, taupunkt)
end