The var's are not able to store those long strings(900> characters) but you pointed me in the direction to an even simpler solution that needed just one statement added to the berry program (the red one) :
def strReplace(haystack, needle, food)
import string
return string.split(haystack, needle).concat(food)
end
def decode(value, trigger, payload)
import string
import mqtt
var codes={'1-0:1.8.1':'enrg_imp_t1','1-0:1.8.2':'enrg_imp_t2','1-0:2.8.1':'enrg_exp_t1','1-0:2.8.2':'enrg_exp_t2','0-0:96.14.0':'tariff','1-0:1.7.0':'pwr_imp','1-0:2.7.0':'pwr_exp','1-0:32.7.0':'volts_l1','1-0:52.7.0':'volts_l2','1-0:72.7.0':'volts_l3','1-0:31.7.0':'amps_l1','1-0:51.7.0':'amps_l2','1-0:71.7.0':'amps_l3','1-0:21.7.0':'l1_pwr_imp','1-0:41.7.0':'l2_pwr_imp','1-0:61.7.0':'l3_pwr_imp','1-0:22.7.0':'l1_pwr_exp','1-0:42.7.0':'l2_pwr_exp','1-0:62.7.0':'l3_pwr_exp'}
var msg=string.split(str(value),"\r\n")
var mqttmsg=map()
for it: msg
var it1=string.split(str(it),'(',1)
var key=codes.find(it1[0])
if (key!=nil)
var val=string.split(it1[1],size(it1[1])-1)[0]
val=string.split(val,'*')[0]
mqttmsg.insert(key,number(val))
end
end
mqtt.publish('tele/tasmota-esmr/DSMR5', strReplace(str(mqttmsg),"'",'"'))
mqtt.publish('cmnd/tasmota-evc/serialsend3', value)
end
tasmota.add_rule("SerialReceived",decode)