I have been able to make this much simpler by using the new Synop Analyzer binding and the Radiation channel in the Weatherunderground 2.0 binding. This is the net result of it:
/*
* Rules to calculate outside light lux.
* Basic idea from Domoticz LUA script at https://www.domoticz.com/wiki/Real-time_solar_data_without_any_hardware_sensor_:_azimuth,_Altitude,_Lux_sensor...
* Authors: Sébastien Joly, Neutrino, Jmleglise
*
* Adapted to openHab rule by mherwege
* 23-Jun-2017 Modified to use Okta from Synop Analyzer binding and Radiation from Astro binding
* These bindings already do most of the queries and calculations
*/
/*
* Required openHab items as input:
* Number Okta current okta value from Synop Analyzer binding
* Number TotalRadiation current total solar radiation from Astro binding
*
* Required openHab items storing results:
* Number Lux radiation in Lux
* Number WeightedLux radiation in Lux corrected for cloud layer
*/
rule "Calculate outside light"
when
Item Okta changed or
Item TotalRadiation changed
then
// Okta
var int vOkta = (Okta.state as Number).intValue
var double vTotalRadiation = (TotalRadiation.state as Number).doubleValue
// Factor of mitigation for the cloud layer
var double Kc = 1 - 0.75 * Math.pow(vOkta/8.0, 3.4)
logInfo("Light", "Kc {}", Kc)
var double vLux = vTotalRadiation / 0.0079 // Radiation in Lux. 1 Lux = 0.0079 W/m²
var double vWeightedLux = vLux * Kc // radiation of the Sun with the cloud layer
Lux.postUpdate(vLux)
WeightedLux.postUpdate(vWeightedLux)
logInfo("Light", "Lux {}", vLux)
logInfo("Light", "WeightedLux {}", vWeightedLux)
end