Rules coding

Hello,

I want to see such text information in my sitemap:

Küche 20.0°C ➩ 21.0°C (15%)

20.0°C = current temp.
21.0°C = target temp.
(15%) = actuator

I already managed to have the current and target temp in a rule but with the actuator I have problem because sometimes it is null… Here my current rule:


EG_KUECHE_TEMP_UEBERSICHT.postUpdate(String::format("%.1f°C", (EG_KUECHE_TEMP_IST.state as DecimalType).floatValue()) + " ➩ " +  String::format("%.1f°C",   (EG_KUECHE_TEMP_SOLL.state as DecimalType).floatValue()))

For the actuator I tried such statement, but it’s not working:

EG_KUECHE_TEMP_UEBERSICHT.postUpdate(String::format("%.1f°C", (EG_KUECHE_TEMP_IST.state as DecimalType).floatValue()) + " ➩ " +  String::format("%.1f°C",   (EG_KUECHE_TEMP_SOLL.state as DecimalType).floatValue()) + if (EG_KUECHE_TEMP_STELLWERT.state != NULL){String::format("(%.1f)??", (EG_KUECHE_TEMP_STELLWERT.state as DecimalType).floatValue())}	else {" 0 "} )

Can someone help me?

Why don’t you create the desired string step by step. Using logInfo statements can see the intermediate strings. If you have the desired string complete you can shorten the rule again.

It works

20,0°C ➩ 21,0°C(15,0%)

EG_KUECHE_TEMP_UEBERSICHT.postUpdate(
 String::format("%.1f°C", (EG_KUECHE_TEMP_IST.state as DecimalType).floatValue()) + " ➩ " +
 String::format("%.1f°C", (EG_KUECHE_TEMP_SOLL.state as DecimalType).floatValue()) + 
 if (EG_KUECHE_TEMP_STELLWERT.state != NULL){String::format("(%.1f%%)", (EG_KUECHE_TEMP_STELLWERT.state as DecimalType).floatValue())} else {" 0 "} )

What version do you use?

it’s working now! I had an other error before the statement… thx