Which ECMAscript are you using? For the OH3.X there is a built-in ECMAscript using an older JS which if you are just starting you should probably avoid because it is on its way out. And a newer version for which you have to install the JSScripting Add-on.
For console.info(‘Luminance change detected’);
you need that newer version.