Virtual Solar Light Sensor [;]

This rule template works as a virtual light sensor, providing a software only approximation of a hardware outside light sensor.
It takes total sun radiation, as provided by the Astro binding, and corrects it for clouds with data provided by the by the Synop Analyzer binding or a weather binding. The resulting light intensity value in Lux updates an item that can be used to trigger outside light level dependent behaviour in other rules.

Language: javascript


  • JavaScript Scripting Add-on installed.
  • Total Radiation item: item representing total sun radiation in a location, as provided by the Astro binding.
  • Cloudiness item: item representing cloudiness. This can be an okta value as provided by the Synop Analyzer binding or a cloudiness percentage as provided by a weather binding.


The rule template needs to be configured with 2 input and 1 or 2 output items.


  • Total Radiation: name of the item (Number) that represents the total (sum of direct and diffuse) sun radiation.
  • Cloudiness: name of the item (Number) that represents to okta value or cloudiness percentage. The okta value is a value between 0 and 8 (integer values) representing the level of cloudiness, with 0 a clear sky.
  • Percent: flag indicating if the cloudiness input is an okta value (percent = false), or a cloudiness percentage value (percent = true).


  • Lux: name of item (Number:Illuminance) that represents the total sun radiation in Lux without considering the cloud layer.
  • Weighted Lux: name of item (Number:Illuminance) that represents the sun radiation in Lux, considering the effect of the cloud layer.

One of the output items can be omitted if not relevant for your use case.


Version 1.0

  • Adapted older version of rule template (developed for ECMAScript 5.1) to ECMAScript 2022+ (ES6), for use with JavaScript Scripting Add-on and OH4.0.

Version 0.4

  • Converted to JavaScript ECMA 5.1 (Nashorn) and rule template, available here.

Version 0.3

  • Converted to jython

Version 0.2

  • DSL rule modified to use Okta from Synop Analyzer binding and Total Radiation from Astro binding

Version 0.1


A wider discussion and history can be found in the community thread.


I love how your version history is pretty much the same as most of my rule templates! :rofl: First Rules DSL, then Python, then Nashorn and finally JS Scripting.


This is totally weird but I’m not seeing this in my list of rule templates to install, even when I toggle “show unpublished” for the community marketplace. Your version string looks fine and I see no other reason why it wouldn’t be listed.

I’m on a 4.1 snapshot from a week or so ago (upgrade to the latest is in process). Can someone confirm whether it’s just me or if this is a wider problem?

I am on a milestone and I can see it, but I already had it installed, so may not be the same situation.

That’s definitely part of it. I just removed my Presence Simulation rule template that uses the exact same versioning as above. I need to experiment to figure out if our version string is wrong or if there is a bug that needs to be filed. I’ll come back with my findings.


My dev instance was at 4.0.2 and now is at 4.0.3. In both versions it is listed.

I don’t think this is a problem with 4.0.x releases, only 4.1. Thanks for confirming.

I think the current snapshot is borked. Errors everywhere from Zigbee. I’m going to go back to 4.1 M1 and will report back when I see what’s going on there.

I figured it out.

The version numbers are not working because snapshots and milestones have third and fourth level version numbers. [; is excluding the snapshots and milestones because I think it means <= x < and 4.1 M1 is greater than

I’ve been able to make Presence Simulation show back up using [;]. I’m sure other ways that will work. That’s just the first one I happened upon. I’ll continue to experiment a bit but it looks like the fix is to change the version ranges in the titles.

After experimenting some I’ll update all my titles and you can use those as a tempalte.


1 Like

I think [; should work in that case.

It should. I’m experimenting with [4.0;4.9] [;] to basically catch all OH 4 versions (assuming we don’t go above 4.9). That way I don’t have to remember to update it when a new release is made. But I’m finding a weird refresh issue with the list. I don’t think OH hits the forum every time you reload the page making it hard to test.