Hello, I have successfully installed and configured openHab on my Raspberry Pi. However, I need some help with the coding of a transformation script:
I’m using the “Fritzbox TR064” Binding in order to integrate my phone which works pretty well already. The item definition for an incoming call is:
The setup works, but once the incoming call ended, I get an “Err” since the input for “[%2$s]” is empty. My question now is how to write a transformation script in javascript to prevent the BasicUI from showing “Err” when there is no incoming call. I’ve tried to get the second argument and if it is empty, to return a valid value. But I can’t seem to get the second parameter in my transformation script…
[ItemStateChangedEvent ] - fboxIncomingCall changed from to 54069xx,017683xxxxx
I only want to show the second number (which works with “[%2$s]”) - but if there is no active call (fboxIncomingCall is empty), I don’t want to get “Err” on my sitemap.
What I tried in my transformation script was to split the argument by “,” and always return the second one. The new definition looks like this:
OK. So the getCaller.js always returns null, or it returns null when there is no active call? I would have expected the JS to work for at least the incoming call case.
If you can’t figure anything out, you can resort to a Rule and Proxy Item.
Maybe store the value in a proxy item. When new value comes in, look if it is a real number, if yes change proxy item to new value. If null or error, keep old value.