Perhaps that square bracket is the error. It is not in my script.
Oh, don’t how this typo happens. Copy paste your original and restarted the Raspberry Pi. But same behavior
2017-09-10 20:55:20.521 [ERROR] [ab.binding.http.internal.HttpBinding] - Transformation ‘JS(valid_ip.js)’ threw an exception. [response=22.214.171.124
org.openhab.core.transform.TransformationException: An error occurred while loading script.
Update: Moved the *.js from scripts to transform folder and it is working
I have implemented your script on OH2.2 and it works, but I got this warning in my openhab.lg file:
2018-01-30 15:20:11.016 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
2018-01-30 15:20:11.020 [WARN ] [ab.binding.http.internal.HttpBinding] - Couldn’t transform response because transformationService of type ‘JS’ is unavailable
What is the problem ?
That was the problem.