Mapping problem with whitespaces

I have a problem with mapping a string from an enigma2 receiver.

2017-02-28 15:02:22.451 [WARN ] [rm.AbstractFileTransformationService] - Could not transform '                                                                                                                                            
true    ' with the file '' : Target value not found in map for '                                                                                                                                                                    
true    '

My file looks like this:


How can I get this to work ? I think the problem is the spaces before and behing the string :fearful:
Any Idea ?

Ups, should read your complete question, before answering 8-). Did you try to add the whitespace to the map file?



Yes, I also think this is the problem …

But how can I resolve this ?

I did not use this before, but maybe a REGEXP transformation would work? Something like: transform(“REGEX”, “.true.”, “Ok”) ? Or you could use a Javascript transformation which returns “An” or “Aus” depending on if the input string contains “true”.

With Javascript it should work like this:

In Item configuration: JS(isTrue.js)

And in the file isTrue.js should be:

(function(i) {
if (i.includes(“true”) {
return “An”;
} else {
return “Aus”;

Don’t know, if the Javascript syntax is correct. Did you have a look at:

Thanks for your help, but also with your js code it does not work :sweat:
In the log there is nothing…

I found a solution for me :grin:

I now did it in a rule and a second item file:


rule "wozitv"                                                                                                                                                                                                                             
                Item wozitv_power_orig changed                                                                                                                                                                                            
                if (wozitv_power_orig.state.toString.deleteWhitespace == "true"){                                                                                                                                                         
                        sendCommand(wozitv_power, "OFF")                                                                                                                                                                                  
                if (wozitv_power_orig.state.toString.deleteWhitespace == "false"){                                                                                                                                                        
                        sendCommand(wozitv_power, "ON")                                                                                                                                                                                   

Thanks for your help @happenpappen

1 Like

Your .map file can have keys with spaces, if they are escaped. See this description. Or, in the alternative, the enigma2 binding author might consider stripping whitespace as a convenience to the binding user.