E-Mail with dynamic content

Hello OH2 Community,

i want to monitor our sewage treatment plant. It is controlled with a PLC which uses a TCP/Modbus interface. Transmitting and recieving the data via Modbus works fine, but unfortunatly i have problems with recieving mails from openhab, which are dynamicaly generated. I used this help: Samples Rules · openhab/openhab1-addons Wiki · GitHub

Here a snipet of my messages.rules

val string mailText =“”
rule “send Mail for sewage treatment”
when
Item error_sewage changed
then
mailText = “”
if(error_sewage.state >= 1){
if(error_pressure>=1){
mailText = mailText + “Pressure error text… blalbalbal\n”

}
if(error_time >=1){
mailText = mailText + “Time Error text… blablabla.\n”
}
}
sendMail(mailTo,“Error sewage plant”,“Hello, \n the sewage plant has following errors:\n\n” + mailText)}
end

It would have been of interest to know what isn’t working, so we can only assume!

I go for the lines(changes in bold):

if(error_sewage.state as Decimal>= 1){
if(error_pressure .state as Decimal>=1){

Hello,

The sending of the mail isn’t working.

I changed the file according to your suggestions, but sending still doesnt work.
Here the items
Switch error_sewage “Sewage Plant error” (sewage_err) {modbus=“plc_i_bit:299”}
Switch error_pressure “Pressure error” (sewage_err) {modbus=“plc_i_bit:300”}